Skip to content

SessionRepositoryFilter.SessionRepositoryRequestWrapper.commitSession() triggers extraneous call to SessionRespository.findById(...) #1731

Open
@pferraro

Description

@pferraro

Describe the bug
For a valid session, SessionRepositoryFilter.SessionRepositoryRequestWrapper.commitSession() does the following:

  1. Clears cached values for references for requestedSessionCache, requestedSession, and requestedSessionId.
  2. Saves the state of the session
  3. If the requested session ID is not valid, or if the ID of the session changed from the requested session ID, then the session ID is sent to the client

However, since #1 already cleared the requested session cached values #3 requires a completely redundant call to SessionRepository.findById(...). Depending on the implementation, this can be unnecessarily expensive.

To Reproduce
Use a tracer to detect calls to SessionRepository.findById(...). For a requested session, this is triggered twice, once at the beginning of the request, and again after the session is saved.

Expected behavior
SessionRepository.findById(...) should be considered a potentially expensive operation, and only triggered when necessary. Clearing cached values after determining whether to send the session ID to the client (i.e. in a finally block) would solve the problem.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions