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

IllegalStateException: WRITER masks original exception

    Details

    • Similar Issues:

      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

            Hide
            jglick Jesse Glick added a comment -

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

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

            Daniel Beck

            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.)

            Show
            evernat evernat added a comment - Daniel Beck 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.)
            Hide
            danielbeck Daniel Beck added a comment -

            In Jenkins 2.138.3 and upgraded Jetty

            Probably a different issue by now?

            Show
            danielbeck Daniel Beck added a comment - In Jenkins 2.138.3 and upgraded Jetty Probably a different issue by now?
            Hide
            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?

            Show
            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?
            Hide
            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)

            Show
            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)
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            The fix has been released in 2.56

            Show
            oleg_nenashev Oleg Nenashev added a comment - The fix has been released in 2.56
            Hide
            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)

            Show
            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)
            Hide
            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.

            Show
            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 .

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: