No content to map due to end-of-input jackson parser No content to map due to end-of-input jackson parser android android

No content to map due to end-of-input jackson parser


import com.fasterxml.jackson.core.JsonParser.Feature;import com.fasterxml.jackson.databind.ObjectMapper;StatusResponses loginValidator = null;ObjectMapper objectMapper = new ObjectMapper();objectMapper.configure(Feature.AUTO_CLOSE_SOURCE, true);try {    String res = result.getResponseAsString();//{"status":"true","msg":"success"}    loginValidator = objectMapper.readValue(res, StatusResponses.class);//replaced result.getResponseAsString() with res} catch (Exception e) {    e.printStackTrace();}

Don't know how it worked and why it worked? :( but it worked


In my case the problem was caused by my passing a null InputStream to the ObjectMapper.readValue call:

ObjectMapper objectMapper = ...InputStream is = null; // The code here was returning null.Foo foo = objectMapper.readValue(is, Foo.class)

I am guessing that this is the most common reason for this exception.


I could fix this error. In my case, the problem was at client side. By mistake I did not close the stream that I was writing to server. I closed stream and it worked fine. Even the error sounds like server was not able to identify the end-of-input.

OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());out.write(jsonstring.getBytes());out.close() ; //This is what I did