-
Bug
-
Resolution: Cannot Reproduce
-
Major
-
3.0.6.Final
-
None
Resteasy v.3 client does not allow to read the entity if an exception was thrown in the method that returns void.
@Path("test") public interface IService { @POST @Path("test") public void test() throws Exception; } public class Service implements IService { @Override public void test() throws Exception { throw new Exception("Blah"); } } @Provider public class ServerExceptionHandler implements ExceptionMapper<Exception> { public Response toResponse(Exception exception) { return Response.serverError().entity("Blah blah blah").build(); } }
This code (v.2 client) works fine.
IService service = ProxyFactory.create(IService.class, "http://localhost:8080/resteasy-test/test"); try { service.test(); } catch (ClientResponseFailure e) { Response resp = e.getResponse(); System.out.println(((ClientResponse) resp).getEntity(String.class)); }
But that code (v.3 client) fails.
ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = (ResteasyWebTarget) client.target("http://localhost:8080/resteasy-test/test"); IService service = target.proxy(IService.class); try { service.test(); } catch (InternalServerErrorException e) { Response resp = e.getResponse(); System.out.println(resp.readEntity(String.class)); }
Exception in thread "main" java.lang.IllegalStateException: Response is closed.
at org.jboss.resteasy.specimpl.BuiltResponse.abortIfClosed(BuiltResponse.java:254)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:148)
at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:217)
The response's entity is buffered in the DefaultEntityExtractorFactory.createVoidExtractor. However ClientResponse cannot read the entity (even from the buffer) if it was closed.
- relates to
-
RESTEASY-664 ClientErrorInterceptor: IOException Stream closed when trying to get the error message from response for methods that return void
- Closed