Skip to content

Commit

Permalink
Polish SessionRepositoryFilter
Browse files Browse the repository at this point in the history
This commit polishes SessionRepositoryFilter by simplifying some code paths.
  • Loading branch information
vpavic authored and rwinch committed Oct 18, 2022
1 parent 1f38a93 commit 82db55c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -267,14 +267,7 @@ public boolean isRequestedSessionIdValid() {
if (requestedSession != null) {
requestedSession.setLastAccessedTime(Instant.now());
}
return isRequestedSessionIdValid(requestedSession);
}
return this.requestedSessionIdValid;
}

private boolean isRequestedSessionIdValid(S session) {
if (this.requestedSessionIdValid == null) {
this.requestedSessionIdValid = session != null;
this.requestedSessionIdValid = (requestedSession != null);
}
return this.requestedSessionIdValid;
}
Expand Down Expand Up @@ -358,7 +351,6 @@ private S getRequestedSession() {
S session = SessionRepositoryFilter.this.sessionRepository.findById(sessionId);
if (session != null) {
this.requestedSession = session;
this.requestedSessionId = sessionId;
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrap
}
});

// 2 invocations expected: initial resolution, after invalidation, after commit
// 2 invocations expected: initial resolution, after invalidation
verify(sessionRepository, times(2)).findById(eq(session.getId()));
verify(sessionRepository).deleteById(eq(session.getId()));
verify(sessionRepository).createSession();
Expand Down

0 comments on commit 82db55c

Please sign in to comment.