Project: Tomcat
Bug 46875 CometConnectionManagerValve: concurrent access on session object when calling HttpSession.invalidate()
Reported: 2009-03-19 02:15:04 | Status: resolved wontfix

When calling invalidate() on an valid HttpSession object CometConnectionManagerValve methods sessionDestroy(HttpSessionEvent se) and event(Request request, Response response, CometEvent event) are called concurrently. So either a CometEvent with EventType.END and EventSubType.SESSION_END is never signaled via sessionDestroyed(...) or the HttpSession object has become invalid and the attribute holding comet requests can not be set or removed via event(...). I have configured CometConnectionManagerValve as a Valve element in context.xml and also as a Listener element in my applications web.xml. see this stacktrace 'sessionDestroy() was a bit faster': An exception or error occurred in the container during the request processing java.lang.IllegalStateException: removeAttribute: Session already invalidated at org.apache.catalina.session.StandardSession.removeAttribute(StandardSession.java:1206) at org.apache.catalina.session.StandardSession.removeAttribute(StandardSession.java:1181) at org.apache.catalina.session.StandardSessionFacade.removeAttribute(StandardSessionFacade.java:140) at org.apache.catalina.valves.CometConnectionManagerValve.event(CometConnectionManagerValve.java:335) at org.apache.catalina.core.StandardHostValve.event(StandardHostValve.java:179) at org.apache.catalina.valves.ValveBase.event(ValveBase.java:200) at org.apache.catalina.core.StandardEngineValve.event(StandardEngineValve.java:128) at org.apache.catalina.connector.CoyoteAdapter.event(CoyoteAdapter.java:198) at org.apache.coyote.http11.Http11NioProcessor.event(Http11NioProcessor.java:750) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.event(Http11NioProtocol.java:653) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2081) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:637)

Files changed in fix:
java/org/apache/catalina/valves/CometConnectionManagerValve.java