Merge branch '3.2.x' into 3.3.x

Closes gh-41613
This commit is contained in:
Andy Wilkinson 2024-07-25 16:15:44 +01:00
commit c642f6d268
69 changed files with 279 additions and 302 deletions

View File

@ -35,7 +35,6 @@ import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier;
import org.springframework.boot.actuate.health.HealthEndpoint;
import org.springframework.boot.actuate.health.HealthEndpointWebExtension;
import org.springframework.boot.actuate.info.GitInfoContributor;
@ -114,7 +113,8 @@ public class CloudFoundryActuatorAutoConfiguration {
@SuppressWarnings("removal")
public CloudFoundryWebEndpointServletHandlerMapping cloudFoundryWebEndpointServletHandlerMapping(
ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes,
RestTemplateBuilder restTemplateBuilder, ServletEndpointsSupplier servletEndpointsSupplier,
RestTemplateBuilder restTemplateBuilder,
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier servletEndpointsSupplier,
ControllerEndpointsSupplier controllerEndpointsSupplier, ApplicationContext applicationContext) {
CloudFoundryWebEndpointDiscoverer discoverer = new CloudFoundryWebEndpointDiscoverer(applicationContext,
parameterMapper, endpointMediaTypes, null, Collections.emptyList(), Collections.emptyList());

View File

@ -20,9 +20,6 @@ import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.boot.actuate.autoconfigure.endpoint.expose.IncludeExcludeEndpointFilter;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint;
import org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
@ -48,22 +45,26 @@ public class ServletEndpointManagementContextConfiguration {
@Bean
@SuppressWarnings("removal")
public IncludeExcludeEndpointFilter<ExposableServletEndpoint> servletExposeExcludePropertyEndpointFilter(
public IncludeExcludeEndpointFilter<org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint> servletExposeExcludePropertyEndpointFilter(
WebEndpointProperties properties) {
WebEndpointProperties.Exposure exposure = properties.getExposure();
return new IncludeExcludeEndpointFilter<>(ExposableServletEndpoint.class, exposure.getInclude(),
return new IncludeExcludeEndpointFilter<>(
org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint.class, exposure.getInclude(),
exposure.getExclude());
}
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(DispatcherServlet.class)
@SuppressWarnings("removal")
public static class WebMvcServletEndpointManagementContextConfiguration {
@Bean
public ServletEndpointRegistrar servletEndpointRegistrar(WebEndpointProperties properties,
ServletEndpointsSupplier servletEndpointsSupplier, DispatcherServletPath dispatcherServletPath) {
return new ServletEndpointRegistrar(dispatcherServletPath.getRelativePath(properties.getBasePath()),
@SuppressWarnings({ "deprecation", "removal" })
public org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar servletEndpointRegistrar(
WebEndpointProperties properties,
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier servletEndpointsSupplier,
DispatcherServletPath dispatcherServletPath) {
return new org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar(
dispatcherServletPath.getRelativePath(properties.getBasePath()),
servletEndpointsSupplier.getEndpoints());
}
@ -72,13 +73,16 @@ public class ServletEndpointManagementContextConfiguration {
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(ResourceConfig.class)
@ConditionalOnMissingClass("org.springframework.web.servlet.DispatcherServlet")
@SuppressWarnings("removal")
public static class JerseyServletEndpointManagementContextConfiguration {
@Bean
public ServletEndpointRegistrar servletEndpointRegistrar(WebEndpointProperties properties,
ServletEndpointsSupplier servletEndpointsSupplier, JerseyApplicationPath jerseyApplicationPath) {
return new ServletEndpointRegistrar(jerseyApplicationPath.getRelativePath(properties.getBasePath()),
@SuppressWarnings({ "deprecation", "removal" })
public org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar servletEndpointRegistrar(
WebEndpointProperties properties,
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier servletEndpointsSupplier,
JerseyApplicationPath jerseyApplicationPath) {
return new org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar(
jerseyApplicationPath.getRelativePath(properties.getBasePath()),
servletEndpointsSupplier.getEndpoints());
}

View File

@ -29,16 +29,12 @@ import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.invoke.OperationInvokerAdvisor;
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint;
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.actuate.endpoint.web.PathMapper;
import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.annotation.ExposableControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -96,10 +92,12 @@ public class WebEndpointAutoConfiguration {
@Bean
@ConditionalOnMissingBean(ControllerEndpointsSupplier.class)
@SuppressWarnings("removal")
public ControllerEndpointDiscoverer controllerEndpointDiscoverer(ObjectProvider<PathMapper> endpointPathMappers,
@SuppressWarnings({ "deprecation", "removal" })
public org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer controllerEndpointDiscoverer(
ObjectProvider<PathMapper> endpointPathMappers,
ObjectProvider<Collection<EndpointFilter<ExposableControllerEndpoint>>> filters) {
return new ControllerEndpointDiscoverer(this.applicationContext, endpointPathMappers.orderedStream().toList(),
return new org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer(
this.applicationContext, endpointPathMappers.orderedStream().toList(),
filters.getIfAvailable(Collections::emptyList));
}
@ -125,16 +123,16 @@ public class WebEndpointAutoConfiguration {
@Configuration(proxyBeanMethods = false)
@ConditionalOnWebApplication(type = Type.SERVLET)
@SuppressWarnings("removal")
static class WebEndpointServletConfiguration {
@Bean
@ConditionalOnMissingBean(ServletEndpointsSupplier.class)
ServletEndpointDiscoverer servletEndpointDiscoverer(ApplicationContext applicationContext,
ObjectProvider<PathMapper> endpointPathMappers,
ObjectProvider<EndpointFilter<ExposableServletEndpoint>> filters) {
return new ServletEndpointDiscoverer(applicationContext, endpointPathMappers.orderedStream().toList(),
filters.orderedStream().toList());
@SuppressWarnings({ "deprecation", "removal" })
@ConditionalOnMissingBean(org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier.class)
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer servletEndpointDiscoverer(
ApplicationContext applicationContext, ObjectProvider<PathMapper> endpointPathMappers,
ObjectProvider<EndpointFilter<org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint>> filters) {
return new org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer(
applicationContext, endpointPathMappers.orderedStream().toList(), filters.orderedStream().toList());
}
}

View File

@ -45,11 +45,9 @@ import org.springframework.boot.actuate.endpoint.jackson.EndpointObjectMapper;
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint;
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.jersey.JerseyEndpointResourceFactory;
import org.springframework.boot.actuate.endpoint.web.jersey.JerseyHealthEndpointAdditionalPathResourceFactory;
import org.springframework.boot.actuate.health.HealthEndpoint;
@ -86,7 +84,8 @@ class JerseyWebEndpointManagementContextConfiguration {
@Bean
@SuppressWarnings("removal")
JerseyWebEndpointsResourcesRegistrar jerseyWebEndpointsResourcesRegistrar(Environment environment,
WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier,
WebEndpointsSupplier webEndpointsSupplier,
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier servletEndpointsSupplier,
EndpointMediaTypes endpointMediaTypes, WebEndpointProperties webEndpointProperties) {
String basePath = webEndpointProperties.getBasePath();
boolean shouldRegisterLinks = shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
@ -130,7 +129,7 @@ class JerseyWebEndpointManagementContextConfiguration {
private final WebEndpointsSupplier webEndpointsSupplier;
private final ServletEndpointsSupplier servletEndpointsSupplier;
private final org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier servletEndpointsSupplier;
private final EndpointMediaTypes mediaTypes;
@ -139,8 +138,8 @@ class JerseyWebEndpointManagementContextConfiguration {
private final boolean shouldRegisterLinks;
JerseyWebEndpointsResourcesRegistrar(WebEndpointsSupplier webEndpointsSupplier,
ServletEndpointsSupplier servletEndpointsSupplier, EndpointMediaTypes endpointMediaTypes,
String basePath, boolean shouldRegisterLinks) {
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier servletEndpointsSupplier,
EndpointMediaTypes endpointMediaTypes, String basePath, boolean shouldRegisterLinks) {
this.webEndpointsSupplier = webEndpointsSupplier;
this.servletEndpointsSupplier = servletEndpointsSupplier;
this.mediaTypes = endpointMediaTypes;
@ -155,7 +154,8 @@ class JerseyWebEndpointManagementContextConfiguration {
private void register(ResourceConfig config) {
Collection<ExposableWebEndpoint> webEndpoints = this.webEndpointsSupplier.getEndpoints();
Collection<ExposableServletEndpoint> servletEndpoints = this.servletEndpointsSupplier.getEndpoints();
Collection<org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint> servletEndpoints = this.servletEndpointsSupplier
.getEndpoints();
EndpointLinksResolver linksResolver = getLinksResolver(webEndpoints, servletEndpoints);
EndpointMapping mapping = new EndpointMapping(this.basePath);
Collection<Resource> endpointResources = new JerseyEndpointResourceFactory().createEndpointResources(
@ -164,7 +164,7 @@ class JerseyWebEndpointManagementContextConfiguration {
}
private EndpointLinksResolver getLinksResolver(Collection<ExposableWebEndpoint> webEndpoints,
Collection<ExposableServletEndpoint> servletEndpoints) {
Collection<org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint> servletEndpoints) {
List<ExposableEndpoint<?>> endpoints = new ArrayList<>(webEndpoints.size() + servletEndpoints.size());
endpoints.addAll(webEndpoints);
endpoints.addAll(servletEndpoints);

View File

@ -43,7 +43,6 @@ import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier;
import org.springframework.boot.actuate.endpoint.web.servlet.AdditionalHealthEndpointPathsWebMvcHandlerMapping;
import org.springframework.boot.actuate.endpoint.web.servlet.ControllerEndpointHandlerMapping;
import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping;
@ -84,9 +83,10 @@ public class WebMvcEndpointManagementContextConfiguration {
@ConditionalOnMissingBean
@SuppressWarnings("removal")
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier,
ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier,
EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties,
WebEndpointProperties webEndpointProperties, Environment environment) {
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier servletEndpointsSupplier,
ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes,
CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties,
Environment environment) {
List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
allEndpoints.addAll(webEndpoints);

View File

@ -29,7 +29,6 @@ import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfigu
import org.springframework.boot.actuate.autoconfigure.metrics.export.ConditionalOnEnabledMetricsExport;
import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration;
import org.springframework.boot.actuate.metrics.export.prometheus.PrometheusScrapeEndpoint;
import org.springframework.boot.actuate.metrics.export.prometheus.PrometheusSimpleclientScrapeEndpoint;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@ -81,7 +80,8 @@ public class PrometheusMetricsExportAutoConfiguration {
@SuppressWarnings("removal")
@Bean
@ConditionalOnMissingBean({ PrometheusScrapeEndpoint.class, PrometheusSimpleclientScrapeEndpoint.class })
@ConditionalOnMissingBean({ PrometheusScrapeEndpoint.class,
org.springframework.boot.actuate.metrics.export.prometheus.PrometheusSimpleclientScrapeEndpoint.class })
PrometheusScrapeEndpoint prometheusEndpoint(PrometheusRegistry prometheusRegistry,
PrometheusConfig prometheusConfig) {
return new PrometheusScrapeEndpoint(prometheusRegistry, prometheusConfig.prometheusProperties());

View File

@ -68,12 +68,6 @@ abstract class HttpSender extends BaseHttpSender<URI, byte[]> {
postSpans(endpoint, headers, body);
}
/**
* This will send span(s) as a POST to a zipkin endpoint.
* @param endpoint the POST endpoint. For example, http://localhost:9411/api/v2/spans.
* @param headers headers for the POST request
* @param body list of possibly gzipped, encoded spans.
*/
abstract void postSpans(URI endpoint, HttpHeaders headers, byte[] body) throws IOException;
HttpHeaders getDefaultHeaders() {

View File

@ -94,7 +94,7 @@ class ZipkinConfigurations {
@Bean
@ConditionalOnMissingBean(BytesMessageSender.class)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
ZipkinRestTemplateSender restTemplateSender(ZipkinProperties properties, Encoding encoding,
ObjectProvider<ZipkinRestTemplateBuilderCustomizer> customizers,
ObjectProvider<ZipkinConnectionDetails> connectionDetailsProvider,
@ -111,7 +111,7 @@ class ZipkinConfigurations {
restTemplateBuilder.build());
}
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
private RestTemplateBuilder applyCustomizers(RestTemplateBuilder restTemplateBuilder,
ObjectProvider<ZipkinRestTemplateBuilderCustomizer> customizers) {
Iterable<ZipkinRestTemplateBuilderCustomizer> orderedCustomizers = () -> customizers.orderedStream()
@ -132,7 +132,7 @@ class ZipkinConfigurations {
@Bean
@ConditionalOnMissingBean(BytesMessageSender.class)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
ZipkinWebClientSender webClientSender(ZipkinProperties properties, Encoding encoding,
ObjectProvider<ZipkinWebClientBuilderCustomizer> customizers,
ObjectProvider<ZipkinConnectionDetails> connectionDetailsProvider,

View File

@ -16,7 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.tracing.zipkin;
import zipkin2.reporter.HttpEndpointSupplier;
import zipkin2.reporter.HttpEndpointSupplier.Factory;
import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails;
@ -24,7 +24,7 @@ import org.springframework.boot.autoconfigure.service.connection.ConnectionDetai
* Details required to establish a connection to a Zipkin server.
* <p>
* Note: {@linkplain #getSpanEndpoint()} is only read once and passed to a bean of type
* {@link HttpEndpointSupplier.Factory} which defaults to no-op (constant).
* {@link Factory HttpEndpointSupplier.Factory} which defaults to no-op (constant).
*
* @author Moritz Halbritter
* @since 3.1.0

View File

@ -16,11 +16,11 @@
package org.springframework.boot.actuate.autoconfigure.tracing.zipkin;
import java.net.http.HttpClient;
import java.net.http.HttpClient.Builder;
/**
* Callback interface that can be implemented by beans wishing to customize the
* {@link HttpClient.Builder} used to send spans to Zipkin.
* {@link Builder HttpClient.Builder} used to send spans to Zipkin.
*
* @author Moritz Halbritter
* @since 3.3.0
@ -32,6 +32,6 @@ public interface ZipkinHttpClientBuilderCustomizer {
* Customize the http client builder.
* @param httpClient the http client builder to customize
*/
void customize(HttpClient.Builder httpClient);
void customize(Builder httpClient);
}

View File

@ -31,8 +31,6 @@ import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoint;
import org.springframework.boot.actuate.endpoint.web.PathMapper;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer;
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@ -98,7 +96,8 @@ class WebEndpointAutoConfigurationTests {
@SuppressWarnings("removal")
void webApplicationConfiguresEndpointDiscoverer() {
this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(ControllerEndpointDiscoverer.class);
assertThat(context).hasSingleBean(
org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer.class);
assertThat(context).hasSingleBean(WebEndpointDiscoverer.class);
});
}
@ -112,14 +111,16 @@ class WebEndpointAutoConfigurationTests {
@Test
@SuppressWarnings("removal")
void contextShouldConfigureServletEndpointDiscoverer() {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ServletEndpointDiscoverer.class));
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer.class));
}
@Test
@SuppressWarnings("removal")
void contextWhenNotServletShouldNotConfigureServletEndpointDiscoverer() {
new ApplicationContextRunner().withConfiguration(CONFIGURATIONS)
.run((context) -> assertThat(context).doesNotHaveBean(ServletEndpointDiscoverer.class));
.run((context) -> assertThat(context).doesNotHaveBean(
org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer.class));
}
@Component

View File

@ -22,7 +22,6 @@ import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.exporter.common.TextFormat;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.metrics.export.prometheus.PrometheusSimpleclientScrapeEndpoint;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@ -36,7 +35,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
/**
* Tests for generating documentation describing the
* {@link PrometheusSimpleclientScrapeEndpoint}.
* {@link org.springframework.boot.actuate.metrics.export.prometheus.PrometheusSimpleclientScrapeEndpoint}.
*
* @author Andy Wilkinson
* @author Johnny Lim
@ -76,12 +75,13 @@ class PrometheusSimpleclientScrapeEndpointDocumentationTests extends MockMvcEndp
@Bean
@SuppressWarnings({ "removal", "deprecation" })
PrometheusSimpleclientScrapeEndpoint endpoint() {
org.springframework.boot.actuate.metrics.export.prometheus.PrometheusSimpleclientScrapeEndpoint endpoint() {
CollectorRegistry collectorRegistry = new CollectorRegistry(true);
io.micrometer.prometheus.PrometheusMeterRegistry meterRegistry = new io.micrometer.prometheus.PrometheusMeterRegistry(
(key) -> null, collectorRegistry, Clock.SYSTEM);
new JvmMemoryMetrics().bindTo(meterRegistry);
return new PrometheusSimpleclientScrapeEndpoint(collectorRegistry);
return new org.springframework.boot.actuate.metrics.export.prometheus.PrometheusSimpleclientScrapeEndpoint(
collectorRegistry);
}
}

View File

@ -25,8 +25,6 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfi
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementContextAutoConfiguration;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
@ -52,8 +50,9 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* Integration tests for the Actuator's MVC {@link ControllerEndpoint controller
* endpoints}.
* Integration tests for the Actuator's MVC
* {@link org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint
* controller endpoints}.
*
* @author Phillip Webb
* @author Andy Wilkinson
@ -120,7 +119,7 @@ class ControllerEndpointWebMvcIntegrationTests {
}
@RestControllerEndpoint(id = "example")
@org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint(id = "example")
@SuppressWarnings("removal")
static class ExampleController {

View File

@ -30,8 +30,6 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfi
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration;
@ -160,13 +158,13 @@ class JerseyEndpointIntegrationTests {
return autoconfigurations.toArray(new Class<?>[0]);
}
@ControllerEndpoint(id = "controller")
@org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint(id = "controller")
@SuppressWarnings("removal")
static class TestControllerEndpoint {
}
@RestControllerEndpoint(id = "restcontroller")
@org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint(id = "restcontroller")
@SuppressWarnings("removal")
static class TestRestControllerEndpoint {

View File

@ -25,8 +25,6 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfi
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.reactive.ReactiveManagementContextAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
@ -107,13 +105,13 @@ class WebFluxEndpointIntegrationTests {
.build();
}
@ControllerEndpoint(id = "controller")
@org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint(id = "controller")
@SuppressWarnings("removal")
static class TestControllerEndpoint {
}
@RestControllerEndpoint(id = "restcontroller")
@org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint(id = "restcontroller")
@SuppressWarnings("removal")
static class TestRestControllerEndpoint {

View File

@ -33,9 +33,6 @@ import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAu
import org.springframework.boot.actuate.autoconfigure.web.exchanges.HttpExchangesAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementContextAutoConfiguration;
import org.springframework.boot.actuate.endpoint.web.EndpointServlet;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint;
import org.springframework.boot.actuate.web.exchanges.InMemoryHttpExchangeRepository;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
@ -189,7 +186,7 @@ class WebMvcEndpointExposureIntegrationTests {
String.format("Unexpected %s HTTP status for endpoint %s", result.getStatus(), path));
}
@RestControllerEndpoint(id = "custommvc")
@org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint(id = "custommvc")
@SuppressWarnings("removal")
static class CustomMvcEndpoint {
@ -200,13 +197,14 @@ class WebMvcEndpointExposureIntegrationTests {
}
@ServletEndpoint(id = "customservlet")
@SuppressWarnings("removal")
static class CustomServletEndpoint implements Supplier<EndpointServlet> {
@org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint(id = "customservlet")
@SuppressWarnings({ "deprecation", "removal" })
static class CustomServletEndpoint
implements Supplier<org.springframework.boot.actuate.endpoint.web.EndpointServlet> {
@Override
public EndpointServlet get() {
return new EndpointServlet(new HttpServlet() {
public org.springframework.boot.actuate.endpoint.web.EndpointServlet get() {
return new org.springframework.boot.actuate.endpoint.web.EndpointServlet(new HttpServlet() {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)

View File

@ -28,10 +28,6 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfi
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementContextAutoConfiguration;
import org.springframework.boot.actuate.endpoint.web.EndpointServlet;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint;
import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
@ -197,25 +193,26 @@ class WebMvcEndpointIntegrationTests {
}
@ServletEndpoint(id = "servlet")
@SuppressWarnings("removal")
static class TestServletEndpoint implements Supplier<EndpointServlet> {
@org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint(id = "servlet")
@SuppressWarnings({ "deprecation", "removal" })
static class TestServletEndpoint
implements Supplier<org.springframework.boot.actuate.endpoint.web.EndpointServlet> {
@Override
public EndpointServlet get() {
return new EndpointServlet(new HttpServlet() {
public org.springframework.boot.actuate.endpoint.web.EndpointServlet get() {
return new org.springframework.boot.actuate.endpoint.web.EndpointServlet(new HttpServlet() {
});
}
}
@ControllerEndpoint(id = "controller")
@org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint(id = "controller")
@SuppressWarnings("removal")
static class TestControllerEndpoint {
}
@RestControllerEndpoint(id = "restcontroller")
@org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint(id = "restcontroller")
@SuppressWarnings("removal")
static class TestRestControllerEndpoint {

View File

@ -30,7 +30,6 @@ import org.springframework.boot.actuate.endpoint.Operation;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoint;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
@ -354,7 +353,7 @@ class EndpointRequestTests {
}
@ServletEndpoint(id = "baz")
@org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint(id = "baz")
@SuppressWarnings("removal")
static class BazServletEndpoint {

View File

@ -32,8 +32,6 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAu
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.web.EndpointServlet;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
@ -177,13 +175,14 @@ abstract class AbstractEndpointRequestIntegrationTests {
}
@ServletEndpoint(id = "se1")
@SuppressWarnings("removal")
static class TestServletEndpoint implements Supplier<EndpointServlet> {
@org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint(id = "se1")
@SuppressWarnings({ "deprecation", "removal" })
static class TestServletEndpoint
implements Supplier<org.springframework.boot.actuate.endpoint.web.EndpointServlet> {
@Override
public EndpointServlet get() {
return new EndpointServlet(ExampleServlet.class);
public org.springframework.boot.actuate.endpoint.web.EndpointServlet get() {
return new org.springframework.boot.actuate.endpoint.web.EndpointServlet(ExampleServlet.class);
}
}

View File

@ -31,7 +31,6 @@ import org.springframework.boot.actuate.endpoint.Operation;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoint;
import org.springframework.boot.actuate.endpoint.web.PathMappedEndpoints;
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint;
import org.springframework.boot.autoconfigure.security.servlet.RequestMatcherProvider;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockServletContext;
@ -353,7 +352,7 @@ class EndpointRequestTests {
}
@ServletEndpoint(id = "baz")
@org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint(id = "baz")
@SuppressWarnings("removal")
static class BazServletEndpoint {

View File

@ -34,7 +34,7 @@ import static org.mockito.Mockito.mock;
*
* @author Andy Wilkinson
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class LazyTracingSpanContextSupplierTests {
private final Tracer tracer = mock(Tracer.class);

View File

@ -50,7 +50,7 @@ import static org.mockito.Mockito.mock;
*
* @author Moritz Halbritter
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class ZipkinConfigurationsSenderConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()

View File

@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.tracing.zipkin;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.time.Duration;
import java.util.Base64;
@ -36,8 +35,6 @@ import zipkin2.reporter.Encoding;
import zipkin2.reporter.HttpEndpointSupplier;
import zipkin2.reporter.HttpEndpointSuppliers;
import org.springframework.http.HttpHeaders;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatIOException;
@ -55,9 +52,14 @@ class ZipkinHttpClientSenderTests extends ZipkinHttpSenderTests {
@Override
@BeforeEach
void beforeEach() throws Exception {
void beforeEach() {
this.mockBackEnd = new MockWebServer();
this.mockBackEnd.start();
try {
this.mockBackEnd.start();
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
this.zipkinUrl = this.mockBackEnd.url("/api/v2/spans").toString();
super.beforeEach();
}
@ -109,10 +111,6 @@ class ZipkinHttpClientSenderTests extends ZipkinHttpSenderTests {
});
}
/**
* This tests that a dynamic {@linkplain HttpEndpointSupplier} updates are visible to
* {@link HttpSender#postSpans(URI, HttpHeaders, byte[])}.
*/
@Test
void sendUsesDynamicEndpoint() throws Exception {
this.mockBackEnd.enqueue(new MockResponse());

View File

@ -41,7 +41,7 @@ abstract class ZipkinHttpSenderTests {
abstract BytesMessageSender createSender();
@BeforeEach
void beforeEach() throws Exception {
void beforeEach() {
this.sender = createSender();
}

View File

@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.tracing.zipkin;
import java.io.IOException;
import java.net.URI;
import java.util.Base64;
import java.util.Collections;
import java.util.List;
@ -29,7 +28,6 @@ import zipkin2.reporter.Encoding;
import zipkin2.reporter.HttpEndpointSupplier;
import zipkin2.reporter.HttpEndpointSuppliers;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.test.web.client.MockRestServiceServer;
@ -48,7 +46,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
* @author Moritz Halbritter
* @author Stefan Bratanov
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class ZipkinRestTemplateSenderTests extends ZipkinHttpSenderTests {
private static final String ZIPKIN_URL = "http://localhost:9411/api/v2/spans";
@ -101,10 +99,6 @@ class ZipkinRestTemplateSenderTests extends ZipkinHttpSenderTests {
}
}
/**
* This tests that a dynamic {@linkplain HttpEndpointSupplier} updates are visible to
* {@link HttpSender#postSpans(URI, HttpHeaders, byte[])}.
*/
@Test
void sendUsesDynamicEndpoint() throws Exception {
this.mockServer.expect(requestTo(ZIPKIN_URL + "/1")).andRespond(withStatus(HttpStatus.ACCEPTED));

View File

@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.tracing.zipkin;
import java.io.IOException;
import java.net.URI;
import java.time.Duration;
import java.util.Base64;
import java.util.Collections;
@ -39,7 +38,6 @@ import zipkin2.reporter.Encoding;
import zipkin2.reporter.HttpEndpointSupplier;
import zipkin2.reporter.HttpEndpointSuppliers;
import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.function.client.WebClient;
import static org.assertj.core.api.Assertions.assertThat;
@ -50,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThatException;
*
* @author Stefan Bratanov
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
private static ClearableDispatcher dispatcher;
@ -75,7 +73,7 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
@Override
@BeforeEach
void beforeEach() throws Exception {
void beforeEach() {
super.beforeEach();
clearResponses();
clearRequests();
@ -122,10 +120,6 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
});
}
/**
* This tests that a dynamic {@linkplain HttpEndpointSupplier} updates are visible to
* {@link HttpSender#postSpans(URI, HttpHeaders, byte[])}.
*/
@Test
void sendUsesDynamicEndpoint() throws Exception {
mockBackEnd.enqueue(new MockResponse());
@ -180,10 +174,16 @@ class ZipkinWebClientSenderTests extends ZipkinHttpSenderTests {
assertThat(request).satisfies(assertions);
}
private static void clearRequests() throws InterruptedException {
private static void clearRequests() {
RecordedRequest request;
do {
request = mockBackEnd.takeRequest(0, TimeUnit.SECONDS);
try {
request = mockBackEnd.takeRequest(0, TimeUnit.SECONDS);
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new RuntimeException(ex);
}
}
while (request != null);
}

View File

@ -36,7 +36,6 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAu
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
@ -216,7 +215,7 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests {
}
@RestControllerEndpoint(id = "failController")
@org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint(id = "failController")
@SuppressWarnings("removal")
static class FailingControllerEndpoint {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -24,9 +24,7 @@ import java.util.Map;
import java.util.Set;
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.ExposableControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.util.Assert;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.reactive.HandlerMapping;
@ -35,9 +33,11 @@ import org.springframework.web.reactive.result.method.annotation.RequestMappingH
import org.springframework.web.util.pattern.PathPattern;
/**
* {@link HandlerMapping} that exposes {@link ControllerEndpoint @ControllerEndpoint} and
* {@link RestControllerEndpoint @RestControllerEndpoint} annotated endpoints over Spring
* WebFlux.
* {@link HandlerMapping} that exposes
* {@link org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint @ControllerEndpoint}
* and
* {@link org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint @RestControllerEndpoint}
* annotated endpoints over Spring WebFlux.
*
* @author Phillip Webb
* @since 2.0.0

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -25,9 +25,7 @@ import java.util.Map;
import java.util.Set;
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.ExposableControllerEndpoint;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.util.Assert;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.HandlerMapping;
@ -36,9 +34,11 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
import org.springframework.web.util.pattern.PathPattern;
/**
* {@link HandlerMapping} that exposes {@link ControllerEndpoint @ControllerEndpoint} and
* {@link RestControllerEndpoint @RestControllerEndpoint} annotated endpoints over Spring
* MVC.
* {@link HandlerMapping} that exposes
* {@link org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint @ControllerEndpoint}
* and
* {@link org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint @RestControllerEndpoint}
* annotated endpoints over Spring MVC.
*
* @author Phillip Webb
* @since 2.0.0

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2024 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.
@ -46,6 +46,7 @@ public class JettyServerThreadPoolMetricsBinder extends AbstractJettyMetricsBind
}
@Override
@SuppressWarnings("resource")
protected void bindMetrics(Server server) {
ThreadPool threadPool = server.getThreadPool();
if (threadPool != null) {

View File

@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.entry;
* @author Phillip Webb
* @author Stephane Nicoll
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class EndpointServletTests {
@Test

View File

@ -48,7 +48,7 @@ import static org.mockito.Mockito.mock;
* @author Stephane Nicoll
*/
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class ServletEndpointRegistrarTests {
@Mock

View File

@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Stephane Nicoll
* @author Moritz Halbritter
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class ControllerEndpointDiscovererTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();

View File

@ -57,7 +57,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Stephane Nicoll
* @author Moritz Halbritter
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class ServletEndpointDiscovererTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();

View File

@ -58,7 +58,7 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
* @author Phillip Webb
* @author Stephane Nicoll
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class ControllerEndpointHandlerMappingIntegrationTests {
private final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner(

View File

@ -57,7 +57,7 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
* @author Phillip Webb
* @author Stephane Nicoll
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class ControllerEndpointHandlerMappingIntegrationTests {
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner(

View File

@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Jon Schneider
* @author Johnny Lim
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class PrometheusSimpleclientScrapeEndpointIntegrationTests {
@WebEndpointTest

View File

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.pulsar;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.pulsar.client.api.PulsarClientException;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.PulsarContainer;
import org.testcontainers.junit.jupiter.Container;
@ -106,7 +105,7 @@ class PulsarAutoConfigurationIntegrationTests {
}
@GetMapping("/hello")
String sayHello() throws PulsarClientException {
String sayHello() {
return "Hello World -> " + this.pulsarTemplate.send(TOPIC, "hello");
}

View File

@ -43,7 +43,6 @@ import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfigurati
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException;
import org.springframework.boot.task.TaskSchedulerBuilder;
import org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
@ -171,13 +170,14 @@ public class IntegrationAutoConfiguration {
* scheduling explicitly.
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(TaskSchedulerBuilder.class)
@ConditionalOnBean(org.springframework.boot.task.TaskSchedulerBuilder.class)
@ConditionalOnMissingBean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
protected static class IntegrationTaskSchedulerConfiguration {
@Bean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME)
public ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder taskSchedulerBuilder,
public ThreadPoolTaskScheduler taskScheduler(
org.springframework.boot.task.TaskSchedulerBuilder taskSchedulerBuilder,
ObjectProvider<ThreadPoolTaskSchedulerBuilder> threadPoolTaskSchedulerBuilderProvider) {
ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder = threadPoolTaskSchedulerBuilderProvider
.getIfUnique();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -22,7 +22,6 @@ import java.util.List;
import org.apache.pulsar.client.admin.PulsarAdminBuilder;
import org.apache.pulsar.client.api.ClientBuilder;
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.pulsar.client.api.PulsarClientException;
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.common.schema.SchemaType;
@ -96,7 +95,7 @@ class PulsarConfiguration {
@Bean
@ConditionalOnMissingBean
PulsarClient pulsarClient(PulsarClientFactory clientFactory) throws PulsarClientException {
PulsarClient pulsarClient(PulsarClientFactory clientFactory) {
return clientFactory.createClient();
}

View File

@ -24,8 +24,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading;
import org.springframework.boot.autoconfigure.thread.Threading;
import org.springframework.boot.task.SimpleAsyncTaskExecutorBuilder;
import org.springframework.boot.task.SimpleAsyncTaskExecutorCustomizer;
import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.boot.task.TaskExecutorCustomizer;
import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder;
import org.springframework.boot.task.ThreadPoolTaskExecutorCustomizer;
import org.springframework.context.annotation.Bean;
@ -49,7 +47,6 @@ class TaskExecutorConfigurations {
@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingBean(Executor.class)
@SuppressWarnings("removal")
static class TaskExecutorConfiguration {
@Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME,
@ -63,7 +60,9 @@ class TaskExecutorConfigurations {
@Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME,
AsyncAnnotationBeanPostProcessor.DEFAULT_TASK_EXECUTOR_BEAN_NAME })
@ConditionalOnThreading(Threading.PLATFORM)
ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder taskExecutorBuilder,
@SuppressWarnings({ "deprecation", "removal" })
ThreadPoolTaskExecutor applicationTaskExecutor(
org.springframework.boot.task.TaskExecutorBuilder taskExecutorBuilder,
ObjectProvider<ThreadPoolTaskExecutorBuilder> threadPoolTaskExecutorBuilderProvider) {
ThreadPoolTaskExecutorBuilder threadPoolTaskExecutorBuilder = threadPoolTaskExecutorBuilderProvider
.getIfUnique();
@ -82,11 +81,11 @@ class TaskExecutorConfigurations {
@Bean
@ConditionalOnMissingBean
@Deprecated(since = "3.2.0", forRemoval = true)
TaskExecutorBuilder taskExecutorBuilder(TaskExecutionProperties properties,
ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers,
org.springframework.boot.task.TaskExecutorBuilder taskExecutorBuilder(TaskExecutionProperties properties,
ObjectProvider<org.springframework.boot.task.TaskExecutorCustomizer> taskExecutorCustomizers,
ObjectProvider<TaskDecorator> taskDecorator) {
TaskExecutionProperties.Pool pool = properties.getPool();
TaskExecutorBuilder builder = new TaskExecutorBuilder();
org.springframework.boot.task.TaskExecutorBuilder builder = new org.springframework.boot.task.TaskExecutorBuilder();
builder = builder.queueCapacity(pool.getQueueCapacity());
builder = builder.corePoolSize(pool.getCoreSize());
builder = builder.maxPoolSize(pool.getMaxSize());
@ -104,14 +103,15 @@ class TaskExecutorConfigurations {
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
static class ThreadPoolTaskExecutorBuilderConfiguration {
@Bean
@ConditionalOnMissingBean({ TaskExecutorBuilder.class, ThreadPoolTaskExecutorBuilder.class })
@ConditionalOnMissingBean({ org.springframework.boot.task.TaskExecutorBuilder.class,
ThreadPoolTaskExecutorBuilder.class })
ThreadPoolTaskExecutorBuilder threadPoolTaskExecutorBuilder(TaskExecutionProperties properties,
ObjectProvider<ThreadPoolTaskExecutorCustomizer> threadPoolTaskExecutorCustomizers,
ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers,
ObjectProvider<org.springframework.boot.task.TaskExecutorCustomizer> taskExecutorCustomizers,
ObjectProvider<TaskDecorator> taskDecorator) {
TaskExecutionProperties.Pool pool = properties.getPool();
ThreadPoolTaskExecutorBuilder builder = new ThreadPoolTaskExecutorBuilder();
@ -132,7 +132,8 @@ class TaskExecutorConfigurations {
return builder;
}
private ThreadPoolTaskExecutorCustomizer adapt(TaskExecutorCustomizer customizer) {
private ThreadPoolTaskExecutorCustomizer adapt(
org.springframework.boot.task.TaskExecutorCustomizer customizer) {
return customizer::customize;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -25,8 +25,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading;
import org.springframework.boot.autoconfigure.thread.Threading;
import org.springframework.boot.task.SimpleAsyncTaskSchedulerBuilder;
import org.springframework.boot.task.SimpleAsyncTaskSchedulerCustomizer;
import org.springframework.boot.task.TaskSchedulerBuilder;
import org.springframework.boot.task.TaskSchedulerCustomizer;
import org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder;
import org.springframework.boot.task.ThreadPoolTaskSchedulerCustomizer;
import org.springframework.context.annotation.Bean;
@ -47,7 +45,6 @@ class TaskSchedulingConfigurations {
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(name = TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
@ConditionalOnMissingBean({ TaskScheduler.class, ScheduledExecutorService.class })
@SuppressWarnings("removal")
static class TaskSchedulerConfiguration {
@Bean(name = "taskScheduler")
@ -57,8 +54,9 @@ class TaskSchedulingConfigurations {
}
@Bean
@SuppressWarnings({ "deprecation", "removal" })
@ConditionalOnThreading(Threading.PLATFORM)
ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder taskSchedulerBuilder,
ThreadPoolTaskScheduler taskScheduler(org.springframework.boot.task.TaskSchedulerBuilder taskSchedulerBuilder,
ObjectProvider<ThreadPoolTaskSchedulerBuilder> threadPoolTaskSchedulerBuilderProvider) {
ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder = threadPoolTaskSchedulerBuilderProvider
.getIfUnique();
@ -71,14 +69,14 @@ class TaskSchedulingConfigurations {
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
static class TaskSchedulerBuilderConfiguration {
@Bean
@ConditionalOnMissingBean
TaskSchedulerBuilder taskSchedulerBuilder(TaskSchedulingProperties properties,
ObjectProvider<TaskSchedulerCustomizer> taskSchedulerCustomizers) {
TaskSchedulerBuilder builder = new TaskSchedulerBuilder();
org.springframework.boot.task.TaskSchedulerBuilder taskSchedulerBuilder(TaskSchedulingProperties properties,
ObjectProvider<org.springframework.boot.task.TaskSchedulerCustomizer> taskSchedulerCustomizers) {
org.springframework.boot.task.TaskSchedulerBuilder builder = new org.springframework.boot.task.TaskSchedulerBuilder();
builder = builder.poolSize(properties.getPool().getSize());
TaskSchedulingProperties.Shutdown shutdown = properties.getShutdown();
builder = builder.awaitTermination(shutdown.isAwaitTermination());
@ -91,14 +89,15 @@ class TaskSchedulingConfigurations {
}
@Configuration(proxyBeanMethods = false)
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
static class ThreadPoolTaskSchedulerBuilderConfiguration {
@Bean
@ConditionalOnMissingBean({ TaskSchedulerBuilder.class, ThreadPoolTaskSchedulerBuilder.class })
@ConditionalOnMissingBean({ org.springframework.boot.task.TaskSchedulerBuilder.class,
ThreadPoolTaskSchedulerBuilder.class })
ThreadPoolTaskSchedulerBuilder threadPoolTaskSchedulerBuilder(TaskSchedulingProperties properties,
ObjectProvider<ThreadPoolTaskSchedulerCustomizer> threadPoolTaskSchedulerCustomizers,
ObjectProvider<TaskSchedulerCustomizer> taskSchedulerCustomizers) {
ObjectProvider<org.springframework.boot.task.TaskSchedulerCustomizer> taskSchedulerCustomizers) {
TaskSchedulingProperties.Shutdown shutdown = properties.getShutdown();
ThreadPoolTaskSchedulerBuilder builder = new ThreadPoolTaskSchedulerBuilder();
builder = builder.poolSize(properties.getPool().getSize());
@ -111,7 +110,8 @@ class TaskSchedulingConfigurations {
return builder;
}
private ThreadPoolTaskSchedulerCustomizer adapt(TaskSchedulerCustomizer customizer) {
private ThreadPoolTaskSchedulerCustomizer adapt(
org.springframework.boot.task.TaskSchedulerCustomizer customizer) {
return customizer::customize;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -35,13 +35,14 @@ import org.springframework.context.annotation.Scope;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link RestClient}.
* <p>
* This will produce a {@link RestClient.Builder RestClient.Builder} bean with the
* {@code prototype} scope, meaning each injection point will receive a newly cloned
* instance of the builder.
* This will produce a {@link Builder RestClient.Builder} bean with the {@code prototype}
* scope, meaning each injection point will receive a newly cloned instance of the
* builder.
*
* @author Arjen Poutsma
* @author Moritz Halbritter

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -23,7 +23,7 @@ import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
/**
* Configure {@link RestClient.Builder} with sensible defaults.
* Configure {@link Builder RestClient.Builder} with sensible defaults.
*
* @author Moritz Halbritter
* @since 3.2.0
@ -37,9 +37,9 @@ public class RestClientBuilderConfigurer {
}
/**
* Configure the specified {@link RestClient.Builder}. The builder can be further
* tuned and default settings can be overridden.
* @param builder the {@link RestClient.Builder} instance to configure
* Configure the specified {@link Builder RestClient.Builder}. The builder can be
* further tuned and default settings can be overridden.
* @param builder the {@link Builder RestClient.Builder} instance to configure
* @return the configured builder
*/
public RestClient.Builder configure(RestClient.Builder builder) {

View File

@ -27,7 +27,6 @@ import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLOutputType;
import graphql.schema.GraphQLSchema;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.visibility.DefaultGraphqlFieldVisibility;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -171,20 +170,13 @@ class GraphQlAutoConfigurationTests {
@Test
void fieldIntrospectionShouldBeEnabledByDefault() {
this.contextRunner.run((context) -> {
GraphQlSource graphQlSource = context.getBean(GraphQlSource.class);
GraphQLSchema schema = graphQlSource.schema();
assertThat(schema.getCodeRegistry().getFieldVisibility()).isInstanceOf(DefaultGraphqlFieldVisibility.class);
});
this.contextRunner.run((context) -> assertThat(Introspection.isEnabledJvmWide()).isTrue());
}
@Test
void shouldDisableFieldIntrospection() {
this.contextRunner.withPropertyValues("spring.graphql.schema.introspection.enabled:false").run((context) -> {
GraphQlSource graphQlSource = context.getBean(GraphQlSource.class);
GraphQLSchema schema = graphQlSource.schema();
assertThat(Introspection.isEnabledJvmWide()).isFalse();
});
this.contextRunner.withPropertyValues("spring.graphql.schema.introspection.enabled:false")
.run((context) -> assertThat(Introspection.isEnabledJvmWide()).isFalse());
}
@Test

View File

@ -80,6 +80,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void shouldNotSupplyThreadPoolTaskExecutorBuilderIfCustomTaskExecutorBuilderIsPresent() {
this.contextRunner.withBean(TaskExecutorBuilder.class, TaskExecutorBuilder::new).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
@ -164,6 +165,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void taskExecutorBuilderShouldUseTaskDecorator() {
this.contextRunner.withUserConfiguration(TaskDecoratorConfig.class).run((context) -> {
assertThat(context).hasSingleBean(TaskExecutorBuilder.class);
@ -275,6 +277,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void taskExecutorBuilderShouldApplyCustomizer() {
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
@ -284,6 +287,7 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void threadPoolTaskExecutorBuilderShouldApplyCustomizer() {
this.contextRunner.withUserConfiguration(TaskExecutorCustomizerConfig.class).run((context) -> {
TaskExecutorCustomizer customizer = context.getBean(TaskExecutorCustomizer.class);
@ -335,6 +339,7 @@ class TaskExecutionAutoConfigurationTests {
});
}
@SuppressWarnings("deprecation")
private ContextConsumer<AssertableApplicationContext> assertTaskExecutor(
Consumer<ThreadPoolTaskExecutor> taskExecutor) {
return (context) -> {
@ -379,7 +384,8 @@ class TaskExecutionAutoConfigurationTests {
@Configuration(proxyBeanMethods = false)
static class CustomTaskExecutorBuilderConfig {
private final TaskExecutorBuilder taskExecutorBuilder = new TaskExecutorBuilder()
@SuppressWarnings("deprecation")
private final org.springframework.boot.task.TaskExecutorBuilder taskExecutorBuilder = new org.springframework.boot.task.TaskExecutorBuilder()
.threadNamePrefix("CustomTaskExecutorBuilderConfig-");
@Bean

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -87,6 +87,7 @@ class TaskSchedulingAutoConfigurationTests {
}
@Test
@SuppressWarnings("deprecation")
void shouldNotSupplyThreadPoolTaskSchedulerBuilderIfCustomTaskSchedulerBuilderIsPresent() {
this.contextRunner.withUserConfiguration(SchedulingConfiguration.class)
.withBean(TaskSchedulerBuilder.class, TaskSchedulerBuilder::new)
@ -155,7 +156,6 @@ class TaskSchedulingAutoConfigurationTests {
}
@Test
@SuppressWarnings("unchecked")
void simpleAsyncTaskSchedulerBuilderShouldApplyCustomizers() {
SimpleAsyncTaskSchedulerCustomizer customizer = (scheduler) -> {
};

View File

@ -1,5 +1,5 @@
/*
* Copyright 2023-2023 the original author or authors.
* Copyright 2023-2024 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.
@ -37,6 +37,7 @@ public class MyBean {
this.pulsarReaderFactory = pulsarReaderFactory;
}
@SuppressWarnings("unused")
public void someMethod() {
ReactiveMessageReaderBuilderCustomizer<String> readerBuilderCustomizer = (readerBuilder) -> readerBuilder
.topic("someTopic")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2023-2023 the original author or authors.
* Copyright 2023-2024 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.
@ -16,8 +16,6 @@
package org.springframework.boot.docs.messaging.pulsar.sending;
import org.apache.pulsar.client.api.PulsarClientException;
import org.springframework.pulsar.core.PulsarTemplate;
import org.springframework.stereotype.Component;
@ -30,7 +28,7 @@ public class MyBean {
this.pulsarTemplate = pulsarTemplate;
}
public void someMethod() throws PulsarClientException {
public void someMethod() {
this.pulsarTemplate.send("someTopic", "Hello");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -29,13 +29,13 @@ import org.springframework.boot.test.web.client.MockServerRestClientCustomizer;
import org.springframework.boot.test.web.client.MockServerRestTemplateCustomizer;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
/**
* Annotation that can be applied to a test class to enable and configure
* auto-configuration of a single {@link MockRestServiceServer}. Only useful when a single
* call is made to {@link RestTemplateBuilder} or {@link RestClient.Builder}. If multiple
* {@link org.springframework.web.client.RestTemplate RestTemplates} or
* call is made to {@link RestTemplateBuilder} or {@link Builder RestClient.Builder}. If
* multiple {@link org.springframework.web.client.RestTemplate RestTemplates} or
* {@link org.springframework.web.client.RestClient RestClients} are in use, inject a
* {@link MockServerRestTemplateCustomizer} and use
* {@link MockServerRestTemplateCustomizer#getServer(org.springframework.web.client.RestTemplate)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -38,12 +38,12 @@ import org.springframework.stereotype.Component;
import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
import org.springframework.web.client.RestTemplate;
/**
* Annotation for a Spring rest client test that focuses <strong>only</strong> on beans
* that use {@link RestTemplateBuilder} or {@link RestClient.Builder}.
* that use {@link RestTemplateBuilder} or {@link Builder RestClient.Builder}.
* <p>
* Using this annotation will disable full auto-configuration and instead apply only
* configuration relevant to rest client tests (i.e. Jackson or GSON auto-configuration

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class ConditionReportApplicationContextFailureProcessorTests {
@Test
void loadFailureShouldPrintReport(CapturedOutput output) throws Exception {
void loadFailureShouldPrintReport(CapturedOutput output) {
SpringApplication application = new SpringApplication(TestConfig.class);
application.setWebApplicationType(WebApplicationType.NONE);
ConfigurableApplicationContext applicationContext = application.run();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -20,7 +20,6 @@ import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.mock.env.MockEnvironment;
@ -148,11 +147,6 @@ class ObservabilityContextCustomizerFactoryTests {
return contextCustomizer;
}
private ApplicationContextInitializer<ConfigurableApplicationContext> applyCustomizer(
ContextCustomizer customizer) {
return (applicationContext) -> customizer.customizeContext(applicationContext, null);
}
private void assertThatTracingIsDisabled(ConfigurableApplicationContext context) {
assertThat(context.getEnvironment().getProperty("management.tracing.enabled")).isEqualTo("false");
}

View File

@ -30,9 +30,10 @@ import org.springframework.test.web.client.RequestExpectationManager;
import org.springframework.test.web.client.SimpleRequestExpectationManager;
import org.springframework.util.Assert;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestClient.Builder;
/**
* {@link RestClientCustomizer} that can be applied to {@link RestClient.Builder}
* {@link RestClientCustomizer} that can be applied to {@link Builder RestClient.Builder}
* instances to add {@link MockRestServiceServer} support.
* <p>
* Typically applied to an existing builder before it is used, for example:

View File

@ -20,7 +20,6 @@ import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import org.apache.pulsar.client.api.PulsarClientException;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.PulsarContainer;
@ -63,7 +62,7 @@ class PulsarContainerConnectionDetailsFactoryIntegrationTests {
private TestListener listener;
@Test
void connectionCanBeMadeToPulsarContainer() throws PulsarClientException {
void connectionCanBeMadeToPulsarContainer() {
this.pulsarTemplate.send("test-topic", "test-data");
Awaitility.waitAtMost(Duration.ofSeconds(30))
.untilAsserted(() -> assertThat(this.listener.messages).containsExactly("test-data"));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -18,10 +18,6 @@ package org.springframework.boot.configurationsample.record;
import org.springframework.boot.configurationsample.ConfigurationProperties;
/**
* @author Moritz Halbritter
* @param alpha the alpha property
*/
@ConfigurationProperties("record-with-getter")
public record RecordWithGetter(String alpha) {

View File

@ -32,7 +32,6 @@ public final class GradleVersions {
private GradleVersions() {
}
@SuppressWarnings("UnstableApiUsage")
public static List<String> allCompatible() {
if (isJavaVersion(JavaVersion.VERSION_20)) {
return Arrays.asList("8.1.1", "8.9");

View File

@ -268,6 +268,12 @@ public abstract class Packager {
}
}
/**
* Writes a signature file if necessary for the given {@code writtenLibraries}.
* @param writtenLibraries the libraries
* @param writer the writer to use to write the signature file if necessary
* @throws IOException if a failure occurs when writing the signature file
*/
protected void writeSignatureFileIfNecessary(Map<String, Library> writtenLibraries, AbstractJarWriter writer)
throws IOException {
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -33,44 +33,49 @@ class ByteArrayDataBlockTests {
@Test
void sizeReturnsByteArrayLength() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
assertThat(dataBlock.size()).isEqualTo(this.BYTES.length);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
assertThat(dataBlock.size()).isEqualTo(this.BYTES.length);
}
}
@Test
void readPutsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(8);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(this.BYTES);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(8);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(this.BYTES);
}
}
@Test
void readWhenLessBytesThanRemainingInBufferPutsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(9);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6, 7, 0);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(9);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6, 7, 0);
}
}
@Test
void readWhenLessRemainingInBufferThanLengthPutsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(7);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(7);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(7);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(7);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6);
}
}
@Test
void readWhenHasPosOffsetReadsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(3);
int result = dataBlock.read(dst, 4);
assertThat(result).isEqualTo(3);
assertThat(dst.array()).containsExactly(4, 5, 6);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(3);
int result = dataBlock.read(dst, 4);
assertThat(result).isEqualTo(3);
assertThat(dst.array()).containsExactly(4, 5, 6);
}
}
}

View File

@ -83,8 +83,6 @@ import org.springframework.util.StringUtils;
*/
public class Log4J2LoggingSystem extends AbstractLoggingSystem {
private static final String FILE_PROTOCOL = "file";
private static final String LOG4J_BRIDGE_HANDLER = "org.apache.logging.log4j.jul.Log4jBridgeHandler";
private static final String LOG4J_LOG_MANAGER = "org.apache.logging.log4j.jul.LogManager";

View File

@ -51,7 +51,6 @@ import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JdkClientHttpRequestFactory;
import org.springframework.http.client.JettyClientHttpRequestFactory;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@ -90,7 +89,8 @@ public final class ClientHttpRequestFactories {
* <ol>
* <li>{@link HttpComponentsClientHttpRequestFactory}</li>
* <li>{@link JettyClientHttpRequestFactory}</li>
* <li>{@link OkHttp3ClientHttpRequestFactory} (deprecated)</li>
* <li>{@link org.springframework.http.client.OkHttp3ClientHttpRequestFactory
* OkHttp3ClientHttpRequestFactory} (deprecated)</li>
* <li>{@link SimpleClientHttpRequestFactory}</li>
* </ol>
* @param settings the settings to apply
@ -120,7 +120,8 @@ public final class ClientHttpRequestFactories {
* <li>{@link HttpComponentsClientHttpRequestFactory}</li>
* <li>{@link JdkClientHttpRequestFactory}</li>
* <li>{@link JettyClientHttpRequestFactory}</li>
* <li>{@link OkHttp3ClientHttpRequestFactory} (deprecated)</li>
* <li>{@link org.springframework.http.client.OkHttp3ClientHttpRequestFactory
* OkHttp3ClientHttpRequestFactory} (deprecated)</li>
* <li>{@link SimpleClientHttpRequestFactory}</li>
* </ul>
* A {@code requestFactoryType} of {@link ClientHttpRequestFactory} is equivalent to
@ -149,7 +150,7 @@ public final class ClientHttpRequestFactories {
if (requestFactoryType == SimpleClientHttpRequestFactory.class) {
return (T) Simple.get(settings);
}
if (requestFactoryType == OkHttp3ClientHttpRequestFactory.class) {
if (requestFactoryType == org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class) {
return (T) OkHttp.get(settings);
}
return get(() -> createRequestFactory(requestFactoryType), settings);
@ -220,21 +221,25 @@ public final class ClientHttpRequestFactories {
}
/**
* Support for {@link OkHttp3ClientHttpRequestFactory}.
* Support for
* {@link org.springframework.http.client.OkHttp3ClientHttpRequestFactory}.
*/
@Deprecated(since = "3.2.0", forRemoval = true)
@SuppressWarnings("removal")
static class OkHttp {
static OkHttp3ClientHttpRequestFactory get(ClientHttpRequestFactorySettings settings) {
OkHttp3ClientHttpRequestFactory requestFactory = createRequestFactory(settings.sslBundle());
static org.springframework.http.client.OkHttp3ClientHttpRequestFactory get(
ClientHttpRequestFactorySettings settings) {
org.springframework.http.client.OkHttp3ClientHttpRequestFactory requestFactory = createRequestFactory(
settings.sslBundle());
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
map.from(settings::connectTimeout).asInt(Duration::toMillis).to(requestFactory::setConnectTimeout);
map.from(settings::readTimeout).asInt(Duration::toMillis).to(requestFactory::setReadTimeout);
return requestFactory;
}
private static OkHttp3ClientHttpRequestFactory createRequestFactory(SslBundle sslBundle) {
private static org.springframework.http.client.OkHttp3ClientHttpRequestFactory createRequestFactory(
SslBundle sslBundle) {
if (sslBundle != null) {
Assert.state(!sslBundle.getOptions().isSpecified(), "SSL Options cannot be specified with OkHttp");
SSLSocketFactory socketFactory = sslBundle.createSslContext().getSocketFactory();
@ -244,9 +249,9 @@ public final class ClientHttpRequestFactories {
OkHttpClient client = new OkHttpClient.Builder()
.sslSocketFactory(socketFactory, (X509TrustManager) trustManagers[0])
.build();
return new OkHttp3ClientHttpRequestFactory(client);
return new org.springframework.http.client.OkHttp3ClientHttpRequestFactory(client);
}
return new OkHttp3ClientHttpRequestFactory();
return new org.springframework.http.client.OkHttp3ClientHttpRequestFactory();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -29,7 +29,6 @@ import org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JettyClientHttpRequestFactory;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@ -72,7 +71,7 @@ class ClientHttpRequestFactoriesRuntimeHints implements RuntimeHintsRegistrar {
private void registerOkHttpHints(ReflectionHints hints, ClassLoader classLoader) {
hints.registerTypeIfPresent(classLoader, ClientHttpRequestFactories.OKHTTP_CLIENT_CLASS, (typeHint) -> {
typeHint.onReachableType(TypeReference.of(ClientHttpRequestFactories.OKHTTP_CLIENT_CLASS));
registerReflectionHints(hints, OkHttp3ClientHttpRequestFactory.class);
registerReflectionHints(hints, org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class);
});
}

View File

@ -284,7 +284,6 @@ class StandardConfigDataLocationResolverTests {
void resolveWhenOptionalAndLoaderIsUnknownAndExtensionIsUnknownShouldNotFail() {
ConfigDataLocation location = ConfigDataLocation
.of("optional:some-unknown-loader:dummy.some-unknown-extension");
List<StandardConfigDataResource> locations = this.resolver.resolve(this.context, location);
assertThatNoException().isThrownBy(() -> this.resolver.resolve(this.context, location));
}

View File

@ -227,6 +227,7 @@ class ConfigurationPropertiesBeanRegistrationAotProcessorTests {
this.counter = counter;
}
@SuppressWarnings("unused")
private ValueObjectWithSpecificConstructorSampleBean(String name) {
this(name, 42);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -37,7 +37,7 @@ import static org.mockito.Mockito.spy;
* @author Stephane Nicoll
* @author Filip Hrisafov
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class TaskExecutorBuilderTests {
private final TaskExecutorBuilder builder = new TaskExecutorBuilder();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -35,7 +35,7 @@ import static org.mockito.Mockito.spy;
*
* @author Stephane Nicoll
*/
@SuppressWarnings("removal")
@SuppressWarnings({ "deprecation", "removal" })
class TaskSchedulerBuilderTests {
private final TaskSchedulerBuilder builder = new TaskSchedulerBuilder();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -27,7 +27,6 @@ import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.http.client.AbstractClientHttpRequestFactoryWrapper;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JettyClientHttpRequestFactory;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.ReflectionUtils;
@ -69,11 +68,15 @@ class ClientHttpRequestFactoriesRuntimeHintsTests {
RuntimeHints hints = new RuntimeHints();
new ClientHttpRequestFactoriesRuntimeHints().registerHints(hints, getClass().getClassLoader());
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
assertThat(reflection.onMethod(method(OkHttp3ClientHttpRequestFactory.class, "setConnectTimeout", int.class)))
assertThat(reflection.onMethod(method(org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class,
"setConnectTimeout", int.class)))
.accepts(hints);
assertThat(reflection.onMethod(method(OkHttp3ClientHttpRequestFactory.class, "setReadTimeout", int.class)))
assertThat(reflection.onMethod(method(org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class,
"setReadTimeout", int.class)))
.accepts(hints);
assertThat(hints.reflection().getTypeHint(OkHttp3ClientHttpRequestFactory.class).methods()).hasSize(2);
assertThat(hints.reflection()
.getTypeHint(org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class)
.methods()).hasSize(2);
}
@Test

View File

@ -27,7 +27,6 @@ import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JdkClientHttpRequestFactory;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import static org.assertj.core.api.Assertions.assertThat;
@ -72,9 +71,10 @@ class ClientHttpRequestFactoriesTests {
@Deprecated(since = "3.2.0")
@SuppressWarnings("removal")
void getOfOkHttpFactoryReturnsOkHttpFactory() {
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(OkHttp3ClientHttpRequestFactory.class,
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(
org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class,
ClientHttpRequestFactorySettings.DEFAULTS);
assertThat(requestFactory).isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
assertThat(requestFactory).isInstanceOf(org.springframework.http.client.OkHttp3ClientHttpRequestFactory.class);
}
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@ -18,7 +18,6 @@ package smoketest.actuator;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalManagementPort;
@ -30,8 +29,8 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for separate management and main service ports with Actuator's MVC
* {@link RestControllerEndpoint rest controller endpoints} and {@link ExceptionHandler
* exception handler}.
* {@link org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint
* rest controller endpoints} and {@link ExceptionHandler exception handler}.
*
* @author Guirong Hu
*/