Skip to content
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

Optimize locking mechanism around storing flash attributes [SPR-11538] #16163

Closed
spring-projects-issues opened this issue Mar 11, 2014 · 1 comment
Assignees
Labels
in: web type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Mar 11, 2014

Rossen Stoyanchev opened SPR-11538 and commented

Currently AbstractFlashMapManager automatically locks on a static write lock when adding to or updating the underlying List<FlashMap> storage. The locking occurs at the start of a request, if there are expired FlashMap's (shouldn't be frequent, e.g. redirect that did not succeeded) or just before a redirect if the controller added flash attributes to be saved. Therefore locking is far from being used with every request.

Nevertheless locking could be improved in a couple of ways. First, it shouldn't be automatic in AbstractFlashMapManager. Some implementations like the cookie-based one coming in 4.1 (#13637) don't need it. Second, the lock can be more focused. The SessionFlashMapManager could use WebUtils.getSessionMutex(HttpSession) for locking on the HTTP session or a session attribuite (with HttpSessionMutexListener).


Affects: 4.0.2

Referenced from: commits 7399723

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 24, 2014

Juergen Hoeller commented

Introduced getFlashMapsMutex template method, defaulting to the shared static mutex but overridden in SessionFlashMapManager to use the session mutex instead. Can also be overridden to return null, in which case no synchronization will be used.

SessionFlashMapManager also clears the session attribute now when the given FlashMap List is empty, avoiding any kind of storage overhead.

Juergen

@spring-projects-issues spring-projects-issues added type: enhancement in: web labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.0.3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants