Commit 68aec8b6 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 23a923d1
...@@ -90,7 +90,8 @@ import org.springframework.core.env.Environment; ...@@ -90,7 +90,8 @@ import org.springframework.core.env.Environment;
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 2.0.0 * @since 2.0.0
* @see Endpoint * @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) @Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.TYPE }) @Target({ ElementType.METHOD, ElementType.TYPE })
......
...@@ -31,7 +31,6 @@ import org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfigurat ...@@ -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.neo4j.Neo4jRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration; 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.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.util.ApplicationContextTestUtils; import org.springframework.boot.test.util.ApplicationContextTestUtils;
...@@ -73,8 +72,7 @@ public class SpringApplicationHierarchyTests { ...@@ -73,8 +72,7 @@ public class SpringApplicationHierarchyTests {
MongoDataAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class, MongoDataAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class,
Neo4jDataAutoConfiguration.class, Neo4jRepositoriesAutoConfiguration.class, Neo4jDataAutoConfiguration.class, Neo4jRepositoriesAutoConfiguration.class,
RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class, RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class,
FlywayAutoConfiguration.class, JestAutoConfiguration.class, FlywayAutoConfiguration.class, MetricsAutoConfiguration.class },
MetricsAutoConfiguration.class },
excludeName = { excludeName = {
"org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration" }) "org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration" })
public static class Child { public static class Child {
...@@ -87,8 +85,7 @@ public class SpringApplicationHierarchyTests { ...@@ -87,8 +85,7 @@ public class SpringApplicationHierarchyTests {
MongoDataAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class, MongoDataAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class,
Neo4jDataAutoConfiguration.class, Neo4jRepositoriesAutoConfiguration.class, Neo4jDataAutoConfiguration.class, Neo4jRepositoriesAutoConfiguration.class,
RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class, RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class,
FlywayAutoConfiguration.class, JestAutoConfiguration.class, FlywayAutoConfiguration.class, MetricsAutoConfiguration.class },
MetricsAutoConfiguration.class },
excludeName = { excludeName = {
"org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration" }) "org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration" })
public static class Parent { public static class Parent {
......
...@@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
@Deprecated @Deprecated
@SuppressWarnings("deprecation")
public class ConditionalOnEnabledEndpointTests { public class ConditionalOnEnabledEndpointTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner(); private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
......
...@@ -54,14 +54,6 @@ public final class Autotime { ...@@ -54,14 +54,6 @@ public final class Autotime {
? percentiles.stream().mapToDouble(Double::doubleValue).toArray() : null; ? 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() { public boolean isEnabled() {
return this.enabled; return this.enabled;
} }
...@@ -86,4 +78,12 @@ public final class Autotime { ...@@ -86,4 +78,12 @@ public final class Autotime {
this.percentiles = percentiles; 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);
}
} }
...@@ -75,6 +75,8 @@ public class RSocketStrategiesAutoConfiguration { ...@@ -75,6 +75,8 @@ public class RSocketStrategiesAutoConfiguration {
@ConditionalOnClass({ ObjectMapper.class, CBORFactory.class }) @ConditionalOnClass({ ObjectMapper.class, CBORFactory.class })
protected static class JacksonCborStrategyConfiguration { protected static class JacksonCborStrategyConfiguration {
private static final MediaType[] SUPPORTED_TYPES = { MediaType.APPLICATION_CBOR };
@Bean @Bean
@Order(0) @Order(0)
@ConditionalOnBean(Jackson2ObjectMapperBuilder.class) @ConditionalOnBean(Jackson2ObjectMapperBuilder.class)
...@@ -82,10 +84,8 @@ public class RSocketStrategiesAutoConfiguration { ...@@ -82,10 +84,8 @@ public class RSocketStrategiesAutoConfiguration {
Jackson2ObjectMapperBuilder builder) { Jackson2ObjectMapperBuilder builder) {
return (strategy) -> { return (strategy) -> {
ObjectMapper objectMapper = builder.factory(new CBORFactory()).build(); ObjectMapper objectMapper = builder.factory(new CBORFactory()).build();
MediaType[] supportedTypes = new MediaType[] { strategy.decoder(new Jackson2CborDecoder(objectMapper, SUPPORTED_TYPES));
MediaType.APPLICATION_CBOR }; strategy.encoder(new Jackson2CborEncoder(objectMapper, SUPPORTED_TYPES));
strategy.decoder(new Jackson2CborDecoder(objectMapper, supportedTypes));
strategy.encoder(new Jackson2CborEncoder(objectMapper, supportedTypes));
}; };
} }
...@@ -95,16 +95,17 @@ public class RSocketStrategiesAutoConfiguration { ...@@ -95,16 +95,17 @@ public class RSocketStrategiesAutoConfiguration {
@ConditionalOnClass(ObjectMapper.class) @ConditionalOnClass(ObjectMapper.class)
protected static class JacksonJsonStrategyConfiguration { protected static class JacksonJsonStrategyConfiguration {
private static final MediaType[] SUPPORTED_TYPES = { MediaType.APPLICATION_JSON,
new MediaType("application", "*+json") };
@Bean @Bean
@Order(1) @Order(1)
@ConditionalOnBean(ObjectMapper.class) @ConditionalOnBean(ObjectMapper.class)
public RSocketStrategiesCustomizer jacksonJsonStrategyCustomizer( public RSocketStrategiesCustomizer jacksonJsonStrategyCustomizer(
ObjectMapper objectMapper) { ObjectMapper objectMapper) {
return (strategy) -> { return (strategy) -> {
MediaType[] supportedTypes = new MediaType[] { MediaType.APPLICATION_JSON, strategy.decoder(new Jackson2JsonDecoder(objectMapper, SUPPORTED_TYPES));
new MediaType("application", "*+json") }; strategy.encoder(new Jackson2JsonEncoder(objectMapper, SUPPORTED_TYPES));
strategy.decoder(new Jackson2JsonDecoder(objectMapper, supportedTypes));
strategy.encoder(new Jackson2JsonEncoder(objectMapper, supportedTypes));
}; };
} }
......
...@@ -25,7 +25,7 @@ import org.springframework.boot.testsupport.assertj.Matched; ...@@ -25,7 +25,7 @@ import org.springframework.boot.testsupport.assertj.Matched;
import org.springframework.http.CacheControl; import org.springframework.http.CacheControl;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.Matchers.endsWith;
/** /**
* Tests for {@link ResourceProperties}. * Tests for {@link ResourceProperties}.
......
...@@ -20,7 +20,6 @@ import java.io.File; ...@@ -20,7 +20,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.TimeZone;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.CustomRequestLog; import org.eclipse.jetty.server.CustomRequestLog;
...@@ -88,7 +87,6 @@ public class JettyWebServerFactoryCustomizerTests { ...@@ -88,7 +87,6 @@ public class JettyWebServerFactoryCustomizerTests {
@Test @Test
public void accessLogCanBeCustomized() throws IOException { public void accessLogCanBeCustomized() throws IOException {
File logFile = File.createTempFile("jetty_log", ".log"); File logFile = File.createTempFile("jetty_log", ".log");
String timezone = TimeZone.getDefault().getID();
bind("server.jetty.accesslog.enabled=true", bind("server.jetty.accesslog.enabled=true",
"server.jetty.accesslog.format=extended_ncsa", "server.jetty.accesslog.format=extended_ncsa",
"server.jetty.accesslog.filename=" "server.jetty.accesslog.filename="
......
...@@ -46,8 +46,7 @@ public class ClientHttpConnectorConfigurationTests { ...@@ -46,8 +46,7 @@ public class ClientHttpConnectorConfigurationTests {
jettyResourceFactory.setExecutor(executor); jettyResourceFactory.setExecutor(executor);
jettyResourceFactory.setByteBufferPool(byteBufferPool); jettyResourceFactory.setByteBufferPool(byteBufferPool);
jettyResourceFactory.setScheduler(scheduler); jettyResourceFactory.setScheduler(scheduler);
JettyClientHttpConnector connector = new ClientHttpConnectorConfiguration.JettyClient() JettyClientHttpConnector connector = getClientHttpConnector(jettyResourceFactory);
.jettyClientHttpConnector(jettyResourceFactory);
HttpClient httpClient = (HttpClient) ReflectionTestUtils.getField(connector, HttpClient httpClient = (HttpClient) ReflectionTestUtils.getField(connector,
"httpClient"); "httpClient");
assertThat(httpClient.getExecutor()).isSameAs(executor); assertThat(httpClient.getExecutor()).isSameAs(executor);
...@@ -59,11 +58,18 @@ public class ClientHttpConnectorConfigurationTests { ...@@ -59,11 +58,18 @@ public class ClientHttpConnectorConfigurationTests {
public void JettyResourceFactoryHasSslContextFactory() { public void JettyResourceFactoryHasSslContextFactory() {
// gh-16810 // gh-16810
JettyResourceFactory jettyResourceFactory = new JettyResourceFactory(); JettyResourceFactory jettyResourceFactory = new JettyResourceFactory();
JettyClientHttpConnector connector = new ClientHttpConnectorConfiguration.JettyClient() JettyClientHttpConnector connector = getClientHttpConnector(jettyResourceFactory);
.jettyClientHttpConnector(jettyResourceFactory);
HttpClient httpClient = (HttpClient) ReflectionTestUtils.getField(connector, HttpClient httpClient = (HttpClient) ReflectionTestUtils.getField(connector,
"httpClient"); "httpClient");
assertThat(httpClient.getSslContextFactory()).isNotNull(); 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);
}
} }
...@@ -63,7 +63,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder ...@@ -63,7 +63,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 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 * @author Dave Syer
*/ */
......
...@@ -133,8 +133,10 @@ public class WebSocketMessagingAutoConfigurationTests { ...@@ -133,8 +133,10 @@ public class WebSocketMessagingAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private List<MessageConverter> getDefaultConverters() { private List<MessageConverter> getDefaultConverters() {
CompositeMessageConverter compositeDefaultConverter = new DelegatingWebSocketMessageBrokerConfiguration() DelegatingWebSocketMessageBrokerConfiguration configuration = new DelegatingWebSocketMessageBrokerConfiguration();
.brokerMessageConverter(); // We shouldn't usually call this method directly since it's on a non-proxy config
CompositeMessageConverter compositeDefaultConverter = ReflectionTestUtils
.invokeMethod(configuration, "brokerMessageConverter");
return (List<MessageConverter>) ReflectionTestUtils return (List<MessageConverter>) ReflectionTestUtils
.getField(compositeDefaultConverter, "converters"); .getField(compositeDefaultConverter, "converters");
} }
......
...@@ -3379,6 +3379,8 @@ NOTE: `TomcatServletWebServerFactory`, `JettyServletWebServerFactory` and `Under ...@@ -3379,6 +3379,8 @@ NOTE: `TomcatServletWebServerFactory`, `JettyServletWebServerFactory` and `Under
are dedicated variants of `ConfigurableServletWebServerFactory` that have additional customization setter methods are dedicated variants of `ConfigurableServletWebServerFactory` that have additional customization setter methods
for Tomcat, Jetty and Undertow respectively. for Tomcat, Jetty and Undertow respectively.
[[boot-features-customizing-configurableservletwebserverfactory-directly]] [[boot-features-customizing-configurableservletwebserverfactory-directly]]
===== Customizing ConfigurableServletWebServerFactory Directly ===== Customizing ConfigurableServletWebServerFactory Directly
If the preceding customization techniques are too limited, you can register the 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 ...@@ -3403,6 +3405,7 @@ are also provided should you need to do something more exotic. See the
code documentation] for details. code documentation] for details.
[[boot-features-jsp-limitations]] [[boot-features-jsp-limitations]]
==== JSP Limitations ==== JSP Limitations
When running a Spring Boot application that uses an embedded servlet container (and is When running a Spring Boot application that uses an embedded servlet container (and is
...@@ -3422,17 +3425,19 @@ instead. ...@@ -3422,17 +3425,19 @@ instead.
There is a {github-code}/spring-boot-samples/spring-boot-sample-web-jsp[JSP sample] so 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. that you can see how to set things up.
[[boot-features-reactive-server]] [[boot-features-reactive-server]]
=== Embedded Reactive Server Support === Embedded Reactive Server Support
Spring Boot includes support for the following embedded reactive web servers: Spring Boot includes support for the following embedded reactive web servers:
Reactor Netty, Tomcat, Jetty, and Undertow. Most developers use the appropriate “Starter” 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 to obtain a fully configured instance. By default, the embedded server listens for HTTP
requests on port 8080. requests on port 8080.
[[boot-features-reactive-server-resources]] [[boot-features-reactive-server-resources]]
=== Reactive Server Resources Configuration === Reactive Server Resources Configuration
When auto-configuring a Reactor Netty or Jetty server, Spring Boot will create specific 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` beans that will provide HTTP resources to the server instance: `ReactorResourceFactory`
or `JettyResourceFactory`. or `JettyResourceFactory`.
...@@ -3451,6 +3456,8 @@ both clients and servers. ...@@ -3451,6 +3456,8 @@ both clients and servers.
You can learn more about the resource configuration on the client side in the You can learn more about the resource configuration on the client side in the
<<boot-features-webclient-runtime, WebClient Runtime section>>. <<boot-features-webclient-runtime, WebClient Runtime section>>.
[[boot-features-rsocket]] [[boot-features-rsocket]]
== RSocket == RSocket
...@@ -3483,6 +3490,8 @@ The following code shows a typical `@Controller`: ...@@ -3483,6 +3490,8 @@ The following code shows a typical `@Controller`:
} }
---- ----
[[boot-features-rsocket-strategies-auto-configuration]] [[boot-features-rsocket-strategies-auto-configuration]]
=== RSocket Strategies Auto-configuration === RSocket Strategies Auto-configuration
Spring Boot auto-configures an `RSocketStrategies` bean that provides all the required Spring Boot auto-configures an `RSocketStrategies` bean that provides all the required
...@@ -3499,6 +3508,7 @@ implement the `RSocketStrategiesCustomizer` interface. Note that their `@Order` ...@@ -3499,6 +3508,7 @@ implement the `RSocketStrategiesCustomizer` interface. Note that their `@Order`
important, as it determines the order of codecs. important, as it determines the order of codecs.
[[boot-features-rsocket-server-auto-configuration]] [[boot-features-rsocket-server-auto-configuration]]
=== RSocket server Auto-configuration === RSocket server Auto-configuration
Spring Boot provides auto-configuration for RSocket servers. The required dependencies Spring Boot provides auto-configuration for RSocket servers. The required dependencies
...@@ -3544,6 +3554,8 @@ about customization possibilities. ...@@ -3544,6 +3554,8 @@ about customization possibilities.
Developers can create `RSocketStrategiesCustomizer` beans to add other strategies, Developers can create `RSocketStrategiesCustomizer` beans to add other strategies,
assuming there are `Encoder` and `Decoder` implementations available. assuming there are `Encoder` and `Decoder` implementations available.
[[boot-features-rsocket-requester]] [[boot-features-rsocket-requester]]
=== Calling RSocket Services with `RSocketRequester` === Calling RSocket Services with `RSocketRequester`
...@@ -3582,6 +3594,7 @@ The following code shows a typical example: ...@@ -3582,6 +3594,7 @@ The following code shows a typical example:
---- ----
[[boot-features-security]] [[boot-features-security]]
== Security == Security
If {spring-security}[Spring Security] is on the classpath, then web applications are 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 ...@@ -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. You can provide a different `AuthenticationEventPublisher` by adding a bean for it.
[[boot-features-security-mvc]] [[boot-features-security-mvc]]
=== MVC Security === MVC Security
The default security configuration is implemented in `SecurityAutoConfiguration` and The default security configuration is implemented in `SecurityAutoConfiguration` and
......
...@@ -29,7 +29,7 @@ import org.springframework.boot.web.server.LocalServerPort; ...@@ -29,7 +29,7 @@ import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static io.restassured.RestAssured.given; 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; import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
......
...@@ -39,7 +39,7 @@ import org.springframework.util.FileSystemUtils; ...@@ -39,7 +39,7 @@ import org.springframework.util.FileSystemUtils;
import static io.restassured.RestAssured.given; import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf; 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.modifyUris;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
......
...@@ -34,7 +34,7 @@ import org.springframework.util.FileSystemUtils; ...@@ -34,7 +34,7 @@ import org.springframework.util.FileSystemUtils;
import static io.restassured.RestAssured.given; import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf; 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.modifyUris;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document; import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document;
......
...@@ -23,7 +23,7 @@ import org.junit.jupiter.api.extension.ExtensionContext; ...@@ -23,7 +23,7 @@ import org.junit.jupiter.api.extension.ExtensionContext;
import static org.assertj.core.api.Assertions.assertThat; 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 * @author Madhura Bhave
*/ */
......
...@@ -21,7 +21,8 @@ import org.junit.jupiter.api.extension.RegisterExtension; ...@@ -21,7 +21,8 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import static org.assertj.core.api.Assertions.assertThat; 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 * @author Madhura Bhave
*/ */
......
...@@ -31,7 +31,7 @@ import org.testcontainers.lifecycle.Startable; ...@@ -31,7 +31,7 @@ import org.testcontainers.lifecycle.Startable;
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Madhura Bhave * @author Madhura Bhave
*/ */
public class SkippableContainer<T extends GenericContainer> implements Startable { public class SkippableContainer<T extends GenericContainer<?>> implements Startable {
private final Supplier<T> containerFactory; private final Supplier<T> containerFactory;
......
...@@ -21,7 +21,7 @@ import org.junit.Test; ...@@ -21,7 +21,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import static org.assertj.core.api.Assertions.assertThat; 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. * Tests for {@link ModifiedClassPathRunner} excluding entries from the class path.
......
...@@ -134,7 +134,7 @@ class SslServerCustomizer implements JettyServerCustomizer { ...@@ -134,7 +134,7 @@ class SslServerCustomizer implements JettyServerCustomizer {
/** /**
* Configure the SSL connection. * 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 ssl the ssl details.
* @param sslStoreProvider the ssl store provider * @param sslStoreProvider the ssl store provider
*/ */
......
...@@ -19,12 +19,15 @@ package org.springframework.boot.web.embedded.netty; ...@@ -19,12 +19,15 @@ package org.springframework.boot.web.embedded.netty;
import java.time.Duration; import java.time.Duration;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Predicate;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import reactor.netty.ChannelBindException; import reactor.netty.ChannelBindException;
import reactor.netty.DisposableServer; import reactor.netty.DisposableServer;
import reactor.netty.http.server.HttpServer; 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.PortInUseException;
import org.springframework.boot.web.server.WebServer; import org.springframework.boot.web.server.WebServer;
...@@ -44,6 +47,8 @@ import org.springframework.util.Assert; ...@@ -44,6 +47,8 @@ import org.springframework.util.Assert;
*/ */
public class NettyWebServer implements WebServer { public class NettyWebServer implements WebServer {
private static final Predicate<HttpServerRequest> ALWAYS = (r) -> true;
private static final Log logger = LogFactory.getLog(NettyWebServer.class); private static final Log logger = LogFactory.getLog(NettyWebServer.class);
private final HttpServer httpServer; private final HttpServer httpServer;
...@@ -93,10 +98,7 @@ public class NettyWebServer implements WebServer { ...@@ -93,10 +98,7 @@ public class NettyWebServer implements WebServer {
server = server.handle(this.handlerAdapter); server = server.handle(this.handlerAdapter);
} }
else { else {
server = server.route((routes) -> { server = server.route(this::applyRouteProviders);
this.routeProviders.forEach((provider) -> provider.apply(routes));
routes.route((r) -> true, this.handlerAdapter);
});
} }
if (this.lifecycleTimeout != null) { if (this.lifecycleTimeout != null) {
return server.bindNow(this.lifecycleTimeout); return server.bindNow(this.lifecycleTimeout);
...@@ -104,6 +106,11 @@ public class NettyWebServer implements WebServer { ...@@ -104,6 +106,11 @@ public class NettyWebServer implements WebServer {
return server.bindNow(); 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) { private ChannelBindException findBindException(Exception ex) {
Throwable candidate = ex; Throwable candidate = ex;
while (candidate != null) { while (candidate != null) {
......
...@@ -122,7 +122,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; ...@@ -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.assertThatIOException;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; 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.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment