Repository navigation
fix(dedup): contaminate and latch asyncExecutors on background HTTP session-expiry listeners - #198
Open
slayerjain wants to merge 1 commit into
Open
slayerjain wants to merge 1 commit into
slayerjain wants to merge 1 commit into
Conversation
…ession-expiry listeners Background HTTP session-expiry timers (Tomcat StandardManager/ManagerBase, Jetty HouseKeeper/SessionInactivityTimer, Undertow InMemorySessionManager) can invoke application HttpSessionListener, HttpSessionAttributeListener, HttpSessionBindingListener, HttpSessionActivationListener, and container-native session listeners outside any HTTP request, causing application cleanup code to land silently in a later test's coverage window. - Hook container session-listener dispatch call sites in ServerEntries across Tomcat 8.5/9/10.1/11 (StandardSession), Jetty 9.4/11/12.0/12.1 (Session, ee8/ee9/nested/SessionHandler, ee10/ee11/servlet/SessionHandler, AbstractSessionManager, ManagedSession), and Undertow 2.2/2.3 (ApplicationListeners, SessionListenerBridge, SessionRestoringHandler, SessionListeners) using ASM try/finally bridges with exact fail-closed loader/callsite checks and retransform idempotency. - Route through RequestGate.enterSessionListener / exitSessionListener -> JobGate.enter(listener, "session-listener"): no-op inside an active HTTP request or tracked job (so synchronous HttpSession.invalidate() stays clean), and outside any request/job both contaminates overlapping windows (session-listener:<class>#<method>) and latches asyncExecutors=false. - Skip only exact container-native internal bridge listeners (StandardSession, SessionHandler, SingleSignOnListener, SessionListenerBridge) when invoked via container-native hooks so listener-free session expiry never false-latches. - Add SessionListenerHookTest (unit, ASM bytecode rewrite across all container dispatch classes, and forked-JVM Tomcat 9 / Jetty 9.4 / Undertow 2.2 rows). Signed-off-by: slayerjain <shubhamkjain@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Background HTTP session-expiry timers (Tomcat
StandardManager/ManagerBase, JettyHouseKeeper/SessionInactivityTimer, UndertowInMemorySessionManager) can invoke application session listeners (HttpSessionListener.sessionDestroyed,HttpSessionAttributeListener.attributeRemoved,HttpSessionBindingListener.valueUnbound,HttpSessionActivationListener, and container-native session listeners) outside any HTTP request. Without a session-listener hook, application cleanup code executed on session expiry can land silently inside an unrelated later test's coverage window.Changes
ServerEntries.java:org/apache/catalina/session/StandardSession(HttpSessionListener,HttpSessionAttributeListener,HttpSessionBindingListener,HttpSessionActivationListener,org/apache/catalina/SessionListener).org/eclipse/jetty/server/session/Session,org/eclipse/jetty/ee8/nested/SessionHandler,org/eclipse/jetty/ee9/nested/SessionHandler,org/eclipse/jetty/ee10/servlet/SessionHandler,org/eclipse/jetty/ee11/servlet/SessionHandler,org/eclipse/jetty/session/AbstractSessionManager(Session$LifeCycleListener), andorg/eclipse/jetty/session/ManagedSession(Session$ValueListener:onSessionAttributeUpdate,onSessionActivation,onSessionPassivation).io/undertow/servlet/core/ApplicationListeners,io/undertow/servlet/core/SessionListenerBridge,io/undertow/servlet/handlers/SessionRestoringHandler, andio/undertow/server/session/SessionListeners.try/finallybridge callingRequestGate.enterSessionListener(listener, methodName, containerNative)andRequestGate.exitSessionListener(token)with fail-closed loader/callsite checks and idempotent retransformation.RequestGate.java&JobGate.java:HttpSession.invalidate()stays completely clean and never false-latches).JobGate.enter(listener, "session-listener"): contaminates any overlapping test window withsession-listener:<listenerClass>#<methodName>AND latchesasyncExecutors=false.StandardSession,SessionHandler,SingleSignOnListener,SessionListenerBridge) when invoked viacontainerNative=true, so listener-free session expiry never false-latches.SessionListenerHookTest.java,SessionExpiryApp.java,SessionExpiryTail.java):onSessionAttributeUpdateand exception cleanup), and forked-JVM end-to-end tests on Tomcat 9, Jetty 9.4, and Undertow 2.2.Verification
scripts/smoke-javaagent.shon JDK 21: 449/449 PASS (0 failures, 0 errors, 0 skipped).mvn test-compilebefore test run): 9/9 KILLED (M1–M9, 0 survived, 0 compile errors).HttpSessionListenerbg,HttpSessionBindingListenerbg, sync invalidate, no-listener bg).