Skip to content

Ability to ignore session restoration exceptions #2124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thomasschuerger opened this issue Aug 17, 2022 · 2 comments
Closed

Ability to ignore session restoration exceptions #2124

thomasschuerger opened this issue Aug 17, 2022 · 2 comments
Labels
status: duplicate A duplicate of another issue type: enhancement A general enhancement

Comments

@thomasschuerger
Copy link

thomasschuerger commented Aug 17, 2022

Expected Behavior

There should be a new boolean configuration property that enables turning sessions which exist but cannot be successfully restored from a SessionRepository automatically into a new session. The default value for this property should reflect the current behavior.

Current Behavior

If a session cookie contains a valid session ID and the session exists but cannot be restored (e.g. via Redis or JDBC), an exception is thrown, which (by default) makes the request fail with an internal server error. Unfortunately this problem persists if the request is retried, which can be very annoying for the users that own such a session. Such a case can easily happen if a session was serialized with an old version of the software and is tried to be restored by a new version and deserialization fails, for example because the serialVersionUID of a serialized class has changed.

Context

Class serialVersionUIDs can change over time and they may not always be under your own control. For example, recently Spring Security's DefaultSavedRequest's serialVersionUID was changed, which broke all serialized sessions that contained a DefaultSavedRequest as an attribute.

This feature should be in spring-session-core so that it is independent of the session repository used. It could easily be added to SessionRepositoryRequestWrapper.getSession(boolean), where getRequestedSession() is called, or inside getRequestedSession(). If an exception is thrown, the session should be treated as non-existent instead so that a new session is generated.

@vpavic
Copy link
Contributor

vpavic commented Aug 17, 2022

This is a duplicate of #529. Consider tracking that issue for further progress around this.

You might also want to take a look at #2099 where some aspects of this have been discussed recently.

@marcusdacoregio
Copy link
Contributor

Duplicate of #529

@marcusdacoregio marcusdacoregio marked this as a duplicate of #529 Apr 19, 2023
@marcusdacoregio marcusdacoregio added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants