-
Bug
-
Resolution: Done
-
Major
-
3.1.2.Final
-
None
It appears that RESTEASY runtime does not call .close() on output stream.
Many MessageBodyWritters do however call flush() o close() thus the problem is not always visible.
But for simple StringTextStar MessageBodyWritter the problem can be easyli reproduced.
ServletContainerDispatcher.service ends up calling
(after invoking user methods)
org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse()
followed by interceptors ( proceed/aroundWriteTo)
followed by message output writers (writeTo)
during this chain the output stream is never closed.
JavaDocs say in many places (CointainerResponseContext, WriterInterceptor etc)
"The JAX-RS runtime is responsible for closing the output stream".
So the stream should be closed somewhere after last call to writeTo.. but it's not.
However some message writters DO close stream (in it's writeTo). Eg ResteasyJackson2Provider internally in writeTo calls it's JsonGenerator.close() method which closes wrapped entity stream.
So when you return json entities using jackson - you have no problem with the output.
However if you return eg simple String class (org.jboss.resteasy.plugins.providers.StringTextStar) then close() is never called.
steps to reproduce:
1. setup simple jax-rs service that returns String.class entity
2. add writterInterceptor that will wrap output stream with some OutputStream that does buffering (CipherOutputStream is good example)
3. observe that you wont'get full output body (or no output at all)
instead of adding conrete wrapping output stream you may add eg FilterOutputStream + override close() method to add logging
public void close() throws IOException {
logger.info("close() called");
super.close();
}
- causes
-
RESTEASY-1710 StreamingOutput flush/close doesn't work in 3.1.4
- Closed
- is related to
-
RESTEASY-2901 Upon a serialization error, jackson2 writes garbage (partially serialized entity) to resteasy's Response
- Open