Skip to content

Commit 4d3d56a

Browse files
committed
Try to stabilize SampleSessionWebFluxApplicationTests
userDefinedMappingsSecureByDefault in SampleSessionWebFluxApplicationTests may fail with an NPE if the session times out before the initial response is sent due to the absence of a SESSION cookie in the response. The test uses a short session timeout (2 seconds) and we've seen the problem occur on CI when, presumably, a noisy neighbour has caused some CPU starvation. This commit increases the timeout to 5 seconds to reduce the chance of a short period of CPU starvation causing the test to fail. Closes gh-25572
1 parent f38e863 commit 4d3d56a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-webflux/src/test/java/smoketest/session/SampleSessionWebFluxApplicationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
3636
*
3737
* @author Vedran Pavic
3838
*/
39-
@SpringBootTest(properties = "server.servlet.session.timeout:2",
39+
@SpringBootTest(properties = "server.servlet.session.timeout:5",
4040
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
4141
class SampleSessionWebFluxApplicationTests {
4242

@@ -57,7 +57,7 @@ void userDefinedMappingsSecureByDefault() throws Exception {
5757
response = webClient.get().cookie("SESSION", sessionCookie.getValue()).exchange().block(Duration.ofSeconds(30));
5858
assertThat(response.statusCode()).isEqualTo(HttpStatus.OK);
5959
assertThat(response.bodyToMono(String.class).block(Duration.ofSeconds(30))).isEqualTo(sessionId);
60-
Thread.sleep(2000);
60+
Thread.sleep(5000);
6161
response = webClient.get().cookie("SESSION", sessionCookie.getValue()).exchange().block(Duration.ofSeconds(30));
6262
assertThat(response.statusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
6363
}

0 commit comments

Comments
 (0)