-
Bug
-
Resolution: Done
-
Major
-
2.0-beta-2, 2.0.1.GA
-
None
-
Workaround Exists
-
If a JAXB exception occurs when parsing a server response, the input stream never gets reset. Thus if you try to call it again with another JaxB entity, you get a SAXParseException (org.xml.sax.SAXParseException: Premature end of file.)
protected <T> T processResultsResponse(ClientResponse<T> response) {
try
catch (JAXBUnmarshalException e)
{ // --- insert workaround here -- // //This call below throws the SAXParseException) MyJaxBErrorClass = response.getEntity(MyJaxBErrorClass.class); throw MyJaxBErrorClass.createException(); }}
You can manually reset the input stream as described in the workaround, but there's no way to do that directly from the ClientResponse. I would prefer that if a getEntity call failed, it would reset itself such that it could be called again immediately - but would be happy with a resetStream() addition to the ClientResponse interface or something similar.