File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
integration-test/java/org/springframework/session/jdbc
main/java/org/springframework/session/jdbc Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -586,6 +586,18 @@ void cleanupInactiveSessionsUsingSessionDefinedInterval() {
586
586
assertThat (this .repository .findById (session .getId ())).isNull ();
587
587
}
588
588
589
+ @ Test
590
+ void cleanupExpiredSessionsWhenMaxInactiveIntervalNegativeThenSessionNotDeleted () {
591
+ JdbcSession session = this .repository .createSession ();
592
+ session .setMaxInactiveInterval (Duration .ofSeconds (-1 ));
593
+ session .setLastAccessedTime (Instant .now ().minusSeconds (MapSession .DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS + 1 ));
594
+
595
+ this .repository .save (session );
596
+ this .repository .cleanUpExpiredSessions ();
597
+
598
+ assertThat (this .repository .findById (session .getId ())).isNotNull ();
599
+ }
600
+
589
601
@ Test
590
602
void changeSessionIdWhenOnlyChangeId () {
591
603
String attrName = "changeSessionId" ;
Original file line number Diff line number Diff line change @@ -185,7 +185,8 @@ public class JdbcIndexedSessionRepository
185
185
// @formatter:off
186
186
private static final String DELETE_SESSION_QUERY = ""
187
187
+ "DELETE FROM %TABLE_NAME% "
188
- + "WHERE SESSION_ID = ?" ;
188
+ + "WHERE SESSION_ID = ? "
189
+ + "AND MAX_INACTIVE_INTERVAL >= 0" ;
189
190
// @formatter:on
190
191
191
192
// @formatter:off
@@ -701,6 +702,9 @@ void clearChangeFlags() {
701
702
}
702
703
703
704
Instant getExpiryTime () {
705
+ if (getMaxInactiveInterval ().isNegative ()) {
706
+ return Instant .ofEpochMilli (Long .MAX_VALUE );
707
+ }
704
708
return getLastAccessedTime ().plus (getMaxInactiveInterval ());
705
709
}
706
710
You can’t perform that action at this time.
0 commit comments