Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.2.Final, 2.1.3.Final
    • Fix Version/s: None
    • Component/s: Servlet
    • Labels:
      None

      Description

      In our applications we are seeing sporadic requests where the request attributes have been cleared prior to calling ServletRequestListener.requestDestroyed. This particular listener places an attribute in requestInitialized, which is needed in requestDestroyed to cleanup a ThreadLocal. The current situation causes a massive leak in this ThreadLocal. By adding some debugging code to Undertow, we've managed to capture a stack trace of the premature invocation of clearAttributes (see below). As can be seen in this stack trace, the attributes are cleared way before the request is being destroyed. It is still in the middle of request processing. Stack frame 12 ( H{{ttpResponseConduit.java:657}} ) suggest an Exception occurred (probably an IOException due to a closed connection).

      This regression was introduced by https://github.com/undertow-io/undertow/commit/a549027dc129ae61c94c08b046086aa2377c06a6 for UNDERTOW-1722.

      At the moment we also see that clearAttributes is called twice, once during the request, once after destroy:

      [ServletRequestListener] (default task-6) in requestInitialized
      [WicketFilter] (default task-6) Start of request
      [io.undertow.request] (default task-6) Clearing request attributes
      [WicketFilter] (default task-6) End of request
      [ServletRequestListener] (default task-6) in requestDestroyed
      [io.undertow.request] (default task-6) Clearing request attributes
      

      This is the premature invocation of clearAttributes:

      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.spec.HttpServletRequestImpl.clearAttributes(HttpServletRequestImpl.java:1204)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.spec.HttpServletRequestImpl.closeAndDrainRequest(HttpServletRequestImpl.java:695)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.core.ServletBlockingHttpExchange.close(ServletBlockingHttpExchange.java:89)
      at io.undertow.core@2.1.3.Final//io.undertow.server.HttpServerExchange.endExchange(HttpServerExchange.java:1626)
      at io.undertow.core@2.1.3.Final//io.undertow.server.AbstractServerConnection$CloseSetter.handleEvent(AbstractServerConnection.java:316)
      at io.undertow.core@2.1.3.Final//io.undertow.server.AbstractServerConnection$CloseSetter.handleEvent(AbstractServerConnection.java:296)
      at org.jboss.xnio@3.8.1.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
      at org.jboss.xnio@3.8.1.Final//org.xnio.StreamConnection.invokeCloseListener(StreamConnection.java:80)
      at org.jboss.xnio@3.8.1.Final//org.xnio.Connection.close(Connection.java:142)
      at io.undertow.core@2.1.3.Final//io.undertow.server.AbstractServerConnection.close(AbstractServerConnection.java:159)
      at org.jboss.xnio@3.8.1.Final//org.xnio.IoUtils.safeClose(IoUtils.java:152)
      at io.undertow.core@2.1.3.Final//io.undertow.server.protocol.http.HttpResponseConduit.write(HttpResponseConduit.java:657)
      at io.undertow.core@2.1.3.Final//io.undertow.conduits.ChunkedStreamSinkConduit.doWrite(ChunkedStreamSinkConduit.java:166)
      at io.undertow.core@2.1.3.Final//io.undertow.conduits.ChunkedStreamSinkConduit.write(ChunkedStreamSinkConduit.java:128)
      at org.jboss.xnio@3.8.1.Final//org.xnio.conduits.ConduitStreamSinkChannel.write(ConduitStreamSinkChannel.java:150)
      at io.undertow.core@2.1.3.Final//io.undertow.channels.DetachableStreamSinkChannel.write(DetachableStreamSinkChannel.java:240)
      at io.undertow.core@2.1.3.Final//io.undertow.server.HttpServerExchange$WriteDispatchChannel.write(HttpServerExchange.java:2111)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.spec.ServletOutputStreamImpl.writeBufferBlocking(ServletOutputStreamImpl.java:575)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.spec.ServletOutputStreamImpl.flushInternal(ServletOutputStreamImpl.java:490)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.spec.ServletPrintWriter.write(ServletPrintWriter.java:272)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.spec.ServletPrintWriter.write(ServletPrintWriter.java:301)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.spec.ServletPrintWriter.append(ServletPrintWriter.java:410)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.spec.ServletPrintWriterDelegate.append(ServletPrintWriterDelegate.java:235)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.protocol.http.servlet.ServletWebResponse.write(ServletWebResponse.java:110)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.protocol.http.HeaderBufferingWebResponse.write(HeaderBufferingWebResponse.java:179)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.protocol.http.BufferedWebResponse$WriteCharSequenceAction.invoke(BufferedWebResponse.java:171)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.protocol.http.BufferedWebResponse.writeTo(BufferedWebResponse.java:602)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:198)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:202)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:914)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:65)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:282)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:253)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:221)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:275)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:206)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:299)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//nl.topicus.cobra.webfilters.OpenJpaTransactionInViewFilter.doFilter(OpenJpaTransactionInViewFilter.java:46)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//nl.topicus.cobra.webfilters.OpenJpaTransactionInViewFilter$Proxy$_$$_WeldSubclass.doFilter$$super(Unknown Source)
      at jdk.internal.reflect.GeneratedMethodAccessor556.invoke(Unknown Source)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.base/java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.interceptor.proxy.TerminalAroundInvokeInvocationContext.proceedInternal(TerminalAroundInvokeInvocationContext.java:51)
      at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.interceptor.proxy.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:78)
      at org.jboss.jts//com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:180)
      at org.jboss.jts//com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:168)
      at org.jboss.jts//com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:53)
      at org.jboss.jts//com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:86)
      at org.jboss.jts//com.arjuna.ats.jta.cdi.transactional.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:47)
      at jdk.internal.reflect.GeneratedMethodAccessor554.invoke(Unknown Source)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.base/java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:73)
      at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeAroundInvoke(InterceptorMethodHandler.java:84)
      at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:72)
      at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:56)
      at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:79)
      at org.jboss.weld.core@3.1.4.Final//org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:68)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//nl.topicus.cobra.webfilters.OpenJpaTransactionInViewFilter$Proxy$_$$_WeldSubclass.doFilter(Unknown Source)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//nl.parnassys.core.web.ActiveRequestsPerSessionFilter.doHttpRequestFilter(ActiveRequestsPerSessionFilter.java:140)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//nl.parnassys.core.web.ActiveRequestsPerSessionFilter.doFilter(ActiveRequestsPerSessionFilter.java:112)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
      at deployment.parnassys-deliverable-las-web-ear.ear.parnassys-las-web.war//nl.parnassys.core.web.ClickjackFilter.doFilter(ClickjackFilter.java:43)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
      at org.wildfly.extension.undertow@20.0.0.Final//org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
      at io.undertow.core@2.1.3.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
      at io.undertow.core@2.1.3.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at io.undertow.core@2.1.3.Final//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
      at io.undertow.core@2.1.3.Final//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
      at io.undertow.core@2.1.3.Final//io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
      at io.undertow.core@2.1.3.Final//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
      at io.undertow.core@2.1.3.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at org.wildfly.extension.undertow@20.0.0.Final//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
      at io.undertow.core@2.1.3.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at org.wildfly.extension.undertow@20.0.0.Final//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
      at io.undertow.core@2.1.3.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
      at org.wildfly.extension.undertow@20.0.0.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
      at org.wildfly.extension.undertow@20.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
      at org.wildfly.extension.undertow@20.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
      at org.wildfly.extension.undertow@20.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
      at org.wildfly.extension.undertow@20.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
      at org.wildfly.extension.undertow@20.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
      at io.undertow.servlet@2.1.3.Final//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
      at io.undertow.core@2.1.3.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:370)
      at io.undertow.core@2.1.3.Final//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
      at org.jboss.threads@2.3.3.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      at org.jboss.threads@2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
      at org.jboss.threads@2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      at org.jboss.threads@2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
      at java.base/java.lang.Thread.run(Unknown Source)
       

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                flavia.rainone Flavia Rainone
                Reporter:
                papegaaij Emond Papegaaij
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: