Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-3612

ClientRequestContext's overridden entity stream is not closed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 6.2.12.Final
    • jaxrs
    • None

      The issue is similar to RESTEASY-3040 but for ClientRequestContext with OutputStream.

      The method ClientRequestContext#setEntityStream is documented with,

      Set a new entity output stream. The JAX-RS runtime is responsible for closing the output stream.

      However when overriding this, the replaced stream is never explicitly closed. The following example never prints Was closed when the request completes. 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.

      import org.apache.commons.io.output.ProxyOutputStream;
      
      @jakarta.ws.rs.ext.Provider
      public final class TestInterceptor implements ClientRequestFilter {
      
        @Override
        public void filter(ClientRequestContext requestContext) {
          requestContext.setEntityStream(new ProxyInputStream(requestContext.getEntityStream()) {
            @Override
            public void close() throws IOException {
              System.err.println("Was closed");
              super.close();
            }
          });
        }
      }
       

              jperkins-rhn James Perkins
              icewil Nicolas HENRY (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: