From 853ab5d67b3336ae73ad962da7a60b19cc455667 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 17 Sep 2021 12:52:41 +0100 Subject: [PATCH] Fix Jetty 10+ test failure related to empty path handling See gh-27424 --- .../server/reactive/ErrorHandlerIntegrationTests.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java index 79d0158eae9..f91779cba1b 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java @@ -27,6 +27,7 @@ import org.springframework.web.client.ResponseErrorHandler; import org.springframework.web.client.RestTemplate; import org.springframework.web.testfixture.http.server.reactive.bootstrap.AbstractHttpHandlerIntegrationTests; import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; +import org.springframework.web.testfixture.http.server.reactive.bootstrap.JettyHttpServer; import static org.assertj.core.api.Assertions.assertThat; @@ -80,7 +81,14 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { URI url = new URI("http://localhost:" + port + "//"); ResponseEntity response = restTemplate.getForEntity(url, String.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + // Jetty 10+ rejects empty path segments, see https://github.com/eclipse/jetty.project/issues/6302, + // but an application can apply CompactPathRule via RewriteHandler: + // https://www.eclipse.org/jetty/documentation/jetty-11/programming_guide.php + + HttpStatus expectedStatus = + (httpServer instanceof JettyHttpServer ? HttpStatus.BAD_REQUEST : HttpStatus.OK); + + assertThat(response.getStatusCode()).isEqualTo(expectedStatus); }