This is the first time I try this, but I'm running into an error using
the client proxy on the following interface:
@Path("/user")
@Produces("application/xml")
public interface RESTCredits {
@Path("/
/inventory/credits")
@GET
public Response getCredits(@PathParam("userId") String userId);
}
Here's the client code:
RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
RESTCredits proxy = ProxyFactory.create(RESTCredits.class, "http://localhost:8080/lips/seam/resource/rest/");
ClientResponse<?> credits = (ClientResponse<?>)proxy.getCredits("xx");
assert credits.getStatus() == HttpURLConnection.HTTP_OK;
CreditList creditList = credits.getEntity(new GenericType<CreditList>(){});
And I get an exception because the MessageBodyReader gets a null InputStream.
I checked the code and it appears that the ClientResponse releases the
connection in ClientInvoker:149 because I return a Response with no
@ClientResponseType annotation. So later when I give all the hints to
getEntity() about the type, it's too late to read the response from
ApacheHttpClientExecutor:64 because the connection is closed before we
read it.
I am not sure I understand why we close the connection in
ClientInvoker:149 and I cannot use the @ClientResponseType annotation
because my method may return different types depending on HTTP status
code (which is one of the cool things about Response right?).
So if there's a really good reason to release the connection in
ClientInvoker:149 either we need to first read the data and keep it
somewhere, or @ClientResponseType needs to know about multiple return
types, but that's not very useful for what it's used at the moment,
which is make is possible for getEntity() without type parameter to
return something adequate. Or we remove the releaseConnection() call...
Can I get some advice before I patch? I need this ASAP and I'd prefer to
not make a completely broken fix.