Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
4.7.2.Final
-
None
Description
The method ContainerRequestContext#setEntityStream is documented with,
The runtime is responsible for closing the input stream.
However when overriding this, the replaced stream is never explicitly closed. The following example prints Was closed? false when the request completes and the GC collects the stream. If this is not the responsibility of the framework, then the documentation should be clarified as it is unclear when and where the stream should be closed otherwise.
@javax.ws.rs.ext.Provider public final class TestInterceptor implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { requestContext.setEntityStream(new IsClosedInputStream(requestContext.getEntityStream())); } private static final class IsClosedInputStream extends FilterInputStream { private volatile boolean isClosed; protected IsClosedInputStream(InputStream source) { super(source); } @Override public void close() throws IOException { isClosed = true; super.close(); } @Override protected void finalize() { System.err.println("Was closed? " + isClosed); } } }