From 68aec8b6ee5e3c51c12f7a17fe4b0cef1709f908 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 30 May 2019 09:52:05 -0700 Subject: [PATCH] Polish --- .../ConditionalOnEnabledEndpoint.java | 3 ++- .../SpringApplicationHierarchyTests.java | 7 ++----- .../ConditionalOnEnabledEndpointTests.java | 1 + .../boot/actuate/metrics/Autotime.java | 16 ++++++++-------- .../RSocketStrategiesAutoConfiguration.java | 17 +++++++++-------- .../web/ResourcePropertiesTests.java | 2 +- .../JettyWebServerFactoryCustomizerTests.java | 2 -- .../ClientHttpConnectorConfigurationTests.java | 14 ++++++++++---- .../BasicErrorControllerMockMvcTests.java | 3 ++- ...bSocketMessagingAutoConfigurationTests.java | 6 ++++-- .../main/asciidoc/spring-boot-features.adoc | 18 ++++++++++++++++-- .../restassured/UserDocumentationTests.java | 2 +- ...nAdvancedConfigurationIntegrationTests.java | 2 +- ...tDocsAutoConfigurationIntegrationTests.java | 2 +- .../OutputCaptureExtendWithTests.java | 2 +- .../OutputCaptureRegisterExtensionTests.java | 3 ++- .../testcontainers/SkippableContainer.java | 2 +- ...ModifiedClassPathRunnerExclusionsTests.java | 2 +- .../embedded/jetty/SslServerCustomizer.java | 2 +- .../web/embedded/netty/NettyWebServer.java | 15 +++++++++++---- .../AbstractServletWebServerFactoryTests.java | 2 +- 21 files changed, 76 insertions(+), 47 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpoint.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpoint.java index 21488df2ae..8dc4bdb561 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpoint.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpoint.java @@ -90,7 +90,8 @@ import org.springframework.core.env.Environment; * @author Stephane Nicoll * @since 2.0.0 * @see Endpoint - * @deprecated as of 2.2.0 in favor of {@link ConditionalOnAvailableEndpoint} + * @deprecated as of 2.2.0 in favor of + * {@link ConditionalOnAvailableEndpoint @ConditionalOnAvailableEndpoint} */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.METHOD, ElementType.TYPE }) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java index 0ae81109e2..3a393b49ab 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java @@ -31,7 +31,6 @@ import org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfigurat import org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration; -import org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration; import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.test.util.ApplicationContextTestUtils; @@ -73,8 +72,7 @@ public class SpringApplicationHierarchyTests { MongoDataAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class, Neo4jDataAutoConfiguration.class, Neo4jRepositoriesAutoConfiguration.class, RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class, - FlywayAutoConfiguration.class, JestAutoConfiguration.class, - MetricsAutoConfiguration.class }, + FlywayAutoConfiguration.class, MetricsAutoConfiguration.class }, excludeName = { "org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration" }) public static class Child { @@ -87,8 +85,7 @@ public class SpringApplicationHierarchyTests { MongoDataAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class, Neo4jDataAutoConfiguration.class, Neo4jRepositoriesAutoConfiguration.class, RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class, - FlywayAutoConfiguration.class, JestAutoConfiguration.class, - MetricsAutoConfiguration.class }, + FlywayAutoConfiguration.class, MetricsAutoConfiguration.class }, excludeName = { "org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration" }) public static class Parent { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java index 262982394b..76296f2e2c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnEnabledEndpointTests.java @@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Andy Wilkinson */ @Deprecated +@SuppressWarnings("deprecation") public class ConditionalOnEnabledEndpointTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner(); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Autotime.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Autotime.java index e02950a2ed..6c73fe3acd 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Autotime.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Autotime.java @@ -54,14 +54,6 @@ public final class Autotime { ? percentiles.stream().mapToDouble(Double::doubleValue).toArray() : null; } - /** - * Create an instance that disable auto-timed requests. - * @return an instance that disable auto-timed requests - */ - public static Autotime disabled() { - return new Autotime(false, false, null); - } - public boolean isEnabled() { return this.enabled; } @@ -86,4 +78,12 @@ public final class Autotime { this.percentiles = percentiles; } + /** + * Create an instance that disable auto-timed requests. + * @return an instance that disable auto-timed requests + */ + public static Autotime disabled() { + return new Autotime(false, false, null); + } + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java index c2a0033f91..0d5d91f1de 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java @@ -75,6 +75,8 @@ public class RSocketStrategiesAutoConfiguration { @ConditionalOnClass({ ObjectMapper.class, CBORFactory.class }) protected static class JacksonCborStrategyConfiguration { + private static final MediaType[] SUPPORTED_TYPES = { MediaType.APPLICATION_CBOR }; + @Bean @Order(0) @ConditionalOnBean(Jackson2ObjectMapperBuilder.class) @@ -82,10 +84,8 @@ public class RSocketStrategiesAutoConfiguration { Jackson2ObjectMapperBuilder builder) { return (strategy) -> { ObjectMapper objectMapper = builder.factory(new CBORFactory()).build(); - MediaType[] supportedTypes = new MediaType[] { - MediaType.APPLICATION_CBOR }; - strategy.decoder(new Jackson2CborDecoder(objectMapper, supportedTypes)); - strategy.encoder(new Jackson2CborEncoder(objectMapper, supportedTypes)); + strategy.decoder(new Jackson2CborDecoder(objectMapper, SUPPORTED_TYPES)); + strategy.encoder(new Jackson2CborEncoder(objectMapper, SUPPORTED_TYPES)); }; } @@ -95,16 +95,17 @@ public class RSocketStrategiesAutoConfiguration { @ConditionalOnClass(ObjectMapper.class) protected static class JacksonJsonStrategyConfiguration { + private static final MediaType[] SUPPORTED_TYPES = { MediaType.APPLICATION_JSON, + new MediaType("application", "*+json") }; + @Bean @Order(1) @ConditionalOnBean(ObjectMapper.class) public RSocketStrategiesCustomizer jacksonJsonStrategyCustomizer( ObjectMapper objectMapper) { return (strategy) -> { - MediaType[] supportedTypes = new MediaType[] { MediaType.APPLICATION_JSON, - new MediaType("application", "*+json") }; - strategy.decoder(new Jackson2JsonDecoder(objectMapper, supportedTypes)); - strategy.encoder(new Jackson2JsonEncoder(objectMapper, supportedTypes)); + strategy.decoder(new Jackson2JsonDecoder(objectMapper, SUPPORTED_TYPES)); + strategy.encoder(new Jackson2JsonEncoder(objectMapper, SUPPORTED_TYPES)); }; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java index e334aa0de4..390f98310f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ResourcePropertiesTests.java @@ -25,7 +25,7 @@ import org.springframework.boot.testsupport.assertj.Matched; import org.springframework.http.CacheControl; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.endsWith; +import static org.hamcrest.Matchers.endsWith; /** * Tests for {@link ResourceProperties}. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java index efb6b82a22..a59f47af57 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java @@ -20,7 +20,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.TimeZone; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.CustomRequestLog; @@ -88,7 +87,6 @@ public class JettyWebServerFactoryCustomizerTests { @Test public void accessLogCanBeCustomized() throws IOException { File logFile = File.createTempFile("jetty_log", ".log"); - String timezone = TimeZone.getDefault().getID(); bind("server.jetty.accesslog.enabled=true", "server.jetty.accesslog.format=extended_ncsa", "server.jetty.accesslog.filename=" diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorConfigurationTests.java index a5cd87f844..2a3a20d6a9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorConfigurationTests.java @@ -46,8 +46,7 @@ public class ClientHttpConnectorConfigurationTests { jettyResourceFactory.setExecutor(executor); jettyResourceFactory.setByteBufferPool(byteBufferPool); jettyResourceFactory.setScheduler(scheduler); - JettyClientHttpConnector connector = new ClientHttpConnectorConfiguration.JettyClient() - .jettyClientHttpConnector(jettyResourceFactory); + JettyClientHttpConnector connector = getClientHttpConnector(jettyResourceFactory); HttpClient httpClient = (HttpClient) ReflectionTestUtils.getField(connector, "httpClient"); assertThat(httpClient.getExecutor()).isSameAs(executor); @@ -59,11 +58,18 @@ public class ClientHttpConnectorConfigurationTests { public void JettyResourceFactoryHasSslContextFactory() { // gh-16810 JettyResourceFactory jettyResourceFactory = new JettyResourceFactory(); - JettyClientHttpConnector connector = new ClientHttpConnectorConfiguration.JettyClient() - .jettyClientHttpConnector(jettyResourceFactory); + JettyClientHttpConnector connector = getClientHttpConnector(jettyResourceFactory); HttpClient httpClient = (HttpClient) ReflectionTestUtils.getField(connector, "httpClient"); assertThat(httpClient.getSslContextFactory()).isNotNull(); } + private JettyClientHttpConnector getClientHttpConnector( + JettyResourceFactory jettyResourceFactory) { + ClientHttpConnectorConfiguration.JettyClient jettyClient = new ClientHttpConnectorConfiguration.JettyClient(); + // We shouldn't usually call this method directly since it's on a non-proxy config + return ReflectionTestUtils.invokeMethod(jettyClient, "jettyClientHttpConnector", + jettyResourceFactory); + } + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerMockMvcTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerMockMvcTests.java index fc3ca235cd..80cd7594a1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerMockMvcTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerMockMvcTests.java @@ -63,7 +63,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; /** - * Tests for {@link BasicErrorController} using {@link MockMvc} and {@link SpringRunner}. + * Tests for {@link BasicErrorController} using {@link MockMvc} and + * {@link SpringBootTest @SpringBootTest}. * * @author Dave Syer */ diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java index cb96d40bcf..bf8932d5b6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfigurationTests.java @@ -133,8 +133,10 @@ public class WebSocketMessagingAutoConfigurationTests { @SuppressWarnings("unchecked") private List getDefaultConverters() { - CompositeMessageConverter compositeDefaultConverter = new DelegatingWebSocketMessageBrokerConfiguration() - .brokerMessageConverter(); + DelegatingWebSocketMessageBrokerConfiguration configuration = new DelegatingWebSocketMessageBrokerConfiguration(); + // We shouldn't usually call this method directly since it's on a non-proxy config + CompositeMessageConverter compositeDefaultConverter = ReflectionTestUtils + .invokeMethod(configuration, "brokerMessageConverter"); return (List) ReflectionTestUtils .getField(compositeDefaultConverter, "converters"); } diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 728d4a4caa..ff8808ef40 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -3379,6 +3379,8 @@ NOTE: `TomcatServletWebServerFactory`, `JettyServletWebServerFactory` and `Under are dedicated variants of `ConfigurableServletWebServerFactory` that have additional customization setter methods for Tomcat, Jetty and Undertow respectively. + + [[boot-features-customizing-configurableservletwebserverfactory-directly]] ===== Customizing ConfigurableServletWebServerFactory Directly If the preceding customization techniques are too limited, you can register the @@ -3403,6 +3405,7 @@ are also provided should you need to do something more exotic. See the code documentation] for details. + [[boot-features-jsp-limitations]] ==== JSP Limitations When running a Spring Boot application that uses an embedded servlet container (and is @@ -3422,17 +3425,19 @@ instead. There is a {github-code}/spring-boot-samples/spring-boot-sample-web-jsp[JSP sample] so that you can see how to set things up. + + [[boot-features-reactive-server]] === Embedded Reactive Server Support - Spring Boot includes support for the following embedded reactive web servers: Reactor Netty, Tomcat, Jetty, and Undertow. Most developers use the appropriate “Starter” to obtain a fully configured instance. By default, the embedded server listens for HTTP requests on port 8080. + + [[boot-features-reactive-server-resources]] === Reactive Server Resources Configuration - When auto-configuring a Reactor Netty or Jetty server, Spring Boot will create specific beans that will provide HTTP resources to the server instance: `ReactorResourceFactory` or `JettyResourceFactory`. @@ -3451,6 +3456,8 @@ both clients and servers. You can learn more about the resource configuration on the client side in the <>. + + [[boot-features-rsocket]] == RSocket @@ -3483,6 +3490,8 @@ The following code shows a typical `@Controller`: } ---- + + [[boot-features-rsocket-strategies-auto-configuration]] === RSocket Strategies Auto-configuration Spring Boot auto-configures an `RSocketStrategies` bean that provides all the required @@ -3499,6 +3508,7 @@ implement the `RSocketStrategiesCustomizer` interface. Note that their `@Order` important, as it determines the order of codecs. + [[boot-features-rsocket-server-auto-configuration]] === RSocket server Auto-configuration Spring Boot provides auto-configuration for RSocket servers. The required dependencies @@ -3544,6 +3554,8 @@ about customization possibilities. Developers can create `RSocketStrategiesCustomizer` beans to add other strategies, assuming there are `Encoder` and `Decoder` implementations available. + + [[boot-features-rsocket-requester]] === Calling RSocket Services with `RSocketRequester` @@ -3582,6 +3594,7 @@ The following code shows a typical example: ---- + [[boot-features-security]] == Security If {spring-security}[Spring Security] is on the classpath, then web applications are @@ -3620,6 +3633,7 @@ the entire application (including actuator endpoints if actuator is on the class You can provide a different `AuthenticationEventPublisher` by adding a bean for it. + [[boot-features-security-mvc]] === MVC Security The default security configuration is implemented in `SecurityAutoConfiguration` and diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java index f2b83f3429..d809b79062 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java @@ -29,7 +29,7 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.junit4.SpringRunner; import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document; @RunWith(SpringRunner.class) diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java index 191a773f96..3a1d2c14a4 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationAdvancedConfigurationIntegrationTests.java @@ -39,7 +39,7 @@ import org.springframework.util.FileSystemUtils; import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.contentOf; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyUris; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationIntegrationTests.java index 00cf7d3af2..2c1b57083e 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/restdocs/RestAssuredRestDocsAutoConfigurationIntegrationTests.java @@ -34,7 +34,7 @@ import org.springframework.util.FileSystemUtils; import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.contentOf; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyUris; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document; diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/extension/OutputCaptureExtendWithTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/extension/OutputCaptureExtendWithTests.java index 13c0a74511..ab8eac6b2c 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/extension/OutputCaptureExtendWithTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/extension/OutputCaptureExtendWithTests.java @@ -23,7 +23,7 @@ import org.junit.jupiter.api.extension.ExtensionContext; import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link OutputCapture} when used via {@link ExtendWith}. + * Tests for {@link OutputCapture} when used via {@link ExtendWith @ExtendWith}. * * @author Madhura Bhave */ diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/extension/OutputCaptureRegisterExtensionTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/extension/OutputCaptureRegisterExtensionTests.java index b898f0f3b6..c16e761ed6 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/extension/OutputCaptureRegisterExtensionTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/extension/OutputCaptureRegisterExtensionTests.java @@ -21,7 +21,8 @@ import org.junit.jupiter.api.extension.RegisterExtension; import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link OutputCapture} when used via {@link RegisterExtension}. + * Tests for {@link OutputCapture} when used via + * {@link RegisterExtension @RegisterExtension}. * * @author Madhura Bhave */ diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/SkippableContainer.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/SkippableContainer.java index 723fa23e93..a7f9b9ffb3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/SkippableContainer.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/testcontainers/SkippableContainer.java @@ -31,7 +31,7 @@ import org.testcontainers.lifecycle.Startable; * @author Andy Wilkinson * @author Madhura Bhave */ -public class SkippableContainer implements Startable { +public class SkippableContainer> implements Startable { private final Supplier containerFactory; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/runner/classpath/ModifiedClassPathRunnerExclusionsTests.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/runner/classpath/ModifiedClassPathRunnerExclusionsTests.java index 80573fdb40..9f2fe9fee4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/runner/classpath/ModifiedClassPathRunnerExclusionsTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/test/java/org/springframework/boot/testsupport/runner/classpath/ModifiedClassPathRunnerExclusionsTests.java @@ -21,7 +21,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.isA; +import static org.hamcrest.Matchers.isA; /** * Tests for {@link ModifiedClassPathRunner} excluding entries from the class path. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizer.java index c1151f6010..41ffd8d416 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizer.java @@ -134,7 +134,7 @@ class SslServerCustomizer implements JettyServerCustomizer { /** * Configure the SSL connection. - * @param factory the Jetty {@link SslContextFactory.Server}. + * @param factory the Jetty {@link Server SslContextFactory.Server}. * @param ssl the ssl details. * @param sslStoreProvider the ssl store provider */ diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java index 6d9d7e8e70..b3389579c5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java @@ -19,12 +19,15 @@ package org.springframework.boot.web.embedded.netty; import java.time.Duration; import java.util.Collections; import java.util.List; +import java.util.function.Predicate; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import reactor.netty.ChannelBindException; import reactor.netty.DisposableServer; import reactor.netty.http.server.HttpServer; +import reactor.netty.http.server.HttpServerRequest; +import reactor.netty.http.server.HttpServerRoutes; import org.springframework.boot.web.server.PortInUseException; import org.springframework.boot.web.server.WebServer; @@ -44,6 +47,8 @@ import org.springframework.util.Assert; */ public class NettyWebServer implements WebServer { + private static final Predicate ALWAYS = (r) -> true; + private static final Log logger = LogFactory.getLog(NettyWebServer.class); private final HttpServer httpServer; @@ -93,10 +98,7 @@ public class NettyWebServer implements WebServer { server = server.handle(this.handlerAdapter); } else { - server = server.route((routes) -> { - this.routeProviders.forEach((provider) -> provider.apply(routes)); - routes.route((r) -> true, this.handlerAdapter); - }); + server = server.route(this::applyRouteProviders); } if (this.lifecycleTimeout != null) { return server.bindNow(this.lifecycleTimeout); @@ -104,6 +106,11 @@ public class NettyWebServer implements WebServer { return server.bindNow(); } + private void applyRouteProviders(HttpServerRoutes routes) { + this.routeProviders.forEach((provider) -> provider.apply(routes)); + routes.route(ALWAYS, this.handlerAdapter); + } + private ChannelBindException findBindException(Exception ex) { Throwable candidate = ex; while (candidate != null) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java index 2e61be63e6..2356419472 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java @@ -122,7 +122,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIOException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given;