Uploaded image for project: 'Juneau'
  1. Juneau
  2. JUNEAU-80

RestCallHandlerDefault service method calls handleResponse which seems to close output stream right before it runs res.flushbuffer which throws an IO exception because the stream is closed.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 7.0.1
    • 7.1.0
    • Code
    • Red Hat Enterprise Linux Workstation release 6.9 (Santiago)
      WAS Liberty 17.0.0.1, with a CorsFilter web.xml

    Description

      If I am doing something wrong, please let me know! Please bear with me. I'm not an expert.

      I am trying to upgrade some REST infrastructure to use Juneau (7.0.1) and while all REST calls return successfully, I'm always seeing stack traces.

       

      java.io.IOException: Stream is closed
      at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.validate(HttpOutputStreamImpl.java:210)
      at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.flush(HttpOutputStreamImpl.java:592)
      at com.ibm.ws.webcontainer.osgi.response.WCOutputStream.flush(WCOutputStream.java:234)
      at org.apache.juneau.rest.RestResponse.flushBuffer(RestResponse.java:461)
      at org.apache.juneau.rest.RestCallHandler.service(RestCallHandler.java:182)
      at org.apache.juneau.rest.RestCallHandler.service(RestCallHandler.java:129)
      at org.apache.juneau.rest.RestServlet.service(RestServlet.java:142)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)

       

       

      It looks like the default rest call handler's service method is calling res.flushbuffer() which is throwing an IO exception. For the life of me, I couldn't figure out what was closing the output stream.

       

      I was wondering if maybe the default 'handleResponse' was somehow closing the response output stream so I made my own RestCallHandler with an Override'd handleResponse which does this:

      try {
      res.flushBuffer();
      } catch (IOException e1) {
      logger.info("***IO ex flush before handle resp.");
      }
      try {
      super.handleResponse(req, res, output);
      } catch (RestException e) {
      logger.info("***REST ex from handle resp.");
      } catch (IOException e) {
      logger.info("***IO ex from handle resp.");
      }
      try {
      res.flushBuffer();
      } catch (IOException e1) {
      logger.info("***IO ex flush after handle resp.");
      }
      

       

      and sure enough, I got "**IO ex flush *after handle resp." in my log.

       

      It seems that handleResponse is closing the response output stream. I did a little bit more looking, and I see that DefaultHandler has a 'os.close()' in it.

       

      Is this the culprit of my issue? (Or am I going about this wrong).

      Attachments

        1. JUNEAU-80.patch
          15 kB
          James Bognar

        Activity

          People

            Unassigned Unassigned
            stevehaertel Steve Haertel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: