LDEV-6447 Correct sessionInvalidate() lifecycle - #2804
Open
shane-tw wants to merge 1 commit into
Open
Conversation
shane-tw
force-pushed
the
fix/LDEV-5942-invalidate-committed-session
branch
from
July 24, 2026 11:51
586f990 to
3364c03
Compare
shane-tw
force-pushed
the
fix/LDEV-5942-invalidate-committed-session
branch
from
July 24, 2026 12:04
3364c03 to
da6ac61
Compare
Avoid create-if-missing HttpSession calls during invalidation, including after a committed response. Do not eagerly create replacement sessions for sessionInvalidate(); subsequent SESSION access creates one lazily. Preserve sessionRotate() migration behavior.
shane-tw
force-pushed
the
fix/LDEV-5942-invalidate-committed-session
branch
from
August 5, 2026 10:28
da6ac61 to
4c947f2
Compare
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
sessionInvalidate()used create-if-missingHttpServletRequest.getSession()calls while invalidating and resetting a JEE session. Tomcat rejects session creation after the response is committed:It also eagerly created a replacement session before commit. A client could reuse that replacement
JSESSIONID, even when the caller intended the session to be completely destroyed.This change:
getSession(false)throughout invalidation so it never creates a servlet session merely to destroy it;sessionInvalidate();SESSION; andsessionRotate()ID rotation and data migration.The LDEV-4166 regression now verifies the actual contract:
onSessionEndruns synchronously for the invalidated session and no replacement session remains. Its previous session-count assertion accidentally encoded eager replacement behavior.Validation
SESSIONaccess creates a clean session with a new ID.SessionInvalidate, LDEV-4166, and the LDEV-6046 memory case (4 tests passed; database and servlet-only cases skipped where their services were unavailable).Ticket: LDEV-6447