Isolate known attribute names for type-based @SessionAttributes by handler type#37070
Open
froggy0m0 wants to merge 1 commit into
Open
Isolate known attribute names for type-based @SessionAttributes by handler type#37070froggy0m0 wants to merge 1 commit into
froggy0m0 wants to merge 1 commit into
Conversation
Known attribute names for type-based @SessionAttributes were stored under a shared session key. This allowed one handler to retrieve or remove attributes managed by another. Store the names using a handler-type-specific session key instead. Signed-off-by: Sunghyun Shin <79225728+froggy0m0@users.noreply.github.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.
Problem
SessionAttributesHandlermanages the session attributes that a specific handler declares through@SessionAttributes.With type-based
@SessionAttributes, the actual model attribute names are discovered at runtime.SessionAttributesHandlertherefore stores these known attribute names in the sessionso they can be restored in distributed session scenarios.
However, all handler types currently store their known attribute names under the same
SESSION_KNOWN_ATTRIBUTEkey.As a result, one handler can treat names recorded by another handler as its own.
Consequently, one handler can restore session attributes managed by another.
If that handler subsequently calls
SessionStatus#setComplete(),the cleanup that follows can also remove session attributes managed by the original handler.
Changes
Include the handler type name in the session key used to store and restore known attribute names.
This keeps the known attribute names for type-based
@SessionAttributesisolated by handler type.It does not change how the actual session attributes are stored or how name-based
@SessionAttributesdeclarations behave.Tests
Add regression tests that verify the following:
I would appreciate your review of these changes. I can make changes if needed.