Skip to content

Commit d2960b5

Browse files
committed
Polish gh-1798
- Should throw IllegalStateException
1 parent 8bd4374 commit d2960b5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public HttpSessionWrapper getSession(boolean create) {
312312
}
313313
if (SessionRepositoryFilter.this.httpSessionIdResolver instanceof CookieHttpSessionIdResolver
314314
&& this.response.isCommitted()) {
315-
throw new IllegalArgumentException("Cannot create a session after the response has been committed");
315+
throw new IllegalStateException("Cannot create a session after the response has been committed");
316316
}
317317
if (SESSION_LOGGER.isDebugEnabled()) {
318318
SESSION_LOGGER.debug(

spring-session-core/src/test/java/org/springframework/session/web/http/SessionRepositoryFilterTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import static org.assertj.core.api.Assertions.assertThat;
6363
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
6464
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
65+
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
6566
import static org.assertj.core.api.Assertions.fail;
6667
import static org.mockito.ArgumentMatchers.any;
6768
import static org.mockito.ArgumentMatchers.anyString;
@@ -425,7 +426,7 @@ public void doFilter(HttpServletRequest wrappedRequest) {
425426

426427
@Test
427428
void doFilterGetSessionNewWhenResponseCommittedThenException() {
428-
assertThatIllegalArgumentException().isThrownBy(() -> doFilter(new DoInFilter() {
429+
assertThatIllegalStateException().isThrownBy(() -> doFilter(new DoInFilter() {
429430
@Override
430431
public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse)
431432
throws IOException {

0 commit comments

Comments
 (0)