Uploaded image for project: 'Cache Modules'
  1. Cache Modules
  2. MGNLCACHE-201

GZipFilter tries to manipulate with already committed response

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Neutral
    • None
    • None
    • None
    • None

    Description

      This is not problem on Tomcat (which has mechanism which just ignores such a manipulation), but it's problem for example on websphere liberty, where all of this manipulations are logged as warning or it leads to Invalid state exception.

      Invalid state exception
      This exception can be reproduced for example during logout.
      GZipFilter calls responseWrapper.replay(response) which calls response.flushBuffer in CacheResponseWrapper#replayContent and then response.flushBuffer is called second time in GZipFilter#doFilter. This call then fails with Invalid State exception.
      This seems to be related to wrongly set status code GZipFilter calls responseWrapper.replay(response) then CacheResponseWrapper#replayHeadersAndStatus calls first redirect on response which commits response and then tries to set response status to 401 which is not possible anymore.

      [11/2/18 15:59:30:350 CET] 00000346 id=00000000 com.ibm.ws.webcontainer.srt.SRTServletResponse               W setStatus WARNING: Cannot set status. Response already committed.
      [11/2/18 15:59:30:530 CET] 00000346 id=00000000 com.ibm.ws.webcontainer.webapp.WebApp                        E reportRecursiveError Error Page Exception: 
                                                                                                                     magnoliaAuthor
                                                                                                                     /magnoliaAuthor
                                                                                                                     Error Page Exception
                                                                                                                     com.ibm.ws.webcontainer.webapp.WebAppErrorReport: java.io.IOException: Invalid state
      	at com.ibm.ws.webcontainer.webapp.WebApp.sendError(WebApp.java:4293)
      	at com.ibm.ws.webcontainer.webapp.WebApp.handleException(WebApp.java:5029)
      	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5009)
      	at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:314)
      	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:996)
      	at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:279)
      	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1011)
      	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:414)
      	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:373)
      	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:532)
      	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:466)
      	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:331)
      	at com.ibm.ws.http.channel.internal.inbound.HttpICLReadCallback.complete(HttpICLReadCallback.java:70)
      	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:501)
      	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:571)
      	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:926)
      	at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1015)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.io.IOException: Invalid state
      	at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.flushBuffers(HttpOutputStreamImpl.java:514)
      	at com.ibm.ws.http.channel.internal.outbound.HttpOutputStreamImpl.flush(HttpOutputStreamImpl.java:604)
      	at com.ibm.wsspi.http.ee7.HttpOutputStreamEE7.flush(HttpOutputStreamEE7.java:299)
      	at com.ibm.ws.webcontainer.osgi.response.WCOutputStream.flush(WCOutputStream.java:233)
      	at com.ibm.ws.webcontainer31.osgi.response.WCOutputStream31.flush(WCOutputStream31.java:598)
      	at com.ibm.ws.webcontainer.srt.SRTServletResponse.flushBuffer(SRTServletResponse.java:670)
      	at com.ibm.ws.webcontainer.srt.SRTServletResponse.flushBuffer(SRTServletResponse.java:635)
      

      WARNING: Cannot set header. Response already committed.
      Can be seen with all the redirects.
      CacheResponseWrapper#replayHeadersAndStatus first calls redirect on response which commits it and then tries to replay headers to response which was already commited.

      [11/2/18 15:58:03:580 CET] 000002fd id=00000000 com.ibm.ws.webcontainer.srt.SRTServletResponse               W setStatus WARNING: Cannot set status. Response already committed.
      [11/2/18 15:58:03:608 CET] 000002fd id=00000000 com.ibm.ws.webcontainer.srt.SRTServletResponse               W addHeader SRVE8094W: WARNING: Cannot set header. Response already committed.  Stack trace of errant attempt to set header: 
              at com.ibm.ws.webcontainer.srt.SRTServletResponse.addHeader(SRTServletResponse.java:2193)
              at [internal classes].(Unknown Source)
              at info.magnolia.cms.util.RequestHeaderUtil.setHeader(RequestHeaderUtil.java:79)
              at info.magnolia.module.cache.filter.CacheResponseWrapper.replayHeadersAndStatus(CacheResponseWrapper.java:374)
              at info.magnolia.module.cache.filter.CacheResponseWrapper.replay(CacheResponseWrapper.java:347)
              at info.magnolia.module.cache.filter.GZipFilter.doFilter(GZipFilter.java:97)
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              mdivilek Milan Divilek
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD