Question: Someone can explain me what is the following 2nd parameter tries to explain. I have look around stackoverflow. I haven't got satisfactory explanation. It would be appriciated if anyone can help me to understand. Thanks in advance. My following code is not working.

```
private void showDatePickerDialog() {
    DatePickerDialog datepickerdialog = null;
    datepickerdialog = new DatePickerDialog(this,datepickerdialog.OnDateSetListener(MainActivity.this),day,month,year);
    datepickerdialog.show();
}

```

Answer: 
According to [javaDoc](https://jersey.java.net/apidocs/2.7/jersey/javax/ws/rs/core/Response.html#readEntity(java.lang.Class)), a call to readEntity closes the response entity, so when you make another readEntity call you get IllegalStateException.

> 
> Unless the supplied entity type is an input stream, this method
> automatically closes the an unconsumed original response entity data
> stream if open.
> 
> 
> 

In my case, having the expression `response.readEntity(String.class)`
in the Expressions pane in the Debug perspective caused this exception when I ran the code in Debug mode. The evaluation of the expression consumed the entity and caused it to close.
I solved this by first doing the readEntity to a String entity and then using the Jackson ObjectMapper to actually deserialize to the target class.

Problematic code:

```
Transactions transObj = response.readEntity(Transactions.class);

```

Solution:

```
String stringEntity = response.readEntity(String.class);
Transactions transObj  = objectMapper.readValue(stringEntity, Transactions.class);

```

It seems this problem arises when the JSON string in the response entity stream is very long or complex possibly requiring multiple interactions thereon. 'Deserializing' to a string seems to only require a single bite. Once you have the string (and Jackson or GSON) de-serialization to target entity takes place without touching the response.