Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-21695

IllegalStateException: WRITER masks original exception

    XMLWordPrintable

Details

    Description

      A RuntimeException is thrown inside HttpResponseRenderer. Rather than printing this stack trace to the log, I get

      [ERROR] /jenkins/$stapler/bound/db022930-dbbe-4ded-8c68-8690f97920f3/stuff
      java.lang.IllegalStateException: WRITER
      	at org.mortbay.jetty.Response.getOutputStream(Response.java:531)
      	at javax.servlet.ServletResponseWrapper.getOutputStream(ServletResponseWrapper.java:112)
      	at org.kohsuke.stapler.compression.CompressionServletResponse.activateCompressionIfNecessary(CompressionServletResponse.java:44)
      	at org.kohsuke.stapler.compression.CompressionServletResponse.setHeader(CompressionServletResponse.java:31)
      	at javax.servlet.http.HttpServletResponseWrapper.setHeader(HttpServletResponseWrapper.java:160)
      	at org.kohsuke.stapler.ResponseImpl.getCompressedOutputStream(ResponseImpl.java:278)
      	at org.kohsuke.stapler.jelly.DefaultScriptInvoker.createOutputStream(DefaultScriptInvoker.java:88)
      	at org.kohsuke.stapler.jelly.DefaultScriptInvoker.createXMLOutput(DefaultScriptInvoker.java:68)
      	at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:51)
      	at org.kohsuke.stapler.jelly.JellyFacet$1.dispatch(JellyFacet.java:95)
      	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:728)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:858)
      	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:631)
      	at hudson.init.impl.InstallUncaughtExceptionHandler$1.reportException(InstallUncaughtExceptionHandler.java:27)
      	at org.kohsuke.stapler.compression.CompressionFilter.reportException(CompressionFilter.java:63)
      	at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:58)
      	at ...
      

      which is not exactly helpful. It seems that rsp.getWriter() has already been called, and Jetty correctly rejects the attempt to call rsp.setHeader("Content-Encoding","gzip").

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick added a comment -

            The only workaround I can find is to run with -Dorg.kohsuke.stapler.compression.CompressionFilter.disabled (to suppress the pretty stack trace reporting page, which is irrelevant here anyway because this is an AJAX request). Got lost in ResponseImpl vs. CompressionFilter vs. CompressionServletResponse; for reasons I do not follow, at the start of getCompressedOutputStream, mode == null even though getWriter has previously been called.

            May be reproduced using test case for JENKINS-21693.

            jglick Jesse Glick added a comment - The only workaround I can find is to run with -Dorg.kohsuke.stapler.compression.CompressionFilter.disabled (to suppress the pretty stack trace reporting page, which is irrelevant here anyway because this is an AJAX request). Got lost in ResponseImpl vs. CompressionFilter vs. CompressionServletResponse ; for reasons I do not follow, at the start of getCompressedOutputStream , mode == null even though getWriter has previously been called. May be reproduced using test case for JENKINS-21693 .

            Code changed in jenkins
            User: Jesse Glick
            Path:
            core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java
            http://jenkins-ci.org/commit/jenkins/0c7e7bbc55a24cfa24ac835fd32d31a6e4e8243b
            Log:
            JENKINS-21695 - The CompressionFilter.uncaughtExceptionHandler must not attempt to write to a committed response. (#2834)

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java http://jenkins-ci.org/commit/jenkins/0c7e7bbc55a24cfa24ac835fd32d31a6e4e8243b Log: JENKINS-21695 - The CompressionFilter.uncaughtExceptionHandler must not attempt to write to a committed response. (#2834)
            oleg_nenashev Oleg Nenashev added a comment -

            The fix has been released in 2.56

            oleg_nenashev Oleg Nenashev added a comment - The fix has been released in 2.56

            Code changed in jenkins
            User: Jesse Glick
            Path:
            core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java
            http://jenkins-ci.org/commit/jenkins/161095e01b649e5453e65d5277f3bbcbefa480f4
            Log:
            JENKINS-21695 - The CompressionFilter.uncaughtExceptionHandler must not attempt to write to a committed response. (#2834)

            (cherry picked from commit 0c7e7bbc55a24cfa24ac835fd32d31a6e4e8243b)

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java http://jenkins-ci.org/commit/jenkins/161095e01b649e5453e65d5277f3bbcbefa480f4 Log: JENKINS-21695 - The CompressionFilter.uncaughtExceptionHandler must not attempt to write to a committed response. (#2834) (cherry picked from commit 0c7e7bbc55a24cfa24ac835fd32d31a6e4e8243b)
            evernat evernat added a comment -

            In Jenkins 2.138.3 and upgraded Jetty, testing response.isCommitted() does not seem enough to fix this issue.

            See https://issues.jenkins-ci.org/browse/JENKINS-55006

            A catch instead of response.isCommitted() may be needed?

            evernat evernat added a comment - In Jenkins 2.138.3 and upgraded Jetty, testing response.isCommitted() does not seem enough to fix this issue. See https://issues.jenkins-ci.org/browse/JENKINS-55006 A catch instead of response.isCommitted() may be needed?
            danielbeck Daniel Beck added a comment -

            In Jenkins 2.138.3 and upgraded Jetty

            Probably a different issue by now?

            danielbeck Daniel Beck added a comment - In Jenkins 2.138.3 and upgraded Jetty Probably a different issue by now?
            evernat evernat added a comment -

            danielbeck

            Not really a different issue.

            The problem is the same and the fix which was added using response.isCommitted() does not work anymore as seen in the stack-trace of JENKINS-55006. (I suppose that the fix was working last year.)

            evernat evernat added a comment - danielbeck Not really a different issue. The problem is the same and the fix which was added using response.isCommitted() does not work anymore as seen in the stack-trace of JENKINS-55006 . (I suppose that the fix was working last year.)
            jglick Jesse Glick added a comment -

            Please use separate issues for follow-ups rather than reopening.

            jglick Jesse Glick added a comment - Please use separate issues for follow-ups rather than reopening.

            People

              jglick Jesse Glick
              jglick Jesse Glick
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: