From 4d3d56abfe3c9ed15744b7d78082f17bf7abb45d Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 10 Mar 2021 13:56:23 +0000 Subject: [PATCH] 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 --- .../session/SampleSessionWebFluxApplicationTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-webflux/src/test/java/smoketest/session/SampleSessionWebFluxApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-webflux/src/test/java/smoketest/session/SampleSessionWebFluxApplicationTests.java index abdcc6d06be..280a76a2a33 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-webflux/src/test/java/smoketest/session/SampleSessionWebFluxApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-webflux/src/test/java/smoketest/session/SampleSessionWebFluxApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 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. @@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Vedran Pavic */ -@SpringBootTest(properties = "server.servlet.session.timeout:2", +@SpringBootTest(properties = "server.servlet.session.timeout:5", webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class SampleSessionWebFluxApplicationTests { @@ -57,7 +57,7 @@ class SampleSessionWebFluxApplicationTests { response = webClient.get().cookie("SESSION", sessionCookie.getValue()).exchange().block(Duration.ofSeconds(30)); assertThat(response.statusCode()).isEqualTo(HttpStatus.OK); assertThat(response.bodyToMono(String.class).block(Duration.ofSeconds(30))).isEqualTo(sessionId); - Thread.sleep(2000); + Thread.sleep(5000); response = webClient.get().cookie("SESSION", sessionCookie.getValue()).exchange().block(Duration.ofSeconds(30)); assertThat(response.statusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); }