-
Notifications
You must be signed in to change notification settings - Fork 137
Description
According to the javadoc of:
- Response.readEntity(Class)
- Response.readEntity(javax.ws.rs.core.GenericType)
- Response.readEntity(Class, Annotation [])
- Response.readEntity(javax.ws.rs.core.GenericType, Annotation [])
-
those methods are supposed to close the original entity input stream (unless the supplied type is input stream) and then cache the result for subsequent retrievals via
Response.getEntity().
So it clearly means that those methods MUST not close() the response itself, else subsequent retrievals viaResponse.getEntity()will always end up withIllegalStateExceptionbeing thrown.
Instead, only the underlying input stream should be closed. -
Subsequent call to one of those methods MUST throw an IllegalStateException if the original entity input stream has already been fully consumed without buffering the entity data prior consuming.
In other words:
Message s1 = r.readEntity(Message.class);
System.out.println(s1.toString());
System.out.println(r.getEntity()); => should not throw no exception
s1 = r.readEntity(Message.class); => should throw an IllegalStateException
Is my understanding right for those 2 points ? because it seems that many implementation (https://issues.jboss.org/browse/RESTEASY-2112) including the RI (Jersey) does not behave as exepected for point 1.
If my understanding is wrong what is the intented behavior of those methods ?