From 7bc336cdc6d8bf4f8fbb57cfe73f5fb8684a4fbe Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 28 Feb 2022 10:54:31 +0000 Subject: [PATCH] Use an ephemeral port to avoid potential port clash Closes gh-30007 --- .../ServletWebServerFactoryAutoConfigurationTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java index c30bc1c0cf..5b7f972b43 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java @@ -375,7 +375,7 @@ class ServletWebServerFactoryAutoConfigurationTests { AnnotationConfigServletWebServerApplicationContext::new) .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)) .withPropertyValues("server.forward-headers-strategy=framework", - "server.tomcat.use-relative-redirects=true"); + "server.tomcat.use-relative-redirects=true", "server.port=0"); runner.run((context) -> { Filter filter = context.getBean(FilterRegistrationBean.class).getFilter(); assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class); @@ -389,7 +389,7 @@ class ServletWebServerFactoryAutoConfigurationTests { AnnotationConfigServletWebServerApplicationContext::new) .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)) .withPropertyValues("server.forward-headers-strategy=framework", - "server.tomcat.use-relative-redirects=false"); + "server.tomcat.use-relative-redirects=false", "server.port=0"); runner.run((context) -> { Filter filter = context.getBean(FilterRegistrationBean.class).getFilter(); assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class); @@ -403,7 +403,7 @@ class ServletWebServerFactoryAutoConfigurationTests { AnnotationConfigServletWebServerApplicationContext::new) .withClassLoader(new FilteredClassLoader(Tomcat.class)) .withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)) - .withPropertyValues("server.forward-headers-strategy=framework"); + .withPropertyValues("server.forward-headers-strategy=framework", "server.port=0"); runner.run((context) -> { Filter filter = context.getBean(FilterRegistrationBean.class).getFilter(); assertThat(filter).isInstanceOf(ForwardedHeaderFilter.class);