Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions