Skip to content

Commit b4dbf2d

Browse files
committed
Use cached requestedSession info if available
Prevent fetching the session multiple times when checking whether the sessionId has to be sent to the client, by comparing values before clearing the requestedSessionCache. Resolves: #1424
1 parent 938fd3c commit b4dbf2d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-session-core/src/main/java/org/springframework/session/web/http/SessionRepositoryFilter.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,11 @@ private void commitSession() {
221221
}
222222
else {
223223
S session = wrappedSession.getSession();
224+
String sessionId = session.getId();
225+
final boolean isRequestedSession = isRequestedSessionIdValid() && sessionId.equals(getRequestedSessionId());
224226
clearRequestedSessionCache();
225227
SessionRepositoryFilter.this.sessionRepository.save(session);
226-
String sessionId = session.getId();
227-
if (!isRequestedSessionIdValid() || !sessionId.equals(getRequestedSessionId())) {
228+
if (!isRequestedSession) {
228229
SessionRepositoryFilter.this.httpSessionIdResolver.setSessionId(this, this.response, sessionId);
229230
}
230231
}

0 commit comments

Comments
 (0)