Details
-
Enhancement
-
Resolution: Unresolved
-
Major
-
None
-
3.0.1.Final
-
None
Description
With reference to the conversation in the mailing list ([Resteasy-developers] Unable to fetch StreamingOutput via Client Api):
Proxy a request from one Jax-RS resource to another (secured) one.
RestInterface {
@GET
@Path("/
@Produces({"image/jpeg"})
public StreamingOutput getImage(@PathParam("id") String id);
}
RestProxyInterface {
@GET
@Path("/{id}
")
@Produces(
)
public StreamingOutput getImage(@PathParam("id") String id)
}
Client api causes following exception:
Caused by: javax.ws.rs.ProcessingException: Unable to find a MessageBodyReader of content-type image/jpeg and type interface javax.ws.rs.core.StreamingOutput
at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(ClientReaderInterceptorContext.java:39)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:73)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:50)
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:244)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:178)
at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:211)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:104)
... 35 more
So, obviously there is no reader for StreamingOutput.
Creating on:
@Provider
@Consumes("image/jpeg")
public class StreamingOutputReader implements MessageBodyReader<StreamingOutput> {
@Override
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
@Override
public StreamingOutput readFrom(Class<StreamingOutput> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws IOException, WebApplicationException {
return new StreamingOutput() {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = entityStream.read(buffer)) != -1)
}
};
}
}
Unfortunately I cannot get it to be invoked by the Client Api. Scanning providers is on and according to the logs it is recognized by resteasy.. Debugging through the code, indeed the providerFactory of ClientReaderInterceptorContext doesn't have my StreamingOutputReader...