Polish contribution
See gh-35013
This commit is contained in:
@@ -283,7 +283,7 @@ public class InMemoryWebSessionStore implements WebSessionStore {
|
|||||||
private void checkMaxSessionsLimit() {
|
private void checkMaxSessionsLimit() {
|
||||||
if (sessions.size() >= maxSessions) {
|
if (sessions.size() >= maxSessions) {
|
||||||
expiredSessionChecker.removeExpiredSessions(clock.instant());
|
expiredSessionChecker.removeExpiredSessions(clock.instant());
|
||||||
if (sessions.size() >= maxSessions && !sessions.containsKey(this.getId())) {
|
if (sessions.size() >= maxSessions && !sessions.containsKey(this.id.get())) {
|
||||||
throw new IllegalStateException("Max sessions limit reached: " + sessions.size());
|
throw new IllegalStateException("Max sessions limit reached: " + sessions.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,21 +160,40 @@ class InMemoryWebSessionStoreTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void updateSession() {
|
void updateSession() {
|
||||||
WebSession oneWebSession = insertSession();
|
WebSession session = insertSession();
|
||||||
|
|
||||||
StepVerifier.create(oneWebSession.save())
|
StepVerifier.create(session.save())
|
||||||
.expectComplete()
|
.expectComplete()
|
||||||
.verify();
|
.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test // gh-35013
|
||||||
void updateSession_whenMaxSessionsReached() {
|
void updateSessionAfterMaxSessionLimitIsExceeded() {
|
||||||
WebSession onceWebSession = insertSession();
|
this.store.setMaxSessions(10);
|
||||||
IntStream.range(1, 10000).forEach(i -> insertSession());
|
|
||||||
|
|
||||||
StepVerifier.create(onceWebSession.save())
|
WebSession session = insertSession();
|
||||||
|
assertNumSessions(1);
|
||||||
|
|
||||||
|
IntStream.rangeClosed(1, 9).forEach(i -> insertSession());
|
||||||
|
assertNumSessions(10);
|
||||||
|
|
||||||
|
// Updating an existing session should succeed.
|
||||||
|
StepVerifier.create(session.save())
|
||||||
.expectComplete()
|
.expectComplete()
|
||||||
.verify();
|
.verify();
|
||||||
|
assertNumSessions(10);
|
||||||
|
|
||||||
|
// Saving an additional new session should fail.
|
||||||
|
assertThatIllegalStateException()
|
||||||
|
.isThrownBy(this::insertSession)
|
||||||
|
.withMessage("Max sessions limit reached: 10");
|
||||||
|
assertNumSessions(10);
|
||||||
|
|
||||||
|
// Updating an existing session again should still succeed.
|
||||||
|
StepVerifier.create(session.save())
|
||||||
|
.expectComplete()
|
||||||
|
.verify();
|
||||||
|
assertNumSessions(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user