diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/AbstractCompositeHealthContributorConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/AbstractCompositeHealthContributorConfiguration.java index 5a7454b08a5..3b5aeda866d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/AbstractCompositeHealthContributorConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/AbstractCompositeHealthContributorConfiguration.java @@ -16,12 +16,9 @@ package org.springframework.boot.actuate.autoconfigure.health; -import java.lang.reflect.Constructor; import java.util.Map; import java.util.function.Function; -import org.springframework.beans.BeanUtils; -import org.springframework.core.ResolvableType; import org.springframework.util.Assert; /** @@ -39,18 +36,6 @@ public abstract class AbstractCompositeHealthContributorConfiguration indicatorFactory; - /** - * Creates a {@code AbstractCompositeHealthContributorConfiguration} that will use - * reflection to create health indicator instances. - * @deprecated since 3.0.0 in favor of - * {@link #AbstractCompositeHealthContributorConfiguration(Function)} - */ - @Deprecated(since = "3.0.0", forRemoval = true) - protected AbstractCompositeHealthContributorConfiguration() { - this.indicatorFactory = new ReflectionIndicatorFactory( - ResolvableType.forClass(AbstractCompositeHealthContributorConfiguration.class, getClass())); - } - /** * Creates a {@code AbstractCompositeHealthContributorConfiguration} that will use the * given {@code indicatorFactory} to create health indicator instances. @@ -75,34 +60,4 @@ public abstract class AbstractCompositeHealthContributorConfiguration { - - private final Class indicatorType; - - private final Class beanType; - - ReflectionIndicatorFactory(ResolvableType type) { - this.indicatorType = type.resolveGeneric(1); - this.beanType = type.resolveGeneric(2); - } - - @Override - public I apply(B bean) { - try { - return BeanUtils.instantiateClass(getConstructor(), bean); - } - catch (Exception ex) { - throw new IllegalStateException("Unable to create health indicator %s for bean type %s" - .formatted(this.indicatorType, this.beanType), ex); - } - - } - - @SuppressWarnings("unchecked") - private Constructor getConstructor() throws NoSuchMethodException { - return (Constructor) this.indicatorType.getDeclaredConstructor(this.beanType); - } - - } - } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeHealthContributorConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeHealthContributorConfiguration.java index 7901e130755..4b979e94d19 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeHealthContributorConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeHealthContributorConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 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. @@ -36,18 +36,6 @@ import org.springframework.boot.actuate.health.HealthIndicator; public abstract class CompositeHealthContributorConfiguration extends AbstractCompositeHealthContributorConfiguration { - /** - * Creates a {@code CompositeHealthContributorConfiguration} that will use reflection - * to create {@link HealthIndicator} instances. - * @deprecated since 3.0.0 in favor of - * {@link #CompositeHealthContributorConfiguration(Function)} - */ - @SuppressWarnings("removal") - @Deprecated(since = "3.0.0", forRemoval = true) - public CompositeHealthContributorConfiguration() { - super(); - } - /** * Creates a {@code CompositeHealthContributorConfiguration} that will use the given * {@code indicatorFactory} to create {@link HealthIndicator} instances. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthContributorConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthContributorConfiguration.java index 57b45ff1a10..12c4ff22a88 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthContributorConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthContributorConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 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. @@ -36,18 +36,6 @@ import org.springframework.boot.actuate.health.ReactiveHealthIndicator; public abstract class CompositeReactiveHealthContributorConfiguration extends AbstractCompositeHealthContributorConfiguration { - /** - * Creates a {@code CompositeReactiveHealthContributorConfiguration} that will use - * reflection to create {@link ReactiveHealthIndicator} instances. - * @deprecated since 3.0.0 in favor of - * {@link #CompositeReactiveHealthContributorConfiguration(Function)} - */ - @SuppressWarnings("removal") - @Deprecated(since = "3.0.0", forRemoval = true) - public CompositeReactiveHealthContributorConfiguration() { - super(); - } - /** * Creates a {@code CompositeReactiveHealthContributorConfiguration} that will use the * given {@code indicatorFactory} to create {@link ReactiveHealthIndicator} instances. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java index 771aa7ad46f..d3994aa3289 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsProperties.java @@ -116,8 +116,6 @@ public class MetricsProperties { public static class Client { - private final ClientRequest request = new ClientRequest(); - /** * Maximum number of unique URI tag values allowed. After the max number of * tag values is reached, metrics with additional tag values are denied by @@ -125,10 +123,6 @@ public class MetricsProperties { */ private int maxUriTags = 100; - public ClientRequest getRequest() { - return this.request; - } - public int getMaxUriTags() { return this.maxUriTags; } @@ -137,32 +131,10 @@ public class MetricsProperties { this.maxUriTags = maxUriTags; } - public static class ClientRequest { - - /** - * Name of the metric for sent requests. - */ - private String metricName = "http.client.requests"; - - @Deprecated(since = "3.0.0", forRemoval = true) - @DeprecatedConfigurationProperty(replacement = "management.observations.http.client.requests.name") - public String getMetricName() { - return this.metricName; - } - - @Deprecated(since = "3.0.0", forRemoval = true) - public void setMetricName(String metricName) { - this.metricName = metricName; - } - - } - } public static class Server { - private final ServerRequest request = new ServerRequest(); - /** * Maximum number of unique URI tag values allowed. After the max number of * tag values is reached, metrics with additional tag values are denied by @@ -170,10 +142,6 @@ public class MetricsProperties { */ private int maxUriTags = 100; - public ServerRequest getRequest() { - return this.request; - } - public int getMaxUriTags() { return this.maxUriTags; } @@ -182,27 +150,6 @@ public class MetricsProperties { this.maxUriTags = maxUriTags; } - public static class ServerRequest { - - /** - * Name of the metric for received requests. - */ - private String metricName = "http.server.requests"; - - @Deprecated(since = "3.0.0", forRemoval = true) - @DeprecatedConfigurationProperty(replacement = "management.observations.http.server.requests.name") - public String getMetricName() { - return this.metricName; - } - - @Deprecated(since = "3.0.0", forRemoval = true) - @DeprecatedConfigurationProperty(replacement = "management.observations.http.server.requests.name") - public void setMetricName(String metricName) { - this.metricName = metricName; - } - - } - } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfiguration.java index fdb018f2276..654a87564e4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfiguration.java @@ -29,9 +29,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties; -import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties.Web.Server; import org.springframework.boot.actuate.autoconfigure.metrics.OnlyOnceLoggingDenyMeterFilter; import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.observation.ObservationProperties; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -57,13 +57,12 @@ import org.springframework.core.annotation.Order; @ConditionalOnClass({ ResourceConfig.class, MetricsApplicationEventListener.class }) @ConditionalOnBean({ MeterRegistry.class, ResourceConfig.class }) @EnableConfigurationProperties(MetricsProperties.class) -@SuppressWarnings("removal") public class JerseyServerMetricsAutoConfiguration { - private final MetricsProperties properties; + private final ObservationProperties observationProperties; - public JerseyServerMetricsAutoConfiguration(MetricsProperties properties) { - this.properties = properties; + public JerseyServerMetricsAutoConfiguration(ObservationProperties observationProperties) { + this.observationProperties = observationProperties; } @Bean @@ -75,19 +74,19 @@ public class JerseyServerMetricsAutoConfiguration { @Bean public ResourceConfigCustomizer jerseyServerMetricsResourceConfigCustomizer(MeterRegistry meterRegistry, JerseyTagsProvider tagsProvider) { - Server server = this.properties.getWeb().getServer(); - return (config) -> config.register(new MetricsApplicationEventListener(meterRegistry, tagsProvider, - server.getRequest().getMetricName(), true, new AnnotationUtilsAnnotationFinder())); + String metricName = this.observationProperties.getHttp().getServer().getRequests().getName(); + return (config) -> config.register(new MetricsApplicationEventListener(meterRegistry, tagsProvider, metricName, + true, new AnnotationUtilsAnnotationFinder())); } @Bean @Order(0) - public MeterFilter jerseyMetricsUriTagFilter() { - String metricName = this.properties.getWeb().getServer().getRequest().getMetricName(); + public MeterFilter jerseyMetricsUriTagFilter(MetricsProperties metricsProperties) { + String metricName = this.observationProperties.getHttp().getServer().getRequests().getName(); MeterFilter filter = new OnlyOnceLoggingDenyMeterFilter( () -> String.format("Reached the maximum number of URI tags for '%s'.", metricName)); - return MeterFilter.maximumAllowableTags(metricName, "uri", this.properties.getWeb().getServer().getMaxUriTags(), - filter); + return MeterFilter.maximumAllowableTags(metricName, "uri", + metricsProperties.getWeb().getServer().getMaxUriTags(), filter); } /** diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/ObservationProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/ObservationProperties.java index b42ecf3e212..24d81daa4b1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/ObservationProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/ObservationProperties.java @@ -91,10 +91,9 @@ public class ObservationProperties { public static class ClientRequests { /** - * Name of the observation for client requests. If empty, will use the - * default "http.client.requests". + * Name of the observation for client requests. */ - private String name; + private String name = "http.client.requests"; public String getName() { return this.name; @@ -125,10 +124,9 @@ public class ObservationProperties { public static class ServerRequests { /** - * Name of the observation for server requests. If empty, will use the - * default "http.server.requests". + * Name of the observation for server requests. */ - private String name; + private String name = "http.server.requests"; public String getName() { return this.name; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/graphql/GraphQlObservationAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/graphql/GraphQlObservationAutoConfiguration.java index 5c447db00fb..86b5ed0aee3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/graphql/GraphQlObservationAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/graphql/GraphQlObservationAutoConfiguration.java @@ -43,7 +43,6 @@ import org.springframework.graphql.observation.GraphQlObservationInstrumentation @AutoConfiguration(after = ObservationAutoConfiguration.class) @ConditionalOnBean(ObservationRegistry.class) @ConditionalOnClass({ GraphQL.class, GraphQlSource.class, Observation.class }) -@SuppressWarnings("removal") public class GraphQlObservationAutoConfiguration { @Bean diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientHttpObservationConventionAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientHttpObservationConventionAdapter.java deleted file mode 100644 index 87205527f5e..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientHttpObservationConventionAdapter.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.observation.web.client; - -import io.micrometer.common.KeyValues; -import io.micrometer.core.instrument.Tag; - -import org.springframework.boot.actuate.metrics.web.client.RestTemplateExchangeTagsProvider; -import org.springframework.http.client.observation.ClientRequestObservationContext; -import org.springframework.http.client.observation.ClientRequestObservationConvention; - -/** - * Adapter class that applies {@link RestTemplateExchangeTagsProvider} tags as a - * {@link ClientRequestObservationConvention}. - * - * @author Brian Clozel - */ -@SuppressWarnings({ "removal" }) -class ClientHttpObservationConventionAdapter implements ClientRequestObservationConvention { - - private final String metricName; - - private final RestTemplateExchangeTagsProvider tagsProvider; - - ClientHttpObservationConventionAdapter(String metricName, RestTemplateExchangeTagsProvider tagsProvider) { - this.metricName = metricName; - this.tagsProvider = tagsProvider; - } - - @Override - @SuppressWarnings("deprecation") - public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) { - Iterable tags = this.tagsProvider.getTags(context.getUriTemplate(), context.getCarrier(), - context.getResponse()); - return KeyValues.of(tags, Tag::getKey, Tag::getValue); - } - - @Override - public KeyValues getHighCardinalityKeyValues(ClientRequestObservationContext context) { - return KeyValues.empty(); - } - - @Override - public String getName() { - return this.metricName; - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapter.java deleted file mode 100644 index 0f3230a5bf8..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapter.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.observation.web.client; - -import io.micrometer.common.KeyValues; -import io.micrometer.core.instrument.Tag; -import io.micrometer.observation.Observation; - -import org.springframework.boot.actuate.metrics.web.reactive.client.WebClientExchangeTagsProvider; -import org.springframework.core.Conventions; -import org.springframework.web.reactive.function.client.ClientRequest; -import org.springframework.web.reactive.function.client.ClientRequestObservationContext; -import org.springframework.web.reactive.function.client.ClientRequestObservationConvention; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * Adapter class that applies {@link WebClientExchangeTagsProvider} tags as a - * {@link ClientRequestObservationConvention}. - * - * @author Brian Clozel - */ -@SuppressWarnings("removal") -class ClientObservationConventionAdapter implements ClientRequestObservationConvention { - - private static final String URI_TEMPLATE_ATTRIBUTE = Conventions.getQualifiedAttributeName(WebClient.class, - "uriTemplate"); - - private final String metricName; - - private final WebClientExchangeTagsProvider tagsProvider; - - ClientObservationConventionAdapter(String metricName, WebClientExchangeTagsProvider tagsProvider) { - this.metricName = metricName; - this.tagsProvider = tagsProvider; - } - - @Override - public boolean supportsContext(Observation.Context context) { - return context instanceof ClientRequestObservationContext; - } - - @Override - public KeyValues getLowCardinalityKeyValues(ClientRequestObservationContext context) { - ClientRequest request = context.getRequest(); - if (request == null) { - request = context.getCarrier().attribute(URI_TEMPLATE_ATTRIBUTE, context.getUriTemplate()).build(); - } - Iterable tags = this.tagsProvider.tags(request, context.getResponse(), context.getError()); - return KeyValues.of(tags, Tag::getKey, Tag::getValue); - } - - @Override - public KeyValues getHighCardinalityKeyValues(ClientRequestObservationContext context) { - return KeyValues.empty(); - } - - @Override - public String getName() { - return this.metricName; - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/HttpClientObservationsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/HttpClientObservationsAutoConfiguration.java index 23323d25238..563a805e654 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/HttpClientObservationsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/HttpClientObservationsAutoConfiguration.java @@ -65,13 +65,10 @@ public class HttpClientObservationsAutoConfiguration { @Bean @Order(0) - @SuppressWarnings("removal") MeterFilter metricsHttpClientUriTagFilter(ObservationProperties observationProperties, MetricsProperties metricsProperties) { Client clientProperties = metricsProperties.getWeb().getClient(); - String metricName = clientProperties.getRequest().getMetricName(); - String observationName = observationProperties.getHttp().getClient().getRequests().getName(); - String name = (observationName != null) ? observationName : metricName; + String name = observationProperties.getHttp().getClient().getRequests().getName(); MeterFilter denyFilter = new OnlyOnceLoggingDenyMeterFilter( () -> "Reached the maximum number of URI tags for '%s'. Are you using 'uriVariables'?" .formatted(name)); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfiguration.java index 0f62f2849b1..a1d2a152de5 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 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 org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties; import org.springframework.boot.actuate.autoconfigure.observation.ObservationProperties; import org.springframework.boot.actuate.metrics.web.client.ObservationRestTemplateCustomizer; -import org.springframework.boot.actuate.metrics.web.client.RestTemplateExchangeTagsProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.web.client.RestTemplateBuilder; @@ -40,39 +39,16 @@ import org.springframework.web.client.RestTemplate; @Configuration(proxyBeanMethods = false) @ConditionalOnClass(RestTemplate.class) @ConditionalOnBean(RestTemplateBuilder.class) -@SuppressWarnings("removal") class RestTemplateObservationConfiguration { @Bean ObservationRestTemplateCustomizer observationRestTemplateCustomizer(ObservationRegistry observationRegistry, ObjectProvider customConvention, - ObservationProperties observationProperties, MetricsProperties metricsProperties, - ObjectProvider optionalTagsProvider) { - String name = observationName(observationProperties, metricsProperties); - ClientRequestObservationConvention observationConvention = createConvention(customConvention.getIfAvailable(), - name, optionalTagsProvider.getIfAvailable()); + ObservationProperties observationProperties, MetricsProperties metricsProperties) { + String name = observationProperties.getHttp().getClient().getRequests().getName(); + ClientRequestObservationConvention observationConvention = customConvention + .getIfAvailable(() -> new DefaultClientRequestObservationConvention(name)); return new ObservationRestTemplateCustomizer(observationRegistry, observationConvention); } - private static String observationName(ObservationProperties observationProperties, - MetricsProperties metricsProperties) { - String metricName = metricsProperties.getWeb().getClient().getRequest().getMetricName(); - String observationName = observationProperties.getHttp().getClient().getRequests().getName(); - return (observationName != null) ? observationName : metricName; - } - - private static ClientRequestObservationConvention createConvention( - ClientRequestObservationConvention customConvention, String name, - RestTemplateExchangeTagsProvider tagsProvider) { - if (customConvention != null) { - return customConvention; - } - else if (tagsProvider != null) { - return new ClientHttpObservationConventionAdapter(name, tagsProvider); - } - else { - return new DefaultClientRequestObservationConvention(name); - } - } - } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfiguration.java index ce531912e1d..2df9c4bf910 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 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 org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties; import org.springframework.boot.actuate.autoconfigure.observation.ObservationProperties; import org.springframework.boot.actuate.metrics.web.reactive.client.ObservationWebClientCustomizer; -import org.springframework.boot.actuate.metrics.web.reactive.client.WebClientExchangeTagsProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -37,39 +36,16 @@ import org.springframework.web.reactive.function.client.WebClient; */ @Configuration(proxyBeanMethods = false) @ConditionalOnClass(WebClient.class) -@SuppressWarnings("removal") class WebClientObservationConfiguration { @Bean ObservationWebClientCustomizer observationWebClientCustomizer(ObservationRegistry observationRegistry, ObjectProvider customConvention, - ObservationProperties observationProperties, ObjectProvider tagsProvider, - MetricsProperties metricsProperties) { - String name = observationName(observationProperties, metricsProperties); - ClientRequestObservationConvention observationConvention = createConvention(customConvention.getIfAvailable(), - tagsProvider.getIfAvailable(), name); + ObservationProperties observationProperties, MetricsProperties metricsProperties) { + String name = observationProperties.getHttp().getClient().getRequests().getName(); + ClientRequestObservationConvention observationConvention = customConvention + .getIfAvailable(() -> new DefaultClientRequestObservationConvention(name)); return new ObservationWebClientCustomizer(observationRegistry, observationConvention); } - private static ClientRequestObservationConvention createConvention( - ClientRequestObservationConvention customConvention, WebClientExchangeTagsProvider tagsProvider, - String name) { - if (customConvention != null) { - return customConvention; - } - else if (tagsProvider != null) { - return new ClientObservationConventionAdapter(name, tagsProvider); - } - else { - return new DefaultClientRequestObservationConvention(name); - } - } - - private static String observationName(ObservationProperties observationProperties, - MetricsProperties metricsProperties) { - String metricName = metricsProperties.getWeb().getClient().getRequest().getMetricName(); - String observationName = observationProperties.getHttp().getClient().getRequests().getName(); - return (observationName != null) ? observationName : metricName; - } - } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapter.java deleted file mode 100644 index 43689a962a0..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapter.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.observation.web.reactive; - -import java.util.List; - -import io.micrometer.common.KeyValues; -import io.micrometer.core.instrument.Tag; - -import org.springframework.boot.actuate.metrics.web.reactive.server.DefaultWebFluxTagsProvider; -import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsContributor; -import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsProvider; -import org.springframework.http.codec.ServerCodecConfigurer; -import org.springframework.http.server.reactive.observation.ServerRequestObservationContext; -import org.springframework.http.server.reactive.observation.ServerRequestObservationConvention; -import org.springframework.web.server.adapter.DefaultServerWebExchange; -import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver; -import org.springframework.web.server.i18n.LocaleContextResolver; -import org.springframework.web.server.session.DefaultWebSessionManager; -import org.springframework.web.server.session.WebSessionManager; - -/** - * Adapter class that applies {@link WebFluxTagsProvider} tags as a - * {@link ServerRequestObservationConvention}. - * - * @author Brian Clozel - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention { - - private final WebSessionManager webSessionManager = new DefaultWebSessionManager(); - - private final ServerCodecConfigurer serverCodecConfigurer = ServerCodecConfigurer.create(); - - private final LocaleContextResolver localeContextResolver = new AcceptHeaderLocaleContextResolver(); - - private final String name; - - private final WebFluxTagsProvider tagsProvider; - - ServerRequestObservationConventionAdapter(String name, WebFluxTagsProvider tagsProvider) { - this.name = name; - this.tagsProvider = tagsProvider; - } - - ServerRequestObservationConventionAdapter(String name, List contributors) { - this(name, new DefaultWebFluxTagsProvider(contributors)); - } - - @Override - public String getName() { - return this.name; - } - - @Override - public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) { - DefaultServerWebExchange serverWebExchange = new DefaultServerWebExchange(context.getCarrier(), - context.getResponse(), this.webSessionManager, this.serverCodecConfigurer, this.localeContextResolver); - serverWebExchange.getAttributes().putAll(context.getAttributes()); - Iterable tags = this.tagsProvider.httpRequestTags(serverWebExchange, context.getError()); - return KeyValues.of(tags, Tag::getKey, Tag::getValue); - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/WebFluxObservationAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/WebFluxObservationAutoConfiguration.java index 17c2a9d7f27..457d2cdf393 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/WebFluxObservationAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/WebFluxObservationAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.observation.web.reactive; -import java.util.List; - import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.config.MeterFilter; import io.micrometer.observation.Observation; @@ -31,8 +29,6 @@ import org.springframework.boot.actuate.autoconfigure.metrics.OnlyOnceLoggingDen import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.ObservationProperties; -import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsContributor; -import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -66,48 +62,23 @@ import org.springframework.web.filter.reactive.ServerHttpObservationFilter; @SuppressWarnings("removal") public class WebFluxObservationAutoConfiguration { - private final MetricsProperties metricsProperties; - private final ObservationProperties observationProperties; - public WebFluxObservationAutoConfiguration(MetricsProperties metricsProperties, - ObservationProperties observationProperties) { - this.metricsProperties = metricsProperties; + public WebFluxObservationAutoConfiguration(ObservationProperties observationProperties) { this.observationProperties = observationProperties; } @Bean @ConditionalOnMissingBean(ServerHttpObservationFilter.class) public OrderedServerHttpObservationFilter webfluxObservationFilter(ObservationRegistry registry, - ObjectProvider customConvention, - ObjectProvider tagConfigurer, - ObjectProvider contributorsProvider) { - String observationName = this.observationProperties.getHttp().getServer().getRequests().getName(); - String metricName = this.metricsProperties.getWeb().getServer().getRequest().getMetricName(); - String name = (observationName != null) ? observationName : metricName; - WebFluxTagsProvider tagsProvider = tagConfigurer.getIfAvailable(); - List tagsContributors = contributorsProvider.orderedStream().toList(); - ServerRequestObservationConvention convention = createConvention(customConvention.getIfAvailable(), name, - tagsProvider, tagsContributors); + ObjectProvider customConvention) { + String name = this.observationProperties.getHttp().getServer().getRequests().getName(); + ServerRequestObservationConvention convention = customConvention + .getIfAvailable(() -> new DefaultServerRequestObservationConvention(name)); int order = this.observationProperties.getHttp().getServer().getFilter().getOrder(); return new OrderedServerHttpObservationFilter(registry, convention, order); } - private static ServerRequestObservationConvention createConvention( - ServerRequestObservationConvention customConvention, String name, WebFluxTagsProvider tagsProvider, - List tagsContributors) { - if (customConvention != null) { - return customConvention; - } - if (tagsProvider != null) { - return new ServerRequestObservationConventionAdapter(name, tagsProvider); - } - if (!tagsContributors.isEmpty()) { - return new ServerRequestObservationConventionAdapter(name, tagsContributors); - } - return new DefaultServerRequestObservationConvention(name); - } - @Configuration(proxyBeanMethods = false) @ConditionalOnClass(MeterRegistry.class) @ConditionalOnBean(MeterRegistry.class) @@ -117,9 +88,7 @@ public class WebFluxObservationAutoConfiguration { @Order(0) MeterFilter metricsHttpServerUriTagFilter(MetricsProperties metricsProperties, ObservationProperties observationProperties) { - String observationName = observationProperties.getHttp().getServer().getRequests().getName(); - String name = (observationName != null) ? observationName - : metricsProperties.getWeb().getServer().getRequest().getMetricName(); + String name = observationProperties.getHttp().getServer().getRequests().getName(); MeterFilter filter = new OnlyOnceLoggingDenyMeterFilter( () -> "Reached the maximum number of URI tags for '%s'.".formatted(name)); return MeterFilter.maximumAllowableTags(name, "uri", metricsProperties.getWeb().getServer().getMaxUriTags(), diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapter.java deleted file mode 100644 index df52cbca740..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapter.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.observation.web.servlet; - -import java.util.List; - -import io.micrometer.common.KeyValues; -import io.micrometer.core.instrument.Tag; -import io.micrometer.observation.Observation; - -import org.springframework.boot.actuate.metrics.web.servlet.DefaultWebMvcTagsProvider; -import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor; -import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsProvider; -import org.springframework.http.server.observation.ServerRequestObservationContext; -import org.springframework.http.server.observation.ServerRequestObservationConvention; -import org.springframework.util.Assert; -import org.springframework.web.servlet.HandlerMapping; - -/** - * Adapter class that applies {@link WebMvcTagsProvider} tags as a - * {@link ServerRequestObservationConvention}. - * - * @author Brian Clozel - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention { - - private final String observationName; - - private final WebMvcTagsProvider tagsProvider; - - ServerRequestObservationConventionAdapter(String observationName, WebMvcTagsProvider tagsProvider, - List contributors) { - Assert.state((tagsProvider != null) || (contributors != null), - "adapter should adapt to a WebMvcTagsProvider or a list of contributors"); - this.observationName = observationName; - this.tagsProvider = (tagsProvider != null) ? tagsProvider : new DefaultWebMvcTagsProvider(contributors); - } - - @Override - public String getName() { - return this.observationName; - } - - @Override - public boolean supportsContext(Observation.Context context) { - return context instanceof ServerRequestObservationContext; - } - - @Override - public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) { - Iterable tags = this.tagsProvider.getTags(context.getCarrier(), context.getResponse(), getHandler(context), - context.getError()); - return KeyValues.of(tags, Tag::getKey, Tag::getValue); - } - - private Object getHandler(ServerRequestObservationContext context) { - return context.getCarrier().getAttribute(HandlerMapping.BEST_MATCHING_HANDLER_ATTRIBUTE); - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/WebMvcObservationAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/WebMvcObservationAutoConfiguration.java index dba50c22f3d..e6f1c487def 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/WebMvcObservationAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/WebMvcObservationAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.observation.web.servlet; -import java.util.List; - import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.config.MeterFilter; import io.micrometer.observation.Observation; @@ -32,8 +30,6 @@ import org.springframework.boot.actuate.autoconfigure.metrics.OnlyOnceLoggingDen import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.ObservationProperties; -import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor; -import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -66,56 +62,23 @@ import org.springframework.web.servlet.DispatcherServlet; @ConditionalOnClass({ DispatcherServlet.class, Observation.class }) @ConditionalOnBean(ObservationRegistry.class) @EnableConfigurationProperties({ MetricsProperties.class, ObservationProperties.class }) -@SuppressWarnings("removal") public class WebMvcObservationAutoConfiguration { - private final MetricsProperties metricsProperties; - - private final ObservationProperties observationProperties; - - public WebMvcObservationAutoConfiguration(ObservationProperties observationProperties, - MetricsProperties metricsProperties) { - this.observationProperties = observationProperties; - this.metricsProperties = metricsProperties; - } - @Bean @ConditionalOnMissingFilterBean public FilterRegistrationBean webMvcObservationFilter(ObservationRegistry registry, ObjectProvider customConvention, - ObjectProvider customTagsProvider, - ObjectProvider contributorsProvider) { - String name = httpRequestsMetricName(this.observationProperties, this.metricsProperties); - ServerRequestObservationConvention convention = createConvention(customConvention.getIfAvailable(), name, - customTagsProvider.getIfAvailable(), contributorsProvider.orderedStream().toList()); + ObservationProperties observationProperties) { + String name = observationProperties.getHttp().getServer().getRequests().getName(); + ServerRequestObservationConvention convention = customConvention + .getIfAvailable(() -> new DefaultServerRequestObservationConvention(name)); ServerHttpObservationFilter filter = new ServerHttpObservationFilter(registry, convention); FilterRegistrationBean registration = new FilterRegistrationBean<>(filter); - registration.setOrder(this.observationProperties.getHttp().getServer().getFilter().getOrder()); + registration.setOrder(observationProperties.getHttp().getServer().getFilter().getOrder()); registration.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC); return registration; } - private static ServerRequestObservationConvention createConvention( - ServerRequestObservationConvention customConvention, String name, WebMvcTagsProvider tagsProvider, - List contributors) { - if (customConvention != null) { - return customConvention; - } - else if (tagsProvider != null || contributors.size() > 0) { - return new ServerRequestObservationConventionAdapter(name, tagsProvider, contributors); - } - else { - return new DefaultServerRequestObservationConvention(name); - } - } - - private static String httpRequestsMetricName(ObservationProperties observationProperties, - MetricsProperties metricsProperties) { - String observationName = observationProperties.getHttp().getServer().getRequests().getName(); - return (observationName != null) ? observationName - : metricsProperties.getWeb().getServer().getRequest().getMetricName(); - } - @Configuration(proxyBeanMethods = false) @ConditionalOnClass(MeterRegistry.class) @ConditionalOnBean(MeterRegistry.class) @@ -123,9 +86,9 @@ public class WebMvcObservationAutoConfiguration { @Bean @Order(0) - MeterFilter metricsHttpServerUriTagFilter(MetricsProperties metricsProperties, - ObservationProperties observationProperties) { - String name = httpRequestsMetricName(observationProperties, metricsProperties); + MeterFilter metricsHttpServerUriTagFilter(ObservationProperties observationProperties, + MetricsProperties metricsProperties) { + String name = observationProperties.getHttp().getServer().getRequests().getName(); MeterFilter filter = new OnlyOnceLoggingDenyMeterFilter( () -> String.format("Reached the maximum number of URI tags for '%s'.", name)); return MeterFilter.maximumAllowableTags(name, "uri", metricsProperties.getWeb().getServer().getMaxUriTags(), diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 9fb2160d5b2..bd717a474b5 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1980,11 +1980,19 @@ "reason": "Should be applied at the ObservationRegistry level." } }, + { + "name": "management.metrics.web.client.request.metric-name", + "type": "java.lang.String", + "deprecation": { + "replacement": "management.observations.http.client.requests.name", + "level": "error" + } + }, { "name": "management.metrics.web.client.requests-metric-name", "type": "java.lang.String", "deprecation": { - "replacement": "management.metrics.web.client.request.metric-name", + "replacement": "management.observations.http.client.requests.name", "level": "error" } }, @@ -2030,11 +2038,19 @@ "reason": "Not needed anymore, direct instrumentation in Spring MVC." } }, + { + "name": "management.metrics.web.server.request.metric-name", + "type": "java.lang.String", + "deprecation": { + "replacement": "management.observations.http.server.requests.name", + "level": "error" + } + }, { "name": "management.metrics.web.server.requests-metric-name", "type": "java.lang.String", "deprecation": { - "replacement": "management.metrics.web.server.request.metric-name", + "replacement": "management.observations.http.server.requests.name", "level": "error" } }, diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/CompositeHealthContributorConfigurationReflectionTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/CompositeHealthContributorConfigurationReflectionTests.java deleted file mode 100644 index c6100f971b7..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/CompositeHealthContributorConfigurationReflectionTests.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.health; - -import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfigurationReflectionTests.TestHealthIndicator; -import org.springframework.boot.actuate.health.AbstractHealthIndicator; -import org.springframework.boot.actuate.health.Health.Builder; -import org.springframework.boot.actuate.health.HealthContributor; - -/** - * Tests for {@link CompositeHealthContributorConfiguration} using reflection to create - * indicator instances. - * - * @author Phillip Webb - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class CompositeHealthContributorConfigurationReflectionTests - extends AbstractCompositeHealthContributorConfigurationTests { - - @Override - protected AbstractCompositeHealthContributorConfiguration newComposite() { - return new ReflectiveTestCompositeHealthContributorConfiguration(); - } - - static class ReflectiveTestCompositeHealthContributorConfiguration - extends CompositeHealthContributorConfiguration { - - } - - static class TestHealthIndicator extends AbstractHealthIndicator { - - TestHealthIndicator(TestBean testBean) { - } - - @Override - protected void doHealthCheck(Builder builder) throws Exception { - builder.up(); - } - - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthContributorConfigurationReflectionTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthContributorConfigurationReflectionTests.java deleted file mode 100644 index 183a3c7bd3a..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/CompositeReactiveHealthContributorConfigurationReflectionTests.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.health; - -import reactor.core.publisher.Mono; - -import org.springframework.boot.actuate.autoconfigure.health.CompositeReactiveHealthContributorConfigurationReflectionTests.TestReactiveHealthIndicator; -import org.springframework.boot.actuate.health.AbstractReactiveHealthIndicator; -import org.springframework.boot.actuate.health.Health; -import org.springframework.boot.actuate.health.Health.Builder; -import org.springframework.boot.actuate.health.ReactiveHealthContributor; - -/** - * Tests for {@link CompositeReactiveHealthContributorConfiguration} using reflection to - * create indicator instances. - * - * @author Phillip Webb - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class CompositeReactiveHealthContributorConfigurationReflectionTests extends - AbstractCompositeHealthContributorConfigurationTests { - - @Override - protected AbstractCompositeHealthContributorConfiguration newComposite() { - return new TestCompositeReactiveHealthContributorConfiguration(); - } - - static class TestCompositeReactiveHealthContributorConfiguration - extends CompositeReactiveHealthContributorConfiguration { - - } - - static class TestReactiveHealthIndicator extends AbstractReactiveHealthIndicator { - - TestReactiveHealthIndicator(TestBean testBean) { - } - - @Override - protected Mono doHealthCheck(Builder builder) { - return Mono.just(builder.up().build()); - } - - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientHttpObservationConventionAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientHttpObservationConventionAdapterTests.java deleted file mode 100644 index 814e71a4c72..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientHttpObservationConventionAdapterTests.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.observation.web.client; - -import java.net.URI; - -import io.micrometer.common.KeyValue; -import io.micrometer.observation.Observation; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.metrics.web.client.DefaultRestTemplateExchangeTagsProvider; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.client.ClientHttpRequest; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.http.client.observation.ClientRequestObservationContext; -import org.springframework.mock.http.client.MockClientHttpRequest; -import org.springframework.mock.http.client.MockClientHttpResponse; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link ClientHttpObservationConventionAdapter}. - * - * @author Brian Clozel - */ -@SuppressWarnings({ "deprecation", "removal" }) -class ClientHttpObservationConventionAdapterTests { - - private static final String TEST_METRIC_NAME = "test.metric.name"; - - private final ClientHttpObservationConventionAdapter convention = new ClientHttpObservationConventionAdapter( - TEST_METRIC_NAME, new DefaultRestTemplateExchangeTagsProvider()); - - private final ClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("/resource/test")); - - private final ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.OK); - - private ClientRequestObservationContext context; - - @BeforeEach - void setup() { - this.context = new ClientRequestObservationContext(this.request); - this.context.setResponse(this.response); - this.context.setUriTemplate("/resource/{name}"); - } - - @Test - void shouldUseConfiguredName() { - assertThat(this.convention.getName()).isEqualTo(TEST_METRIC_NAME); - } - - @Test - void shouldOnlySupportClientHttpObservationContext() { - assertThat(this.convention.supportsContext(this.context)).isTrue(); - assertThat(this.convention.supportsContext(new OtherContext())).isFalse(); - } - - @Test - void shouldPushTagsAsLowCardinalityKeyValues() { - assertThat(this.convention.getLowCardinalityKeyValues(this.context)).contains(KeyValue.of("status", "200"), - KeyValue.of("outcome", "SUCCESS"), KeyValue.of("uri", "/resource/{name}"), - KeyValue.of("method", "GET")); - } - - @Test - void shouldNotPushAnyHighCardinalityKeyValue() { - assertThat(this.convention.getHighCardinalityKeyValues(this.context)).isEmpty(); - } - - static class OtherContext extends Observation.Context { - - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapterTests.java deleted file mode 100644 index cd73e29efba..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/ClientObservationConventionAdapterTests.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2012-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.observation.web.client; - -import java.net.URI; - -import io.micrometer.common.KeyValue; -import io.micrometer.observation.Observation; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.metrics.web.reactive.client.DefaultWebClientExchangeTagsProvider; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.web.reactive.function.client.ClientRequest; -import org.springframework.web.reactive.function.client.ClientRequestObservationContext; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.WebClient; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link ClientObservationConventionAdapter}. - * - * @author Brian Clozel - */ -@SuppressWarnings({ "deprecation", "removal" }) -class ClientObservationConventionAdapterTests { - - private static final String TEST_METRIC_NAME = "test.metric.name"; - - private final ClientObservationConventionAdapter convention = new ClientObservationConventionAdapter( - TEST_METRIC_NAME, new DefaultWebClientExchangeTagsProvider()); - - private final ClientRequest.Builder requestBuilder = ClientRequest - .create(HttpMethod.GET, URI.create("/resource/test")) - .attribute(WebClient.class.getName() + ".uriTemplate", "/resource/{name}"); - - private final ClientResponse response = ClientResponse.create(HttpStatus.OK).body("foo").build(); - - private ClientRequestObservationContext context; - - @BeforeEach - void setup() { - this.context = new ClientRequestObservationContext(); - this.context.setCarrier(this.requestBuilder); - this.context.setResponse(this.response); - this.context.setUriTemplate("/resource/{name}"); - } - - @Test - void shouldUseConfiguredName() { - assertThat(this.convention.getName()).isEqualTo(TEST_METRIC_NAME); - } - - @Test - void shouldOnlySupportClientObservationContext() { - assertThat(this.convention.supportsContext(this.context)).isTrue(); - assertThat(this.convention.supportsContext(new OtherContext())).isFalse(); - } - - @Test - void shouldPushTagsAsLowCardinalityKeyValues() { - this.context.setRequest(this.requestBuilder.build()); - assertThat(this.convention.getLowCardinalityKeyValues(this.context)).contains(KeyValue.of("status", "200"), - KeyValue.of("outcome", "SUCCESS"), KeyValue.of("uri", "/resource/{name}"), - KeyValue.of("method", "GET")); - } - - @Test - void doesNotFailWithEmptyRequest() { - assertThat(this.convention.getLowCardinalityKeyValues(this.context)).contains(KeyValue.of("status", "200"), - KeyValue.of("outcome", "SUCCESS"), KeyValue.of("uri", "/resource/{name}"), - KeyValue.of("method", "GET")); - } - - @Test - void shouldNotPushAnyHighCardinalityKeyValue() { - assertThat(this.convention.getHighCardinalityKeyValues(this.context)).isEmpty(); - } - - static class OtherContext extends Observation.Context { - - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationTests.java index 6116649a14d..92b4367cad0 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/RestTemplateObservationConfigurationTests.java @@ -18,8 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.observation.web.client; import io.micrometer.common.KeyValues; import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.Tag; -import io.micrometer.core.instrument.Tags; import io.micrometer.observation.ObservationRegistry; import io.micrometer.observation.tck.TestObservationRegistry; import io.micrometer.observation.tck.TestObservationRegistryAssert; @@ -28,9 +26,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; -import org.springframework.boot.actuate.metrics.web.client.DefaultRestTemplateExchangeTagsProvider; import org.springframework.boot.actuate.metrics.web.client.ObservationRestTemplateCustomizer; -import org.springframework.boot.actuate.metrics.web.client.RestTemplateExchangeTagsProvider; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; @@ -40,9 +36,7 @@ import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpRequest; import org.springframework.http.HttpStatus; -import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.observation.ClientRequestObservationContext; import org.springframework.http.client.observation.DefaultClientRequestObservationConvention; import org.springframework.test.web.client.MockRestServiceServer; @@ -58,7 +52,6 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat * @author Brian Clozel */ @ExtendWith(OutputCaptureExtension.class) -@SuppressWarnings("removal") class RestTemplateObservationConfigurationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() @@ -68,8 +61,7 @@ class RestTemplateObservationConfigurationTests { @Test void contributesCustomizerBean() { - this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ObservationRestTemplateCustomizer.class) - .doesNotHaveBean(DefaultRestTemplateExchangeTagsProvider.class)); + this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ObservationRestTemplateCustomizer.class)); } @Test @@ -96,32 +88,6 @@ class RestTemplateObservationConfigurationTests { }); } - @Test - void restTemplateCreatedWithBuilderUsesCustomMetricName() { - final String metricName = "test.metric.name"; - this.contextRunner.withPropertyValues("management.metrics.web.client.request.metric-name=" + metricName) - .run((context) -> { - RestTemplate restTemplate = buildRestTemplate(context); - restTemplate.getForEntity("/projects/{project}", Void.class, "spring-boot"); - TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualToIgnoringCase(metricName); - }); - } - - @Test - void restTemplateCreatedWithBuilderUsesCustomTagsProvider() { - this.contextRunner.withUserConfiguration(CustomTagsConfiguration.class).run((context) -> { - RestTemplate restTemplate = buildRestTemplate(context); - restTemplate.getForEntity("/projects/{project}", Void.class, "spring-boot"); - TestObservationRegistry registry = context.getBean(TestObservationRegistry.class); - TestObservationRegistryAssert.assertThat(registry) - .hasObservationWithNameEqualTo("http.client.requests") - .that() - .hasLowCardinalityKeyValue("project", "spring-boot"); - }); - } - @Test void restTemplateCreatedWithBuilderUsesCustomConvention() { this.contextRunner.withUserConfiguration(CustomConvention.class).run((context) -> { @@ -163,8 +129,7 @@ class RestTemplateObservationConfigurationTests { new ApplicationContextRunner().with(MetricsRun.simple()) .withConfiguration(AutoConfigurations.of(ObservationAutoConfiguration.class, HttpClientObservationsAutoConfiguration.class)) - .run((context) -> assertThat(context).doesNotHaveBean(DefaultRestTemplateExchangeTagsProvider.class) - .doesNotHaveBean(ObservationRestTemplateCustomizer.class)); + .run((context) -> assertThat(context).doesNotHaveBean(ObservationRestTemplateCustomizer.class)); } private RestTemplate buildRestTemplate(AssertableApplicationContext context) { @@ -174,26 +139,6 @@ class RestTemplateObservationConfigurationTests { return restTemplate; } - @Configuration(proxyBeanMethods = false) - static class CustomTagsConfiguration { - - @Bean - CustomTagsProvider customTagsProvider() { - return new CustomTagsProvider(); - } - - } - - @Deprecated(since = "3.0.0", forRemoval = true) - static class CustomTagsProvider implements RestTemplateExchangeTagsProvider { - - @Override - public Iterable getTags(String urlTemplate, HttpRequest request, ClientHttpResponse response) { - return Tags.of("project", "spring-boot"); - } - - } - @Configuration(proxyBeanMethods = false) static class CustomConventionConfiguration { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfigurationTests.java index 9a94712edc7..8a917298b0e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/client/WebClientObservationConfigurationTests.java @@ -29,9 +29,7 @@ import reactor.core.publisher.Mono; import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; -import org.springframework.boot.actuate.metrics.web.reactive.client.DefaultWebClientExchangeTagsProvider; import org.springframework.boot.actuate.metrics.web.reactive.client.ObservationWebClientCustomizer; -import org.springframework.boot.actuate.metrics.web.reactive.client.WebClientExchangeTagsProvider; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; @@ -59,7 +57,6 @@ import static org.mockito.Mockito.mock; * @author Stephane Nicoll */ @ExtendWith(OutputCaptureExtension.class) -@SuppressWarnings("removal") class WebClientObservationConfigurationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple()) @@ -69,8 +66,7 @@ class WebClientObservationConfigurationTests { @Test void contributesCustomizerBean() { - this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ObservationWebClientCustomizer.class) - .doesNotHaveBean(DefaultWebClientExchangeTagsProvider.class)); + this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ObservationWebClientCustomizer.class)); } @Test @@ -82,14 +78,6 @@ class WebClientObservationConfigurationTests { }); } - @Test - void shouldNotOverrideCustomTagsProvider() { - this.contextRunner.withUserConfiguration(CustomTagsProviderConfig.class) - .run((context) -> assertThat(context).getBeans(WebClientExchangeTagsProvider.class) - .hasSize(1) - .containsKey("customTagsProvider")); - } - @Test void shouldUseCustomConventionIfAvailable() { this.contextRunner.withUserConfiguration(CustomConvention.class).run((context) -> { @@ -170,16 +158,6 @@ class WebClientObservationConfigurationTests { return builder.clientConnector(connector).build(); } - @Configuration(proxyBeanMethods = false) - static class CustomTagsProviderConfig { - - @Bean - WebClientExchangeTagsProvider customTagsProvider() { - return mock(WebClientExchangeTagsProvider.class); - } - - } - @Configuration(proxyBeanMethods = false) static class CustomConventionConfig { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapterTests.java deleted file mode 100644 index 9d32817dc80..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/ServerRequestObservationConventionAdapterTests.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.observation.web.reactive; - -import java.util.Map; - -import io.micrometer.common.KeyValue; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.metrics.web.reactive.server.DefaultWebFluxTagsProvider; -import org.springframework.http.server.reactive.observation.ServerRequestObservationContext; -import org.springframework.mock.http.server.reactive.MockServerHttpRequest; -import org.springframework.mock.http.server.reactive.MockServerHttpResponse; -import org.springframework.web.reactive.HandlerMapping; -import org.springframework.web.util.pattern.PathPatternParser; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link ServerRequestObservationConventionAdapter}. - * - * @author Brian Clozel - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class ServerRequestObservationConventionAdapterTests { - - private static final String TEST_METRIC_NAME = "test.metric.name"; - - private final ServerRequestObservationConventionAdapter convention = new ServerRequestObservationConventionAdapter( - TEST_METRIC_NAME, new DefaultWebFluxTagsProvider()); - - @Test - void shouldUseConfiguredName() { - assertThat(this.convention.getName()).isEqualTo(TEST_METRIC_NAME); - } - - @Test - void shouldPushTagsAsLowCardinalityKeyValues() { - MockServerHttpRequest request = MockServerHttpRequest.get("/resource/test").build(); - MockServerHttpResponse response = new MockServerHttpResponse(); - ServerRequestObservationContext context = new ServerRequestObservationContext(request, response, - Map.of(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, - PathPatternParser.defaultInstance.parse("/resource/{name}"))); - assertThat(this.convention.getLowCardinalityKeyValues(context)).contains(KeyValue.of("status", "200"), - KeyValue.of("outcome", "SUCCESS"), KeyValue.of("uri", "/resource/{name}"), - KeyValue.of("method", "GET")); - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/WebFluxObservationAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/WebFluxObservationAutoConfigurationTests.java index d8197198eb4..939b754424a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/WebFluxObservationAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/reactive/WebFluxObservationAutoConfigurationTests.java @@ -19,8 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.observation.web.reactive; import java.util.List; import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.Tag; -import io.micrometer.core.instrument.Tags; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import reactor.core.publisher.Mono; @@ -29,9 +27,6 @@ import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfigu import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.metrics.web.TestController; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; -import org.springframework.boot.actuate.metrics.web.reactive.server.DefaultWebFluxTagsProvider; -import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsContributor; -import org.springframework.boot.actuate.metrics.web.reactive.server.WebFluxTagsProvider; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration; import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext; @@ -83,28 +78,6 @@ class WebFluxObservationAutoConfigurationTests { }); } - @Test - void shouldUseConventionAdapterWhenCustomTagsProvider() { - this.contextRunner.withUserConfiguration(CustomTagsProviderConfiguration.class).run((context) -> { - assertThat(context).hasSingleBean(ServerHttpObservationFilter.class); - assertThat(context).hasSingleBean(WebFluxTagsProvider.class); - assertThat(context).getBean(ServerHttpObservationFilter.class) - .extracting("observationConvention") - .isInstanceOf(ServerRequestObservationConventionAdapter.class); - }); - } - - @Test - void shouldUseConventionAdapterWhenCustomTagsContributor() { - this.contextRunner.withUserConfiguration(CustomTagsContributorConfiguration.class).run((context) -> { - assertThat(context).hasSingleBean(ServerHttpObservationFilter.class); - assertThat(context).hasSingleBean(WebFluxTagsContributor.class); - assertThat(context).getBean(ServerHttpObservationFilter.class) - .extracting("observationConvention") - .isInstanceOf(ServerRequestObservationConventionAdapter.class); - }); - } - @Test void shouldUseCustomConventionWhenAvailable() { this.contextRunner.withUserConfiguration(CustomConventionConfiguration.class).run((context) -> { @@ -128,21 +101,6 @@ class WebFluxObservationAutoConfigurationTests { }); } - @Test - @Deprecated(since = "3.0.0", forRemoval = true) - void afterMaxUrisReachedFurtherUrisAreDeniedWhenUsingCustomMetricName(CapturedOutput output) { - this.contextRunner.withUserConfiguration(TestController.class) - .withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class, ObservationAutoConfiguration.class, - WebFluxAutoConfiguration.class)) - .withPropertyValues("management.metrics.web.server.max-uri-tags=2", - "management.metrics.web.server.request.metric-name=my.http.server.requests") - .run((context) -> { - MeterRegistry registry = getInitializedMeterRegistry(context); - assertThat(registry.get("my.http.server.requests").meters()).hasSizeLessThanOrEqualTo(2); - assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'"); - }); - } - @Test void afterMaxUrisReachedFurtherUrisAreDeniedWhenUsingCustomObservationName(CapturedOutput output) { this.contextRunner.withUserConfiguration(TestController.class) @@ -194,37 +152,6 @@ class WebFluxObservationAutoConfigurationTests { return context.getBean(MeterRegistry.class); } - @Deprecated(since = "3.0.0", forRemoval = true) - @Configuration(proxyBeanMethods = false) - static class CustomTagsProviderConfiguration { - - @Bean - WebFluxTagsProvider tagsProvider() { - return new DefaultWebFluxTagsProvider(); - } - - } - - @Configuration(proxyBeanMethods = false) - static class CustomTagsContributorConfiguration { - - @Bean - WebFluxTagsContributor tagsContributor() { - return new CustomTagsContributor(); - } - - } - - @Deprecated(since = "3.0.0", forRemoval = true) - static class CustomTagsContributor implements WebFluxTagsContributor { - - @Override - public Iterable httpRequestTags(ServerWebExchange exchange, Throwable ex) { - return Tags.of("custom", "testvalue"); - } - - } - @Configuration(proxyBeanMethods = false) static class CustomConventionConfiguration { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapterTests.java deleted file mode 100644 index 9705829af33..00000000000 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/ServerRequestObservationConventionAdapterTests.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.autoconfigure.observation.web.servlet; - -import java.util.Collections; -import java.util.List; - -import io.micrometer.common.KeyValue; -import io.micrometer.core.instrument.Tag; -import io.micrometer.core.instrument.Tags; -import io.micrometer.observation.Observation; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.metrics.web.servlet.DefaultWebMvcTagsProvider; -import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor; -import org.springframework.http.server.observation.ServerRequestObservationContext; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.web.servlet.HandlerMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link ServerRequestObservationConventionAdapter} - * - * @author Brian Clozel - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class ServerRequestObservationConventionAdapterTests { - - private static final String TEST_METRIC_NAME = "test.metric.name"; - - private final ServerRequestObservationConventionAdapter convention = new ServerRequestObservationConventionAdapter( - TEST_METRIC_NAME, new DefaultWebMvcTagsProvider(), Collections.emptyList()); - - private final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/resource/test"); - - private final MockHttpServletResponse response = new MockHttpServletResponse(); - - private final ServerRequestObservationContext context = new ServerRequestObservationContext(this.request, - this.response); - - @Test - void customNameIsUsed() { - assertThat(this.convention.getName()).isEqualTo(TEST_METRIC_NAME); - } - - @Test - void onlySupportServerRequestObservationContext() { - assertThat(this.convention.supportsContext(this.context)).isTrue(); - assertThat(this.convention.supportsContext(new OtherContext())).isFalse(); - } - - @Test - void pushTagsAsLowCardinalityKeyValues() { - this.request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "/resource/{name}"); - this.context.setPathPattern("/resource/{name}"); - assertThat(this.convention.getLowCardinalityKeyValues(this.context)).contains(KeyValue.of("status", "200"), - KeyValue.of("outcome", "SUCCESS"), KeyValue.of("uri", "/resource/{name}"), - KeyValue.of("method", "GET")); - } - - @Test - void doesNotPushAnyHighCardinalityKeyValue() { - assertThat(this.convention.getHighCardinalityKeyValues(this.context)).isEmpty(); - } - - @Test - void pushTagsFromContributors() { - ServerRequestObservationConventionAdapter convention = new ServerRequestObservationConventionAdapter( - TEST_METRIC_NAME, null, List.of(new CustomWebMvcContributor())); - assertThat(convention.getLowCardinalityKeyValues(this.context)).contains(KeyValue.of("custom", "value")); - } - - static class OtherContext extends Observation.Context { - - } - - static class CustomWebMvcContributor implements WebMvcTagsContributor { - - @Override - public Iterable getTags(HttpServletRequest request, HttpServletResponse response, Object handler, - Throwable exception) { - return Tags.of("custom", "value"); - } - - @Override - public Iterable getLongRequestTags(HttpServletRequest request, Object handler) { - return Collections.emptyList(); - } - - } - -} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/WebMvcObservationAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/WebMvcObservationAutoConfigurationTests.java index 7328d40b2b5..b996ba20643 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/WebMvcObservationAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/observation/web/servlet/WebMvcObservationAutoConfigurationTests.java @@ -16,16 +16,12 @@ package org.springframework.boot.actuate.autoconfigure.observation.web.servlet; -import java.util.Collections; import java.util.EnumSet; import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.Tag; import io.micrometer.observation.tck.TestObservationRegistry; import jakarta.servlet.DispatcherType; import jakarta.servlet.Filter; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -33,9 +29,6 @@ import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfigu import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.metrics.web.TestController; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; -import org.springframework.boot.actuate.metrics.web.servlet.DefaultWebMvcTagsProvider; -import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor; -import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsProvider; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext; @@ -67,7 +60,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * @author Moritz Halbritter */ @ExtendWith(OutputCaptureExtension.class) -@SuppressWarnings("removal") class WebMvcObservationAutoConfigurationTests { private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() @@ -85,21 +77,12 @@ class WebMvcObservationAutoConfigurationTests { @Test void definesFilterWhenRegistryIsPresent() { this.contextRunner.run((context) -> { - assertThat(context).doesNotHaveBean(DefaultWebMvcTagsProvider.class); assertThat(context).hasSingleBean(FilterRegistrationBean.class); assertThat(context.getBean(FilterRegistrationBean.class).getFilter()) .isInstanceOf(ServerHttpObservationFilter.class); }); } - @Test - void adapterConventionWhenTagsProviderPresent() { - this.contextRunner.withUserConfiguration(TagsProviderConfiguration.class) - .run((context) -> assertThat(context.getBean(FilterRegistrationBean.class).getFilter()) - .extracting("observationConvention") - .isInstanceOf(ServerRequestObservationConventionAdapter.class)); - } - @Test void customConventionWhenPresent() { this.contextRunner.withUserConfiguration(CustomConventionConfiguration.class) @@ -169,21 +152,6 @@ class WebMvcObservationAutoConfigurationTests { }); } - @Test - @Deprecated(since = "3.0.0", forRemoval = true) - void afterMaxUrisReachedFurtherUrisAreDeniedWhenUsingCustomMetricName(CapturedOutput output) { - this.contextRunner.withUserConfiguration(TestController.class) - .withConfiguration(AutoConfigurations.of(MetricsAutoConfiguration.class, ObservationAutoConfiguration.class, - WebMvcAutoConfiguration.class)) - .withPropertyValues("management.metrics.web.server.max-uri-tags=2", - "management.metrics.web.server.request.metric-name=my.http.server.requests") - .run((context) -> { - MeterRegistry registry = getInitializedMeterRegistry(context); - assertThat(registry.get("my.http.server.requests").meters()).hasSizeLessThanOrEqualTo(2); - assertThat(output).contains("Reached the maximum number of URI tags for 'my.http.server.requests'"); - }); - } - @Test void afterMaxUrisReachedFurtherUrisAreDeniedWhenUsingCustomObservationName(CapturedOutput output) { this.contextRunner.withUserConfiguration(TestController.class) @@ -211,14 +179,6 @@ class WebMvcObservationAutoConfigurationTests { }); } - @Test - void whenTagContributorsAreDefinedThenTagsProviderUsesThem() { - this.contextRunner.withUserConfiguration(TagsContributorsConfiguration.class) - .run((context) -> assertThat(context.getBean(FilterRegistrationBean.class).getFilter()) - .extracting("observationConvention") - .isInstanceOf(ServerRequestObservationConventionAdapter.class)); - } - private MeterRegistry getInitializedMeterRegistry(AssertableWebApplicationContext context) throws Exception { return getInitializedMeterRegistry(context, "/test0", "/test1", "/test2"); } @@ -235,47 +195,6 @@ class WebMvcObservationAutoConfigurationTests { return context.getBean(MeterRegistry.class); } - @Configuration(proxyBeanMethods = false) - static class TagsProviderConfiguration { - - @Bean - TestWebMvcTagsProvider tagsProvider() { - return new TestWebMvcTagsProvider(); - } - - } - - @Configuration(proxyBeanMethods = false) - static class TagsContributorsConfiguration { - - @Bean - WebMvcTagsContributor tagContributorOne() { - return mock(WebMvcTagsContributor.class); - } - - @Bean - WebMvcTagsContributor tagContributorTwo() { - return mock(WebMvcTagsContributor.class); - } - - } - - @Deprecated(since = "3.0.0", forRemoval = true) - private static final class TestWebMvcTagsProvider implements WebMvcTagsProvider { - - @Override - public Iterable getTags(HttpServletRequest request, HttpServletResponse response, Object handler, - Throwable exception) { - return Collections.emptyList(); - } - - @Override - public Iterable getLongRequestTags(HttpServletRequest request, Object handler) { - return Collections.emptyList(); - } - - } - @Configuration(proxyBeanMethods = false) static class TestServerHttpObservationFilterRegistrationConfiguration { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManager.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManager.java index f0a3453e70e..da459eb0c28 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManager.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManager.java @@ -141,7 +141,7 @@ public class PrometheusPushGatewayManager { } this.scheduled.cancel(false); switch (shutdownOperation) { - case PUSH, POST -> post(); + case POST -> post(); case PUT -> put(); case DELETE -> delete(); } @@ -162,13 +162,6 @@ public class PrometheusPushGatewayManager { */ POST, - /** - * Perform a POST before shutdown. - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of {@link #POST}. - */ - @Deprecated(since = "3.0.0", forRemoval = true) - PUSH, - /** * Perform a PUT before shutdown. */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/DefaultRestTemplateExchangeTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/DefaultRestTemplateExchangeTagsProvider.java deleted file mode 100644 index ace3689e686..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/DefaultRestTemplateExchangeTagsProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.client; - -import java.util.Arrays; - -import io.micrometer.core.instrument.Tag; - -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.util.StringUtils; - -/** - * Default implementation of {@link RestTemplateExchangeTagsProvider}. - * - * @author Jon Schneider - * @author Nishant Raut - * @since 2.0.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.http.client.observation.DefaultClientRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -@SuppressWarnings("removal") -public class DefaultRestTemplateExchangeTagsProvider implements RestTemplateExchangeTagsProvider { - - @Override - public Iterable getTags(String urlTemplate, HttpRequest request, ClientHttpResponse response) { - Tag uriTag = (StringUtils.hasText(urlTemplate) ? RestTemplateExchangeTags.uri(urlTemplate) - : RestTemplateExchangeTags.uri(request)); - return Arrays.asList(RestTemplateExchangeTags.method(request), uriTag, - RestTemplateExchangeTags.status(response), RestTemplateExchangeTags.clientName(request), - RestTemplateExchangeTags.outcome(response)); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java deleted file mode 100644 index 5f17ee3d4f4..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.client; - -import java.io.IOException; -import java.net.URI; -import java.util.regex.Pattern; - -import io.micrometer.core.instrument.Tag; - -import org.springframework.boot.actuate.metrics.http.Outcome; -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.http.client.observation.DefaultClientRequestObservationConvention; -import org.springframework.util.StringUtils; -import org.springframework.web.client.RestTemplate; - -/** - * Factory methods for creating {@link Tag Tags} related to a request-response exchange - * performed by a {@link RestTemplate}. - * - * @author Andy Wilkinson - * @author Jon Schneider - * @author Nishant Raut - * @author Brian Clozel - * @since 2.0.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link DefaultClientRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -public final class RestTemplateExchangeTags { - - private static final Pattern STRIP_URI_PATTERN = Pattern.compile("^https?://[^/]+/"); - - private RestTemplateExchangeTags() { - } - - /** - * Creates a {@code method} {@code Tag} for the {@link HttpRequest#getMethod() method} - * of the given {@code request}. - * @param request the request - * @return the method tag - */ - public static Tag method(HttpRequest request) { - return Tag.of("method", request.getMethod().name()); - } - - /** - * Creates a {@code uri} {@code Tag} for the URI of the given {@code request}. - * @param request the request - * @return the uri tag - */ - public static Tag uri(HttpRequest request) { - return Tag.of("uri", ensureLeadingSlash(stripUri(request.getURI().toString()))); - } - - /** - * Creates a {@code uri} {@code Tag} from the given {@code uriTemplate}. - * @param uriTemplate the template - * @return the uri tag - */ - public static Tag uri(String uriTemplate) { - String uri = (StringUtils.hasText(uriTemplate) ? uriTemplate : "none"); - return Tag.of("uri", ensureLeadingSlash(stripUri(uri))); - } - - private static String stripUri(String uri) { - return STRIP_URI_PATTERN.matcher(uri).replaceAll(""); - } - - private static String ensureLeadingSlash(String url) { - return (url == null || url.startsWith("/")) ? url : "/" + url; - } - - /** - * Creates a {@code status} {@code Tag} derived from the - * {@link ClientHttpResponse#getStatusCode() status} of the given {@code response}. - * @param response the response - * @return the status tag - */ - public static Tag status(ClientHttpResponse response) { - return Tag.of("status", getStatusMessage(response)); - } - - private static String getStatusMessage(ClientHttpResponse response) { - try { - if (response == null) { - return "CLIENT_ERROR"; - } - return String.valueOf(response.getStatusCode().value()); - } - catch (IOException ex) { - return "IO_ERROR"; - } - } - - /** - * Create a {@code client.name} {@code Tag} derived from the {@link URI#getHost host} - * of the {@link HttpRequest#getURI() URI} of the given {@code request}. - * @param request the request - * @return the client.name tag - */ - public static Tag clientName(HttpRequest request) { - String host = request.getURI().getHost(); - if (host == null) { - host = "none"; - } - return Tag.of("client.name", host); - } - - /** - * Creates an {@code outcome} {@code Tag} derived from the - * {@link ClientHttpResponse#getStatusCode() status} of the given {@code response}. - * @param response the response - * @return the outcome tag - * @since 2.2.0 - */ - public static Tag outcome(ClientHttpResponse response) { - try { - if (response != null) { - return Outcome.forStatus(response.getStatusCode().value()).asTag(); - } - } - catch (IOException ex) { - // Continue - } - return Outcome.UNKNOWN.asTag(); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTagsProvider.java deleted file mode 100644 index ea3c05360ce..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTagsProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.client; - -import io.micrometer.core.instrument.Tag; - -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.http.client.observation.ClientRequestObservationConvention; -import org.springframework.web.client.RestTemplate; - -/** - * Provides {@link Tag Tags} for an exchange performed by a {@link RestTemplate}. - * - * @author Jon Schneider - * @author Andy Wilkinson - * @since 2.0.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link ClientRequestObservationConvention} - */ -@FunctionalInterface -@Deprecated(since = "3.0.0", forRemoval = true) -public interface RestTemplateExchangeTagsProvider { - - /** - * Provides the tags to be associated with metrics that are recorded for the given - * {@code request} and {@code response} exchange. - * @param urlTemplate the source URl template, if available - * @param request the request - * @param response the response (may be {@code null} if the exchange failed) - * @return the tags - */ - Iterable getTags(String urlTemplate, HttpRequest request, ClientHttpResponse response); - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProvider.java deleted file mode 100644 index aeae3222d5a..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.client; - -import java.util.Arrays; - -import io.micrometer.core.instrument.Tag; - -import org.springframework.web.reactive.function.client.ClientRequest; -import org.springframework.web.reactive.function.client.ClientResponse; - -/** - * Default implementation of {@link WebClientExchangeTagsProvider}. - * - * @author Brian Clozel - * @author Nishant Raut - * @since 2.1.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.web.reactive.function.client.ClientRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -@SuppressWarnings("removal") -public class DefaultWebClientExchangeTagsProvider implements WebClientExchangeTagsProvider { - - @Override - public Iterable tags(ClientRequest request, ClientResponse response, Throwable throwable) { - Tag method = WebClientExchangeTags.method(request); - Tag uri = WebClientExchangeTags.uri(request); - Tag clientName = WebClientExchangeTags.clientName(request); - Tag status = WebClientExchangeTags.status(response, throwable); - Tag outcome = WebClientExchangeTags.outcome(response); - return Arrays.asList(method, uri, clientName, status, outcome); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java deleted file mode 100644 index c916188b684..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.client; - -import java.io.IOException; -import java.util.regex.Pattern; - -import io.micrometer.core.instrument.Tag; - -import org.springframework.boot.actuate.metrics.http.Outcome; -import org.springframework.http.client.reactive.ClientHttpRequest; -import org.springframework.web.reactive.function.client.ClientRequest; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * Factory methods for creating {@link Tag Tags} related to a request-response exchange - * performed by a {@link WebClient}. - * - * @author Brian Clozel - * @author Nishant Raut - * @since 2.1.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.web.reactive.function.client.DefaultClientRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -public final class WebClientExchangeTags { - - private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate"; - - private static final Tag IO_ERROR = Tag.of("status", "IO_ERROR"); - - private static final Tag CLIENT_ERROR = Tag.of("status", "CLIENT_ERROR"); - - private static final Pattern PATTERN_BEFORE_PATH = Pattern.compile("^https?://[^/]+/"); - - private static final Tag CLIENT_NAME_NONE = Tag.of("client.name", "none"); - - private WebClientExchangeTags() { - } - - /** - * Creates a {@code method} {@code Tag} for the {@link ClientHttpRequest#getMethod() - * method} of the given {@code request}. - * @param request the request - * @return the method tag - */ - public static Tag method(ClientRequest request) { - return Tag.of("method", request.method().name()); - } - - /** - * Creates a {@code uri} {@code Tag} for the URI path of the given {@code request}. - * @param request the request - * @return the uri tag - */ - public static Tag uri(ClientRequest request) { - String uri = (String) request.attribute(URI_TEMPLATE_ATTRIBUTE).orElseGet(() -> request.url().toString()); - return Tag.of("uri", extractPath(uri)); - } - - private static String extractPath(String url) { - String path = PATTERN_BEFORE_PATH.matcher(url).replaceFirst(""); - return (path.startsWith("/") ? path : "/" + path); - } - - /** - * Creates a {@code status} {@code Tag} derived from the - * {@link ClientResponse#statusCode()} of the given {@code response} if available, the - * thrown exception otherwise, or considers the request as Cancelled as a last resort. - * @param response the response - * @param throwable the exception - * @return the status tag - * @since 2.3.0 - */ - public static Tag status(ClientResponse response, Throwable throwable) { - if (response != null) { - return Tag.of("status", String.valueOf(response.statusCode().value())); - } - if (throwable != null) { - return (throwable instanceof IOException) ? IO_ERROR : CLIENT_ERROR; - } - return CLIENT_ERROR; - } - - /** - * Create a {@code client.name} {@code Tag} derived from the - * {@link java.net.URI#getHost host} of the {@link ClientRequest#url() URL} of the - * given {@code request}. - * @param request the request - * @return the client.name tag - */ - public static Tag clientName(ClientRequest request) { - String host = request.url().getHost(); - if (host == null) { - return CLIENT_NAME_NONE; - } - return Tag.of("client.name", host); - } - - /** - * Creates an {@code outcome} {@code Tag} derived from the - * {@link ClientResponse#statusCode() status} of the given {@code response}. - * @param response the response - * @return the outcome tag - * @since 2.2.0 - */ - public static Tag outcome(ClientResponse response) { - Outcome outcome = (response != null) ? Outcome.forStatus(response.statusCode().value()) : Outcome.UNKNOWN; - return outcome.asTag(); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsProvider.java deleted file mode 100644 index 7d522e48d2b..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.client; - -import io.micrometer.core.instrument.Tag; - -import org.springframework.web.reactive.function.client.ClientRequest; -import org.springframework.web.reactive.function.client.ClientResponse; - -/** - * {@link Tag Tags} provider for an exchange performed by a - * {@link org.springframework.web.reactive.function.client.WebClient}. - * - * @author Brian Clozel - * @since 2.1.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.web.reactive.function.client.ClientRequestObservationConvention} - */ -@FunctionalInterface -@Deprecated(since = "3.0.0", forRemoval = true) -public interface WebClientExchangeTagsProvider { - - /** - * Provide tags to be associated with metrics for the client exchange. - * @param request the client request - * @param response the server response (may be {@code null}) - * @param throwable the exception (may be {@code null}) - * @return tags to associate with metrics for the request and response exchange - */ - Iterable tags(ClientRequest request, ClientResponse response, Throwable throwable); - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProvider.java deleted file mode 100644 index ef319dc065a..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProvider.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.server; - -import java.util.Collections; -import java.util.List; - -import io.micrometer.core.instrument.Tag; -import io.micrometer.core.instrument.Tags; - -import org.springframework.web.server.ServerWebExchange; - -/** - * Default implementation of {@link WebFluxTagsProvider}. - * - * @author Jon Schneider - * @author Andy Wilkinson - * @since 2.0.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.http.server.reactive.observation.ServerRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -@SuppressWarnings("removal") -public class DefaultWebFluxTagsProvider implements WebFluxTagsProvider { - - private final boolean ignoreTrailingSlash; - - private final List contributors; - - public DefaultWebFluxTagsProvider() { - this(false); - } - - /** - * Creates a new {@link DefaultWebFluxTagsProvider} that will provide tags from the - * given {@code contributors} in addition to its own. - * @param contributors the contributors that will provide additional tags - * @since 2.3.0 - */ - public DefaultWebFluxTagsProvider(List contributors) { - this(false, contributors); - } - - public DefaultWebFluxTagsProvider(boolean ignoreTrailingSlash) { - this(ignoreTrailingSlash, Collections.emptyList()); - } - - /** - * Creates a new {@link DefaultWebFluxTagsProvider} that will provide tags from the - * given {@code contributors} in addition to its own. - * @param ignoreTrailingSlash whether trailing slashes should be ignored when - * determining the {@code uri} tag. - * @param contributors the contributors that will provide additional tags - * @since 2.3.0 - */ - public DefaultWebFluxTagsProvider(boolean ignoreTrailingSlash, List contributors) { - this.ignoreTrailingSlash = ignoreTrailingSlash; - this.contributors = contributors; - } - - @Override - public Iterable httpRequestTags(ServerWebExchange exchange, Throwable exception) { - Tags tags = Tags.empty(); - tags = tags.and(WebFluxTags.method(exchange)); - tags = tags.and(WebFluxTags.uri(exchange, this.ignoreTrailingSlash)); - tags = tags.and(WebFluxTags.exception(exception)); - tags = tags.and(WebFluxTags.status(exchange)); - tags = tags.and(WebFluxTags.outcome(exchange, exception)); - for (WebFluxTagsContributor contributor : this.contributors) { - tags = tags.and(contributor.httpRequestTags(exchange, exception)); - } - return tags; - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java deleted file mode 100644 index ecada43258a..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.server; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; -import java.util.regex.Pattern; - -import io.micrometer.core.instrument.Tag; - -import org.springframework.boot.actuate.metrics.http.Outcome; -import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; -import org.springframework.util.StringUtils; -import org.springframework.web.reactive.HandlerMapping; -import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.pattern.PathPattern; - -/** - * Factory methods for {@link Tag Tags} associated with a request-response exchange that - * is handled by WebFlux. - * - * @author Jon Schneider - * @author Andy Wilkinson - * @author Michael McFadyen - * @author Brian Clozel - * @since 2.0.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.http.server.reactive.observation.ServerRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -public final class WebFluxTags { - - private static final Tag URI_NOT_FOUND = Tag.of("uri", "NOT_FOUND"); - - private static final Tag URI_REDIRECTION = Tag.of("uri", "REDIRECTION"); - - private static final Tag URI_ROOT = Tag.of("uri", "root"); - - private static final Tag URI_UNKNOWN = Tag.of("uri", "UNKNOWN"); - - private static final Tag EXCEPTION_NONE = Tag.of("exception", "None"); - - private static final Pattern FORWARD_SLASHES_PATTERN = Pattern.compile("//+"); - - private static final Set DISCONNECTED_CLIENT_EXCEPTIONS = new HashSet<>( - Arrays.asList("AbortedException", "ClientAbortException", "EOFException", "EofException")); - - private WebFluxTags() { - } - - /** - * Creates a {@code method} tag based on the - * {@link org.springframework.http.server.reactive.ServerHttpRequest#getMethod() - * method} of the {@link ServerWebExchange#getRequest()} request of the given - * {@code exchange}. - * @param exchange the exchange - * @return the method tag whose value is a capitalized method (e.g. GET). - */ - public static Tag method(ServerWebExchange exchange) { - return Tag.of("method", exchange.getRequest().getMethod().name()); - } - - /** - * Creates a {@code status} tag based on the response status of the given - * {@code exchange}. - * @param exchange the exchange - * @return the status tag derived from the response status - */ - public static Tag status(ServerWebExchange exchange) { - HttpStatusCode status = exchange.getResponse().getStatusCode(); - if (status == null) { - status = HttpStatus.OK; - } - return Tag.of("status", String.valueOf(status.value())); - } - - /** - * Creates a {@code uri} tag based on the URI of the given {@code exchange}. Uses the - * {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern if - * available. Falling back to {@code REDIRECTION} for 3xx responses, {@code NOT_FOUND} - * for 404 responses, {@code root} for requests with no path info, and {@code UNKNOWN} - * for all other requests. - * @param exchange the exchange - * @return the uri tag derived from the exchange - */ - public static Tag uri(ServerWebExchange exchange) { - return uri(exchange, false); - } - - /** - * Creates a {@code uri} tag based on the URI of the given {@code exchange}. Uses the - * {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern if - * available. Falling back to {@code REDIRECTION} for 3xx responses, {@code NOT_FOUND} - * for 404 responses, {@code root} for requests with no path info, and {@code UNKNOWN} - * for all other requests. - * @param exchange the exchange - * @param ignoreTrailingSlash whether to ignore the trailing slash - * @return the uri tag derived from the exchange - */ - public static Tag uri(ServerWebExchange exchange, boolean ignoreTrailingSlash) { - PathPattern pathPattern = exchange.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); - if (pathPattern != null) { - String patternString = pathPattern.getPatternString(); - if (ignoreTrailingSlash && patternString.length() > 1) { - patternString = removeTrailingSlash(patternString); - } - if (patternString.isEmpty()) { - return URI_ROOT; - } - return Tag.of("uri", patternString); - } - HttpStatusCode status = exchange.getResponse().getStatusCode(); - if (status != null) { - if (status.is3xxRedirection()) { - return URI_REDIRECTION; - } - if (status == HttpStatus.NOT_FOUND) { - return URI_NOT_FOUND; - } - } - String path = getPathInfo(exchange); - if (path.isEmpty()) { - return URI_ROOT; - } - return URI_UNKNOWN; - } - - private static String getPathInfo(ServerWebExchange exchange) { - String path = exchange.getRequest().getPath().value(); - String uri = StringUtils.hasText(path) ? path : "/"; - String singleSlashes = FORWARD_SLASHES_PATTERN.matcher(uri).replaceAll("/"); - return removeTrailingSlash(singleSlashes); - } - - private static String removeTrailingSlash(String text) { - if (!StringUtils.hasLength(text)) { - return text; - } - return text.endsWith("/") ? text.substring(0, text.length() - 1) : text; - } - - /** - * Creates an {@code exception} tag based on the {@link Class#getSimpleName() simple - * name} of the class of the given {@code exception}. - * @param exception the exception, may be {@code null} - * @return the exception tag derived from the exception - */ - public static Tag exception(Throwable exception) { - if (exception != null) { - String simpleName = exception.getClass().getSimpleName(); - return Tag.of("exception", StringUtils.hasText(simpleName) ? simpleName : exception.getClass().getName()); - } - return EXCEPTION_NONE; - } - - /** - * Creates an {@code outcome} tag based on the response status of the given - * {@code exchange} and the exception thrown during request processing. - * @param exchange the exchange - * @param exception the termination signal sent by the publisher - * @return the outcome tag derived from the response status - * @since 2.5.0 - */ - public static Tag outcome(ServerWebExchange exchange, Throwable exception) { - if (exception != null) { - if (DISCONNECTED_CLIENT_EXCEPTIONS.contains(exception.getClass().getSimpleName())) { - return Outcome.UNKNOWN.asTag(); - } - } - HttpStatusCode statusCode = exchange.getResponse().getStatusCode(); - Outcome outcome = (statusCode != null) ? Outcome.forStatus(statusCode.value()) : Outcome.SUCCESS; - return outcome.asTag(); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsContributor.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsContributor.java deleted file mode 100644 index 6bd9958dfca..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsContributor.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.server; - -import io.micrometer.core.instrument.Tag; - -import org.springframework.web.server.ServerWebExchange; - -/** - * A contributor of {@link Tag Tags} for WebFlux-based request handling. Typically used by - * a {@link WebFluxTagsProvider} to provide tags in addition to its defaults. - * - * @author Andy Wilkinson - * @since 2.3.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.http.server.reactive.observation.ServerRequestObservationConvention} - */ -@FunctionalInterface -@Deprecated(since = "3.0.0", forRemoval = true) -public interface WebFluxTagsContributor { - - /** - * Provides tags to be associated with metrics for the given {@code exchange}. - * @param exchange the exchange - * @param ex the current exception (may be {@code null}) - * @return tags to associate with metrics for the request and response exchange - */ - Iterable httpRequestTags(ServerWebExchange exchange, Throwable ex); - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsProvider.java deleted file mode 100644 index 081c9598cc8..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.server; - -import io.micrometer.core.instrument.Tag; - -import org.springframework.web.server.ServerWebExchange; - -/** - * Provides {@link Tag Tags} for WebFlux-based request handling. - * - * @author Jon Schneider - * @author Andy Wilkinson - * @since 2.0.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.http.server.reactive.observation.ServerRequestObservationConvention} - */ -@FunctionalInterface -@Deprecated(since = "3.0.0", forRemoval = true) -public interface WebFluxTagsProvider { - - /** - * Provides tags to be associated with metrics for the given {@code exchange}. - * @param exchange the exchange - * @param ex the current exception (may be {@code null}) - * @return tags to associate with metrics for the request and response exchange - */ - Iterable httpRequestTags(ServerWebExchange exchange, Throwable ex); - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/package-info.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/package-info.java deleted file mode 100644 index 1167af5ca30..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012-2019 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Actuator support for WebFlux metrics. - */ -package org.springframework.boot.actuate.metrics.web.reactive.server; diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/DefaultWebMvcTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/DefaultWebMvcTagsProvider.java deleted file mode 100644 index ac50670ca32..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/DefaultWebMvcTagsProvider.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.servlet; - -import java.util.Collections; -import java.util.List; - -import io.micrometer.core.instrument.Tag; -import io.micrometer.core.instrument.Tags; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -/** - * Default implementation of {@link WebMvcTagsProvider}. - * - * @author Jon Schneider - * @since 2.0.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.http.server.observation.ServerRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -@SuppressWarnings("removal") -public class DefaultWebMvcTagsProvider implements WebMvcTagsProvider { - - private final boolean ignoreTrailingSlash; - - private final List contributors; - - public DefaultWebMvcTagsProvider() { - this(false); - } - - /** - * Creates a new {@link DefaultWebMvcTagsProvider} that will provide tags from the - * given {@code contributors} in addition to its own. - * @param contributors the contributors that will provide additional tags - * @since 2.3.0 - */ - public DefaultWebMvcTagsProvider(List contributors) { - this(false, contributors); - } - - public DefaultWebMvcTagsProvider(boolean ignoreTrailingSlash) { - this(ignoreTrailingSlash, Collections.emptyList()); - } - - /** - * Creates a new {@link DefaultWebMvcTagsProvider} that will provide tags from the - * given {@code contributors} in addition to its own. - * @param ignoreTrailingSlash whether trailing slashes should be ignored when - * determining the {@code uri} tag. - * @param contributors the contributors that will provide additional tags - * @since 2.3.0 - */ - public DefaultWebMvcTagsProvider(boolean ignoreTrailingSlash, List contributors) { - this.ignoreTrailingSlash = ignoreTrailingSlash; - this.contributors = contributors; - } - - @Override - public Iterable getTags(HttpServletRequest request, HttpServletResponse response, Object handler, - Throwable exception) { - Tags tags = Tags.of(WebMvcTags.method(request), WebMvcTags.uri(request, response, this.ignoreTrailingSlash), - WebMvcTags.exception(exception), WebMvcTags.status(response), WebMvcTags.outcome(response)); - for (WebMvcTagsContributor contributor : this.contributors) { - tags = tags.and(contributor.getTags(request, response, handler, exception)); - } - return tags; - } - - @Override - public Iterable getLongRequestTags(HttpServletRequest request, Object handler) { - Tags tags = Tags.of(WebMvcTags.method(request), WebMvcTags.uri(request, null, this.ignoreTrailingSlash)); - for (WebMvcTagsContributor contributor : this.contributors) { - tags = tags.and(contributor.getLongRequestTags(request, handler)); - } - return tags; - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java deleted file mode 100644 index db5c1f0e49c..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.servlet; - -import java.util.regex.Pattern; - -import io.micrometer.core.instrument.Tag; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import org.springframework.boot.actuate.metrics.http.Outcome; -import org.springframework.http.HttpStatus; -import org.springframework.util.StringUtils; -import org.springframework.web.servlet.HandlerMapping; -import org.springframework.web.util.pattern.PathPattern; - -/** - * Factory methods for {@link Tag Tags} associated with a request-response exchange that - * is handled by Spring MVC. - * - * @author Jon Schneider - * @author Andy Wilkinson - * @author Brian Clozel - * @author Michael McFadyen - * @since 2.0.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.http.server.observation.ServerRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -public final class WebMvcTags { - - private static final String DATA_REST_PATH_PATTERN_ATTRIBUTE = "org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping.EFFECTIVE_REPOSITORY_RESOURCE_LOOKUP_PATH"; - - private static final Tag URI_NOT_FOUND = Tag.of("uri", "NOT_FOUND"); - - private static final Tag URI_REDIRECTION = Tag.of("uri", "REDIRECTION"); - - private static final Tag URI_ROOT = Tag.of("uri", "root"); - - private static final Tag URI_UNKNOWN = Tag.of("uri", "UNKNOWN"); - - private static final Tag EXCEPTION_NONE = Tag.of("exception", "None"); - - private static final Tag STATUS_UNKNOWN = Tag.of("status", "UNKNOWN"); - - private static final Tag METHOD_UNKNOWN = Tag.of("method", "UNKNOWN"); - - private static final Pattern TRAILING_SLASH_PATTERN = Pattern.compile("/$"); - - private static final Pattern MULTIPLE_SLASH_PATTERN = Pattern.compile("//+"); - - private WebMvcTags() { - } - - /** - * Creates a {@code method} tag based on the {@link HttpServletRequest#getMethod() - * method} of the given {@code request}. - * @param request the request - * @return the method tag whose value is a capitalized method (e.g. GET). - */ - public static Tag method(HttpServletRequest request) { - return (request != null) ? Tag.of("method", request.getMethod()) : METHOD_UNKNOWN; - } - - /** - * Creates a {@code status} tag based on the status of the given {@code response}. - * @param response the HTTP response - * @return the status tag derived from the status of the response - */ - public static Tag status(HttpServletResponse response) { - return (response != null) ? Tag.of("status", Integer.toString(response.getStatus())) : STATUS_UNKNOWN; - } - - /** - * Creates a {@code uri} tag based on the URI of the given {@code request}. Uses the - * {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern if - * available. Falling back to {@code REDIRECTION} for 3xx responses, {@code NOT_FOUND} - * for 404 responses, {@code root} for requests with no path info, and {@code UNKNOWN} - * for all other requests. - * @param request the request - * @param response the response - * @return the uri tag derived from the request - */ - public static Tag uri(HttpServletRequest request, HttpServletResponse response) { - return uri(request, response, false); - } - - /** - * Creates a {@code uri} tag based on the URI of the given {@code request}. Uses the - * {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern if - * available. Falling back to {@code REDIRECTION} for 3xx responses, {@code NOT_FOUND} - * for 404 responses, {@code root} for requests with no path info, and {@code UNKNOWN} - * for all other requests. - * @param request the request - * @param response the response - * @param ignoreTrailingSlash whether to ignore the trailing slash - * @return the uri tag derived from the request - */ - public static Tag uri(HttpServletRequest request, HttpServletResponse response, boolean ignoreTrailingSlash) { - if (request != null) { - String pattern = getMatchingPattern(request); - if (pattern != null) { - if (ignoreTrailingSlash && pattern.length() > 1) { - pattern = TRAILING_SLASH_PATTERN.matcher(pattern).replaceAll(""); - } - if (pattern.isEmpty()) { - return URI_ROOT; - } - return Tag.of("uri", pattern); - } - if (response != null) { - HttpStatus status = extractStatus(response); - if (status != null) { - if (status.is3xxRedirection()) { - return URI_REDIRECTION; - } - if (status == HttpStatus.NOT_FOUND) { - return URI_NOT_FOUND; - } - } - } - String pathInfo = getPathInfo(request); - if (pathInfo.isEmpty()) { - return URI_ROOT; - } - } - return URI_UNKNOWN; - } - - private static HttpStatus extractStatus(HttpServletResponse response) { - try { - return HttpStatus.valueOf(response.getStatus()); - } - catch (IllegalArgumentException ex) { - return null; - } - } - - private static String getMatchingPattern(HttpServletRequest request) { - PathPattern dataRestPathPattern = (PathPattern) request.getAttribute(DATA_REST_PATH_PATTERN_ATTRIBUTE); - if (dataRestPathPattern != null) { - return dataRestPathPattern.getPatternString(); - } - return (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); - } - - private static String getPathInfo(HttpServletRequest request) { - String pathInfo = request.getPathInfo(); - String uri = StringUtils.hasText(pathInfo) ? pathInfo : "/"; - uri = MULTIPLE_SLASH_PATTERN.matcher(uri).replaceAll("/"); - return TRAILING_SLASH_PATTERN.matcher(uri).replaceAll(""); - } - - /** - * Creates an {@code exception} tag based on the {@link Class#getSimpleName() simple - * name} of the class of the given {@code exception}. - * @param exception the exception, may be {@code null} - * @return the exception tag derived from the exception - */ - public static Tag exception(Throwable exception) { - if (exception != null) { - String simpleName = exception.getClass().getSimpleName(); - return Tag.of("exception", StringUtils.hasText(simpleName) ? simpleName : exception.getClass().getName()); - } - return EXCEPTION_NONE; - } - - /** - * Creates an {@code outcome} tag based on the status of the given {@code response}. - * @param response the HTTP response - * @return the outcome tag derived from the status of the response - * @since 2.1.0 - */ - public static Tag outcome(HttpServletResponse response) { - Outcome outcome = (response != null) ? Outcome.forStatus(response.getStatus()) : Outcome.UNKNOWN; - return outcome.asTag(); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTagsContributor.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTagsContributor.java deleted file mode 100644 index f27b2115af6..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTagsContributor.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.servlet; - -import io.micrometer.core.instrument.LongTaskTimer; -import io.micrometer.core.instrument.Tag; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -/** - * A contributor of {@link Tag Tags} for Spring MVC-based request handling. Typically used - * by a {@link WebMvcTagsProvider} to provide tags in addition to its defaults. - * - * @author Andy Wilkinson - * @since 2.3.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.http.server.observation.ServerRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -public interface WebMvcTagsContributor { - - /** - * Provides tags to be associated with metrics for the given {@code request} and - * {@code response} exchange. - * @param request the request - * @param response the response - * @param handler the handler for the request or {@code null} if the handler is - * unknown - * @param exception the current exception, if any - * @return tags to associate with metrics for the request and response exchange - */ - Iterable getTags(HttpServletRequest request, HttpServletResponse response, Object handler, - Throwable exception); - - /** - * Provides tags to be used by {@link LongTaskTimer long task timers}. - * @param request the HTTP request - * @param handler the handler for the request or {@code null} if the handler is - * unknown - * @return tags to associate with metrics recorded for the request - */ - Iterable getLongRequestTags(HttpServletRequest request, Object handler); - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTagsProvider.java deleted file mode 100644 index 09206f727b1..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTagsProvider.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.servlet; - -import io.micrometer.core.instrument.LongTaskTimer; -import io.micrometer.core.instrument.Tag; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -/** - * Provides {@link Tag Tags} for Spring MVC-based request handling. - * - * @author Jon Schneider - * @author Andy Wilkinson - * @since 2.0.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.http.server.observation.ServerRequestObservationConvention} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -public interface WebMvcTagsProvider { - - /** - * Provides tags to be associated with metrics for the given {@code request} and - * {@code response} exchange. - * @param request the request - * @param response the response - * @param handler the handler for the request or {@code null} if the handler is - * unknown - * @param exception the current exception, if any - * @return tags to associate with metrics for the request and response exchange - */ - Iterable getTags(HttpServletRequest request, HttpServletResponse response, Object handler, - Throwable exception); - - /** - * Provides tags to be used by {@link LongTaskTimer long task timers}. - * @param request the HTTP request - * @param handler the handler for the request or {@code null} if the handler is - * unknown - * @return tags to associate with metrics recorded for the request - */ - Iterable getLongRequestTags(HttpServletRequest request, Object handler); - -} diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/package-info.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/package-info.java deleted file mode 100644 index 22bbf429f87..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012-2019 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Actuator support for Spring MVC metrics. - */ -package org.springframework.boot.actuate.metrics.web.servlet; diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java deleted file mode 100644 index 4bdcb94ce42..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2012-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.endpoint.web.servlet; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - -import io.micrometer.core.instrument.Tag; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.metrics.web.servlet.DefaultWebMvcTagsProvider; -import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.web.servlet.HandlerMapping; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link DefaultWebMvcTagsProvider}. - * - * @author Andy Wilkinson - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class DefaultWebMvcTagsProviderTests { - - @Test - void whenTagsAreProvidedThenDefaultTagsArePresent() { - Map tags = asMap(new DefaultWebMvcTagsProvider().getTags(null, null, null, null)); - assertThat(tags).containsOnlyKeys("exception", "method", "outcome", "status", "uri"); - } - - @Test - void givenSomeContributorsWhenTagsAreProvidedThenDefaultTagsAndContributedTagsArePresent() { - Map tags = asMap( - new DefaultWebMvcTagsProvider(Arrays.asList(new TestWebMvcTagsContributor("alpha"), - new TestWebMvcTagsContributor("bravo", "charlie"))) - .getTags(null, null, null, null)); - assertThat(tags).containsOnlyKeys("exception", "method", "outcome", "status", "uri", "alpha", "bravo", - "charlie"); - } - - @Test - void whenLongRequestTagsAreProvidedThenDefaultTagsArePresent() { - Map tags = asMap(new DefaultWebMvcTagsProvider().getLongRequestTags(null, null)); - assertThat(tags).containsOnlyKeys("method", "uri"); - } - - @Test - void givenSomeContributorsWhenLongRequestTagsAreProvidedThenDefaultTagsAndContributedTagsArePresent() { - Map tags = asMap( - new DefaultWebMvcTagsProvider(Arrays.asList(new TestWebMvcTagsContributor("alpha"), - new TestWebMvcTagsContributor("bravo", "charlie"))) - .getLongRequestTags(null, null)); - assertThat(tags).containsOnlyKeys("method", "uri", "alpha", "bravo", "charlie"); - } - - @Test - void trailingSlashIsIncludedByDefault() { - MockHttpServletRequest request = new MockHttpServletRequest("GET", "/the/uri/"); - request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "{one}/{two}/"); - Map tags = asMap(new DefaultWebMvcTagsProvider().getTags(request, null, null, null)); - assertThat(tags.get("uri").getValue()).isEqualTo("{one}/{two}/"); - } - - @Test - void trailingSlashCanBeIgnored() { - MockHttpServletRequest request = new MockHttpServletRequest("GET", "/the/uri/"); - request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "{one}/{two}/"); - Map tags = asMap(new DefaultWebMvcTagsProvider(true).getTags(request, null, null, null)); - assertThat(tags.get("uri").getValue()).isEqualTo("{one}/{two}"); - } - - private Map asMap(Iterable tags) { - return StreamSupport.stream(tags.spliterator(), false) - .collect(Collectors.toMap(Tag::getKey, Function.identity())); - } - - private static final class TestWebMvcTagsContributor implements WebMvcTagsContributor { - - private final List tagNames; - - private TestWebMvcTagsContributor(String... tagNames) { - this.tagNames = Arrays.asList(tagNames); - } - - @Override - public Iterable getTags(HttpServletRequest request, HttpServletResponse response, Object handler, - Throwable exception) { - return this.tagNames.stream().map((name) -> Tag.of(name, "value")).toList(); - } - - @Override - public Iterable getLongRequestTags(HttpServletRequest request, Object handler) { - return this.tagNames.stream().map((name) -> Tag.of(name, "value")).toList(); - } - - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcTagsTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcTagsTests.java deleted file mode 100644 index 7097ee9dfd7..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcTagsTests.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.endpoint.web.servlet; - -import io.micrometer.core.instrument.Tag; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTags; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.web.servlet.HandlerMapping; -import org.springframework.web.util.pattern.PathPatternParser; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link WebMvcTags}. - * - * @author Andy Wilkinson - * @author Brian Clozel - * @author Michael McFadyen - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class WebMvcTagsTests { - - private final MockHttpServletRequest request = new MockHttpServletRequest(); - - private final MockHttpServletResponse response = new MockHttpServletResponse(); - - @Test - void uriTagIsDataRestsEffectiveRepositoryLookupPathWhenAvailable() { - this.request.setAttribute( - "org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping.EFFECTIVE_REPOSITORY_RESOURCE_LOOKUP_PATH", - new PathPatternParser().parse("/api/cities")); - this.request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "/api/{repository}"); - Tag tag = WebMvcTags.uri(this.request, this.response); - assertThat(tag.getValue()).isEqualTo("/api/cities"); - } - - @Test - void uriTagValueIsBestMatchingPatternWhenAvailable() { - this.request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "/spring/"); - this.response.setStatus(301); - Tag tag = WebMvcTags.uri(this.request, this.response); - assertThat(tag.getValue()).isEqualTo("/spring/"); - } - - @Test - void uriTagValueIsRootWhenBestMatchingPatternIsEmpty() { - this.request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, ""); - this.response.setStatus(301); - Tag tag = WebMvcTags.uri(this.request, this.response); - assertThat(tag.getValue()).isEqualTo("root"); - } - - @Test - void uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashRemoveTrailingSlash() { - this.request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "/spring/"); - Tag tag = WebMvcTags.uri(this.request, this.response, true); - assertThat(tag.getValue()).isEqualTo("/spring"); - } - - @Test - void uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashKeepSingleSlash() { - this.request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "/"); - Tag tag = WebMvcTags.uri(this.request, this.response, true); - assertThat(tag.getValue()).isEqualTo("/"); - } - - @Test - void uriTagValueIsRootWhenRequestHasNoPatternOrPathInfo() { - assertThat(WebMvcTags.uri(this.request, null).getValue()).isEqualTo("root"); - } - - @Test - void uriTagValueIsRootWhenRequestHasNoPatternAndSlashPathInfo() { - this.request.setPathInfo("/"); - assertThat(WebMvcTags.uri(this.request, null).getValue()).isEqualTo("root"); - } - - @Test - void uriTagValueIsUnknownWhenRequestHasNoPatternAndNonRootPathInfo() { - this.request.setPathInfo("/example"); - assertThat(WebMvcTags.uri(this.request, null).getValue()).isEqualTo("UNKNOWN"); - } - - @Test - void uriTagValueIsRedirectionWhenResponseStatusIs3xx() { - this.response.setStatus(301); - Tag tag = WebMvcTags.uri(this.request, this.response); - assertThat(tag.getValue()).isEqualTo("REDIRECTION"); - } - - @Test - void uriTagValueIsNotFoundWhenResponseStatusIs404() { - this.response.setStatus(404); - Tag tag = WebMvcTags.uri(this.request, this.response); - assertThat(tag.getValue()).isEqualTo("NOT_FOUND"); - } - - @Test - void uriTagToleratesCustomResponseStatus() { - this.response.setStatus(601); - Tag tag = WebMvcTags.uri(this.request, this.response); - assertThat(tag.getValue()).isEqualTo("root"); - } - - @Test - void uriTagIsUnknownWhenRequestIsNull() { - Tag tag = WebMvcTags.uri(null, null); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - - @Test - void outcomeTagIsUnknownWhenResponseIsNull() { - Tag tag = WebMvcTags.outcome(null); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - - @Test - void outcomeTagIsInformationalWhenResponseIs1xx() { - this.response.setStatus(100); - Tag tag = WebMvcTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("INFORMATIONAL"); - } - - @Test - void outcomeTagIsSuccessWhenResponseIs2xx() { - this.response.setStatus(200); - Tag tag = WebMvcTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("SUCCESS"); - } - - @Test - void outcomeTagIsRedirectionWhenResponseIs3xx() { - this.response.setStatus(301); - Tag tag = WebMvcTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("REDIRECTION"); - } - - @Test - void outcomeTagIsClientErrorWhenResponseIs4xx() { - this.response.setStatus(400); - Tag tag = WebMvcTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("CLIENT_ERROR"); - } - - @Test - void outcomeTagIsClientErrorWhenResponseIsNonStandardInClientSeries() { - this.response.setStatus(490); - Tag tag = WebMvcTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("CLIENT_ERROR"); - } - - @Test - void outcomeTagIsServerErrorWhenResponseIs5xx() { - this.response.setStatus(500); - Tag tag = WebMvcTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("SERVER_ERROR"); - } - - @Test - void outcomeTagIsUnknownWhenResponseStatusIsInUnknownSeries() { - this.response.setStatus(701); - Tag tag = WebMvcTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java index ca8d61d3108..6960ea72275 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/prometheus/PrometheusPushGatewayManagerTests.java @@ -140,18 +140,6 @@ class PrometheusPushGatewayManagerTests { then(otherScheduler).should(never()).shutdown(); } - @Test - @SuppressWarnings("removal") - @Deprecated(since = "3.0.0", forRemoval = true) - void shutdownWhenShutdownOperationIsPushPerformsPushAddOnShutdown() throws Exception { - givenScheduleAtFixedRateWithReturnFuture(); - PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry, - this.scheduler, this.pushRate, "job", this.groupingKey, ShutdownOperation.PUSH); - manager.shutdown(); - then(this.future).should().cancel(false); - then(this.pushGateway).should().pushAdd(this.registry, "job", this.groupingKey); - } - @Test void shutdownWhenShutdownOperationIsPostPerformsPushAddOnShutdown() throws Exception { givenScheduleAtFixedRateWithReturnFuture(); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTagsTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTagsTests.java deleted file mode 100644 index 7dd9a2322b3..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTagsTests.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.client; - -import java.io.IOException; -import java.net.URI; - -import io.micrometer.core.instrument.Tag; -import org.junit.jupiter.api.Test; - -import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; -import org.springframework.http.client.ClientHttpRequest; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.mock.http.client.MockClientHttpResponse; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - -/** - * Tests for {@link RestTemplateExchangeTags}. - * - * @author Nishant Raut - * @author Brian Clozel - */ -@SuppressWarnings({ "removal" }) -@Deprecated(since = "3.0.0", forRemoval = true) -class RestTemplateExchangeTagsTests { - - @Test - void outcomeTagIsUnknownWhenResponseIsNull() { - Tag tag = RestTemplateExchangeTags.outcome(null); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - - @Test - void outcomeTagIsInformationalWhenResponseIs1xx() { - ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.CONTINUE); - Tag tag = RestTemplateExchangeTags.outcome(response); - assertThat(tag.getValue()).isEqualTo("INFORMATIONAL"); - } - - @Test - void outcomeTagIsSuccessWhenResponseIs2xx() { - ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.OK); - Tag tag = RestTemplateExchangeTags.outcome(response); - assertThat(tag.getValue()).isEqualTo("SUCCESS"); - } - - @Test - void outcomeTagIsRedirectionWhenResponseIs3xx() { - ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.MOVED_PERMANENTLY); - Tag tag = RestTemplateExchangeTags.outcome(response); - assertThat(tag.getValue()).isEqualTo("REDIRECTION"); - } - - @Test - void outcomeTagIsClientErrorWhenResponseIs4xx() { - ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.BAD_REQUEST); - Tag tag = RestTemplateExchangeTags.outcome(response); - assertThat(tag.getValue()).isEqualTo("CLIENT_ERROR"); - } - - @Test - void outcomeTagIsServerErrorWhenResponseIs5xx() { - ClientHttpResponse response = new MockClientHttpResponse("foo".getBytes(), HttpStatus.BAD_GATEWAY); - Tag tag = RestTemplateExchangeTags.outcome(response); - assertThat(tag.getValue()).isEqualTo("SERVER_ERROR"); - } - - @Test - void outcomeTagIsUnknownWhenResponseThrowsIOException() throws Exception { - ClientHttpResponse response = mock(ClientHttpResponse.class); - given(response.getStatusCode()).willThrow(IOException.class); - Tag tag = RestTemplateExchangeTags.outcome(response); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - - @Test - void outcomeTagIsClientErrorWhenResponseIsNonStandardInClientSeries() throws IOException { - ClientHttpResponse response = mock(ClientHttpResponse.class); - given(response.getStatusCode()).willReturn(HttpStatusCode.valueOf(490)); - Tag tag = RestTemplateExchangeTags.outcome(response); - assertThat(tag.getValue()).isEqualTo("CLIENT_ERROR"); - } - - @Test - void outcomeTagIsUnknownWhenResponseStatusIsInUnknownSeries() throws IOException { - ClientHttpResponse response = mock(ClientHttpResponse.class); - given(response.getStatusCode()).willReturn(HttpStatusCode.valueOf(701)); - Tag tag = RestTemplateExchangeTags.outcome(response); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - - @Test - void clientNameTagIsHostOfRequestUri() { - ClientHttpRequest request = mock(ClientHttpRequest.class); - given(request.getURI()).willReturn(URI.create("https://example.org")); - Tag tag = RestTemplateExchangeTags.clientName(request); - assertThat(tag).isEqualTo(Tag.of("client.name", "example.org")); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java deleted file mode 100644 index c04846e7169..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2012-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.client; - -import java.io.IOException; -import java.net.URI; - -import io.micrometer.core.instrument.Tag; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.web.reactive.function.client.ClientRequest; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.WebClient; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - -/** - * Tests for {@link DefaultWebClientExchangeTagsProvider} - * - * @author Brian Clozel - * @author Nishant Raut - */ -@SuppressWarnings({ "deprecation", "removal" }) -class DefaultWebClientExchangeTagsProviderTests { - - private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate"; - - private final WebClientExchangeTagsProvider tagsProvider = new DefaultWebClientExchangeTagsProvider(); - - private ClientRequest request; - - private ClientResponse response; - - @BeforeEach - void setup() { - this.request = ClientRequest.create(HttpMethod.GET, URI.create("https://example.org/projects/spring-boot")) - .attribute(URI_TEMPLATE_ATTRIBUTE, "https://example.org/projects/{project}") - .build(); - this.response = mock(ClientResponse.class); - given(this.response.statusCode()).willReturn(HttpStatus.OK); - } - - @Test - void tagsShouldBePopulated() { - Iterable tags = this.tagsProvider.tags(this.request, this.response, null); - assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"), - Tag.of("client.name", "example.org"), Tag.of("status", "200"), Tag.of("outcome", "SUCCESS")); - } - - @Test - void tagsWhenNoUriTemplateShouldProvideUriPath() { - ClientRequest request = ClientRequest - .create(HttpMethod.GET, URI.create("https://example.org/projects/spring-boot")) - .build(); - Iterable tags = this.tagsProvider.tags(request, this.response, null); - assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/spring-boot"), - Tag.of("client.name", "example.org"), Tag.of("status", "200"), Tag.of("outcome", "SUCCESS")); - } - - @Test - void tagsWhenIoExceptionShouldReturnIoErrorStatus() { - Iterable tags = this.tagsProvider.tags(this.request, null, new IOException()); - assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"), - Tag.of("client.name", "example.org"), Tag.of("status", "IO_ERROR"), Tag.of("outcome", "UNKNOWN")); - } - - @Test - void tagsWhenExceptionShouldReturnClientErrorStatus() { - Iterable tags = this.tagsProvider.tags(this.request, null, new IllegalArgumentException()); - assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"), - Tag.of("client.name", "example.org"), Tag.of("status", "CLIENT_ERROR"), Tag.of("outcome", "UNKNOWN")); - } - - @Test - void tagsWhenCancelledRequestShouldReturnClientErrorStatus() { - Iterable tags = this.tagsProvider.tags(this.request, null, null); - assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"), - Tag.of("client.name", "example.org"), Tag.of("status", "CLIENT_ERROR"), Tag.of("outcome", "UNKNOWN")); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java deleted file mode 100644 index fbc3860fb4b..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2012-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.client; - -import java.io.IOException; -import java.net.URI; - -import io.micrometer.core.instrument.Tag; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; -import org.springframework.web.reactive.function.client.ClientRequest; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.WebClient; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - -/** - * Tests for {@link WebClientExchangeTags}. - * - * @author Brian Clozel - * @author Nishant Raut - */ -@SuppressWarnings({ "deprecation", "removal" }) -class WebClientExchangeTagsTests { - - private static final String URI_TEMPLATE_ATTRIBUTE = WebClient.class.getName() + ".uriTemplate"; - - private ClientRequest request; - - private ClientResponse response; - - @BeforeEach - void setup() { - this.request = ClientRequest.create(HttpMethod.GET, URI.create("https://example.org/projects/spring-boot")) - .attribute(URI_TEMPLATE_ATTRIBUTE, "https://example.org/projects/{project}") - .build(); - this.response = mock(ClientResponse.class); - } - - @Test - void method() { - assertThat(WebClientExchangeTags.method(this.request)).isEqualTo(Tag.of("method", "GET")); - } - - @Test - void uriWhenAbsoluteTemplateIsAvailableShouldReturnTemplate() { - assertThat(WebClientExchangeTags.uri(this.request)).isEqualTo(Tag.of("uri", "/projects/{project}")); - } - - @Test - void uriWhenRelativeTemplateIsAvailableShouldReturnTemplate() { - this.request = ClientRequest.create(HttpMethod.GET, URI.create("https://example.org/projects/spring-boot")) - .attribute(URI_TEMPLATE_ATTRIBUTE, "/projects/{project}") - .build(); - assertThat(WebClientExchangeTags.uri(this.request)).isEqualTo(Tag.of("uri", "/projects/{project}")); - } - - @Test - void uriWhenTemplateIsMissingShouldReturnPath() { - this.request = ClientRequest.create(HttpMethod.GET, URI.create("https://example.org/projects/spring-boot")) - .build(); - assertThat(WebClientExchangeTags.uri(this.request)).isEqualTo(Tag.of("uri", "/projects/spring-boot")); - } - - @Test - void uriWhenTemplateIsMissingShouldReturnPathWithQueryParams() { - this.request = ClientRequest - .create(HttpMethod.GET, URI.create("https://example.org/projects/spring-boot?section=docs")) - .build(); - assertThat(WebClientExchangeTags.uri(this.request)) - .isEqualTo(Tag.of("uri", "/projects/spring-boot?section=docs")); - } - - @Test - void clientName() { - assertThat(WebClientExchangeTags.clientName(this.request)).isEqualTo(Tag.of("client.name", "example.org")); - } - - @Test - void status() { - given(this.response.statusCode()).willReturn(HttpStatus.OK); - assertThat(WebClientExchangeTags.status(this.response, null)).isEqualTo(Tag.of("status", "200")); - } - - @Test - void statusWhenIOException() { - assertThat(WebClientExchangeTags.status(null, new IOException())).isEqualTo(Tag.of("status", "IO_ERROR")); - } - - @Test - void statusWhenClientException() { - assertThat(WebClientExchangeTags.status(null, new IllegalArgumentException())) - .isEqualTo(Tag.of("status", "CLIENT_ERROR")); - } - - @Test - void statusWhenNonStandard() { - given(this.response.statusCode()).willReturn(HttpStatusCode.valueOf(490)); - assertThat(WebClientExchangeTags.status(this.response, null)).isEqualTo(Tag.of("status", "490")); - } - - @Test - void statusWhenCancelled() { - assertThat(WebClientExchangeTags.status(null, null)).isEqualTo(Tag.of("status", "CLIENT_ERROR")); - } - - @Test - void outcomeTagIsUnknownWhenResponseIsNull() { - Tag tag = WebClientExchangeTags.outcome(null); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - - @Test - void outcomeTagIsInformationalWhenResponseIs1xx() { - given(this.response.statusCode()).willReturn(HttpStatus.CONTINUE); - Tag tag = WebClientExchangeTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("INFORMATIONAL"); - } - - @Test - void outcomeTagIsSuccessWhenResponseIs2xx() { - given(this.response.statusCode()).willReturn(HttpStatus.OK); - Tag tag = WebClientExchangeTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("SUCCESS"); - } - - @Test - void outcomeTagIsRedirectionWhenResponseIs3xx() { - given(this.response.statusCode()).willReturn(HttpStatus.MOVED_PERMANENTLY); - Tag tag = WebClientExchangeTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("REDIRECTION"); - } - - @Test - void outcomeTagIsClientErrorWhenResponseIs4xx() { - given(this.response.statusCode()).willReturn(HttpStatus.BAD_REQUEST); - Tag tag = WebClientExchangeTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("CLIENT_ERROR"); - } - - @Test - void outcomeTagIsServerErrorWhenResponseIs5xx() { - given(this.response.statusCode()).willReturn(HttpStatus.BAD_GATEWAY); - Tag tag = WebClientExchangeTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("SERVER_ERROR"); - } - - @Test - void outcomeTagIsClientErrorWhenResponseIsNonStandardInClientSeries() { - given(this.response.statusCode()).willReturn(HttpStatusCode.valueOf(490)); - Tag tag = WebClientExchangeTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("CLIENT_ERROR"); - } - - @Test - void outcomeTagIsUnknownWhenResponseStatusIsInUnknownSeries() { - given(this.response.statusCode()).willReturn(HttpStatusCode.valueOf(701)); - Tag tag = WebClientExchangeTags.outcome(this.response); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProviderTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProviderTests.java deleted file mode 100644 index 39240b2fd34..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/DefaultWebFluxTagsProviderTests.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2012-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.server; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - -import io.micrometer.core.instrument.Tag; -import org.junit.jupiter.api.Test; - -import org.springframework.mock.http.server.reactive.MockServerHttpRequest; -import org.springframework.mock.web.server.MockServerWebExchange; -import org.springframework.web.server.ServerWebExchange; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link DefaultWebFluxTagsProvider}. - * - * @author Andy Wilkinson - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class DefaultWebFluxTagsProviderTests { - - @Test - void whenTagsAreProvidedThenDefaultTagsArePresent() { - ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/test")); - Map tags = asMap(new DefaultWebFluxTagsProvider().httpRequestTags(exchange, null)); - assertThat(tags).containsOnlyKeys("exception", "method", "outcome", "status", "uri"); - } - - @Test - void givenSomeContributorsWhenTagsAreProvidedThenDefaultTagsAndContributedTagsArePresent() { - ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/test")); - Map tags = asMap( - new DefaultWebFluxTagsProvider(Arrays.asList(new TestWebFluxTagsContributor("alpha"), - new TestWebFluxTagsContributor("bravo", "charlie"))) - .httpRequestTags(exchange, null)); - assertThat(tags).containsOnlyKeys("exception", "method", "outcome", "status", "uri", "alpha", "bravo", - "charlie"); - } - - private Map asMap(Iterable tags) { - return StreamSupport.stream(tags.spliterator(), false) - .collect(Collectors.toMap(Tag::getKey, Function.identity())); - } - - private static final class TestWebFluxTagsContributor implements WebFluxTagsContributor { - - private final List tagNames; - - private TestWebFluxTagsContributor(String... tagNames) { - this.tagNames = Arrays.asList(tagNames); - } - - @Override - public Iterable httpRequestTags(ServerWebExchange exchange, Throwable ex) { - return this.tagNames.stream().map((name) -> Tag.of(name, "value")).toList(); - } - - } - -} diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java deleted file mode 100644 index 03d7a103025..00000000000 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright 2012-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.actuate.metrics.web.reactive.server; - -import java.io.EOFException; - -import io.micrometer.core.instrument.Tag; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.mock.http.server.reactive.MockServerHttpRequest; -import org.springframework.mock.web.server.MockServerWebExchange; -import org.springframework.web.reactive.HandlerMapping; -import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.pattern.PathPatternParser; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; - -/** - * Tests for {@link WebFluxTags}. - * - * @author Brian Clozel - * @author Michael McFadyen - * @author Madhura Bhave - * @author Stephane Nicoll - */ -@SuppressWarnings("removal") -@Deprecated(since = "3.0.0", forRemoval = true) -class WebFluxTagsTests { - - private MockServerWebExchange exchange; - - private final PathPatternParser parser = new PathPatternParser(); - - @BeforeEach - void setup() { - this.exchange = MockServerWebExchange.from(MockServerHttpRequest.get("")); - } - - @Test - void uriTagValueIsBestMatchingPatternWhenAvailable() { - this.exchange.getAttributes() - .put(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, this.parser.parse("/spring/")); - this.exchange.getResponse().setStatusCode(HttpStatus.MOVED_PERMANENTLY); - Tag tag = WebFluxTags.uri(this.exchange); - assertThat(tag.getValue()).isEqualTo("/spring/"); - } - - @Test - void uriTagValueIsRootWhenBestMatchingPatternIsEmpty() { - this.exchange.getAttributes().put(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, this.parser.parse("")); - this.exchange.getResponse().setStatusCode(HttpStatus.MOVED_PERMANENTLY); - Tag tag = WebFluxTags.uri(this.exchange); - assertThat(tag.getValue()).isEqualTo("root"); - } - - @Test - void uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashRemoveTrailingSlash() { - this.exchange.getAttributes() - .put(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, this.parser.parse("/spring/")); - Tag tag = WebFluxTags.uri(this.exchange, true); - assertThat(tag.getValue()).isEqualTo("/spring"); - } - - @Test - void uriTagValueWithBestMatchingPatternAndIgnoreTrailingSlashKeepSingleSlash() { - this.exchange.getAttributes().put(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, this.parser.parse("/")); - Tag tag = WebFluxTags.uri(this.exchange, true); - assertThat(tag.getValue()).isEqualTo("/"); - } - - @Test - void uriTagValueIsRedirectionWhenResponseStatusIs3xx() { - this.exchange.getResponse().setStatusCode(HttpStatus.MOVED_PERMANENTLY); - Tag tag = WebFluxTags.uri(this.exchange); - assertThat(tag.getValue()).isEqualTo("REDIRECTION"); - } - - @Test - void uriTagValueIsNotFoundWhenResponseStatusIs404() { - this.exchange.getResponse().setStatusCode(HttpStatus.NOT_FOUND); - Tag tag = WebFluxTags.uri(this.exchange); - assertThat(tag.getValue()).isEqualTo("NOT_FOUND"); - } - - @Test - void uriTagToleratesCustomResponseStatus() { - this.exchange.getResponse().setRawStatusCode(601); - Tag tag = WebFluxTags.uri(this.exchange); - assertThat(tag.getValue()).isEqualTo("root"); - } - - @Test - void uriTagValueIsRootWhenRequestHasNoPatternOrPathInfo() { - Tag tag = WebFluxTags.uri(this.exchange); - assertThat(tag.getValue()).isEqualTo("root"); - } - - @Test - void uriTagValueIsRootWhenRequestHasNoPatternAndSlashPathInfo() { - MockServerHttpRequest request = MockServerHttpRequest.get("/").build(); - ServerWebExchange exchange = MockServerWebExchange.from(request); - Tag tag = WebFluxTags.uri(exchange); - assertThat(tag.getValue()).isEqualTo("root"); - } - - @Test - void uriTagValueIsUnknownWhenRequestHasNoPatternAndNonRootPathInfo() { - MockServerHttpRequest request = MockServerHttpRequest.get("/example").build(); - ServerWebExchange exchange = MockServerWebExchange.from(request); - Tag tag = WebFluxTags.uri(exchange); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - - @Test - void methodTagToleratesNonStandardHttpMethods() { - ServerWebExchange exchange = mock(ServerWebExchange.class); - ServerHttpRequest request = mock(ServerHttpRequest.class); - given(exchange.getRequest()).willReturn(request); - given(request.getMethod()).willReturn(HttpMethod.valueOf("CUSTOM")); - Tag tag = WebFluxTags.method(exchange); - assertThat(tag.getValue()).isEqualTo("CUSTOM"); - } - - @Test - void outcomeTagIsSuccessWhenResponseStatusIsNull() { - this.exchange.getResponse().setStatusCode(null); - Tag tag = WebFluxTags.outcome(this.exchange, null); - assertThat(tag.getValue()).isEqualTo("SUCCESS"); - } - - @Test - void outcomeTagIsSuccessWhenResponseStatusIsAvailableFromUnderlyingServer() { - ServerWebExchange exchange = mock(ServerWebExchange.class); - ServerHttpRequest request = mock(ServerHttpRequest.class); - ServerHttpResponse response = mock(ServerHttpResponse.class); - given(response.getStatusCode()).willReturn(HttpStatus.OK); - given(response.getStatusCode().value()).willReturn(null); - given(exchange.getRequest()).willReturn(request); - given(exchange.getResponse()).willReturn(response); - Tag tag = WebFluxTags.outcome(exchange, null); - assertThat(tag.getValue()).isEqualTo("SUCCESS"); - } - - @Test - void outcomeTagIsInformationalWhenResponseIs1xx() { - this.exchange.getResponse().setStatusCode(HttpStatus.CONTINUE); - Tag tag = WebFluxTags.outcome(this.exchange, null); - assertThat(tag.getValue()).isEqualTo("INFORMATIONAL"); - } - - @Test - void outcomeTagIsSuccessWhenResponseIs2xx() { - this.exchange.getResponse().setStatusCode(HttpStatus.OK); - Tag tag = WebFluxTags.outcome(this.exchange, null); - assertThat(tag.getValue()).isEqualTo("SUCCESS"); - } - - @Test - void outcomeTagIsRedirectionWhenResponseIs3xx() { - this.exchange.getResponse().setStatusCode(HttpStatus.MOVED_PERMANENTLY); - Tag tag = WebFluxTags.outcome(this.exchange, null); - assertThat(tag.getValue()).isEqualTo("REDIRECTION"); - } - - @Test - void outcomeTagIsClientErrorWhenResponseIs4xx() { - this.exchange.getResponse().setStatusCode(HttpStatus.BAD_REQUEST); - Tag tag = WebFluxTags.outcome(this.exchange, null); - assertThat(tag.getValue()).isEqualTo("CLIENT_ERROR"); - } - - @Test - void outcomeTagIsServerErrorWhenResponseIs5xx() { - this.exchange.getResponse().setStatusCode(HttpStatus.BAD_GATEWAY); - Tag tag = WebFluxTags.outcome(this.exchange, null); - assertThat(tag.getValue()).isEqualTo("SERVER_ERROR"); - } - - @Test - void outcomeTagIsClientErrorWhenResponseIsNonStandardInClientSeries() { - this.exchange.getResponse().setRawStatusCode(490); - Tag tag = WebFluxTags.outcome(this.exchange, null); - assertThat(tag.getValue()).isEqualTo("CLIENT_ERROR"); - } - - @Test - void outcomeTagIsUnknownWhenResponseStatusIsInUnknownSeries() { - this.exchange.getResponse().setRawStatusCode(701); - Tag tag = WebFluxTags.outcome(this.exchange, null); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - - @Test - void outcomeTagIsUnknownWhenExceptionIsDisconnectedClient() { - Tag tag = WebFluxTags.outcome(this.exchange, new EOFException("broken pipe")); - assertThat(tag.getValue()).isEqualTo("UNKNOWN"); - } - -} diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 0c5928ed27c..e65ef1fa54e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -127,16 +127,6 @@ public class FlywayAutoConfiguration { return new PropertiesFlywayConnectionDetails(properties); } - @Deprecated(since = "3.0.0", forRemoval = true) - public Flyway flyway(FlywayProperties properties, ResourceLoader resourceLoader, - ObjectProvider dataSource, ObjectProvider flywayDataSource, - ObjectProvider fluentConfigurationCustomizers, - ObjectProvider javaMigrations, ObjectProvider callbacks) { - return flyway(properties, new PropertiesFlywayConnectionDetails(properties), resourceLoader, dataSource, - flywayDataSource, fluentConfigurationCustomizers, javaMigrations, callbacks, - new ResourceProviderCustomizer()); - } - @Bean Flyway flyway(FlywayProperties properties, FlywayConnectionDetails connectionDetails, ResourceLoader resourceLoader, ObjectProvider dataSource, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java index 478897d053d..c14779f3305 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java @@ -22,7 +22,6 @@ import java.util.Map; import liquibase.integration.spring.SpringLiquibase; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.util.Assert; /** @@ -257,17 +256,6 @@ public class LiquibaseProperties { this.labelFilter = labelFilter; } - @Deprecated(since = "3.0.0", forRemoval = true) - @DeprecatedConfigurationProperty(replacement = "spring.liquibase.label-filter") - public String getLabels() { - return getLabelFilter(); - } - - @Deprecated(since = "3.0.0", forRemoval = true) - public void setLabels(String labels) { - setLabelFilter(labels); - } - public Map getParameters() { return this.parameters; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java index 4d632946283..b5e36068a8a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java @@ -41,8 +41,8 @@ import org.springframework.boot.autoconfigure.web.reactive.WebFluxProperties; import org.springframework.boot.autoconfigure.web.reactive.WebSessionIdResolverAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.PropertyMapper; +import org.springframework.boot.web.server.Cookie; import org.springframework.boot.web.server.Cookie.SameSite; -import org.springframework.boot.web.servlet.server.Session.Cookie; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 681bd7d8384..1a053cd529b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -154,17 +154,6 @@ public class ServerProperties { this.serverHeader = serverHeader; } - @Deprecated(since = "3.0.0", forRemoval = true) - @DeprecatedConfigurationProperty - public DataSize getMaxHttpHeaderSize() { - return getMaxHttpRequestHeaderSize(); - } - - @Deprecated(since = "3.0.0", forRemoval = true) - public void setMaxHttpHeaderSize(DataSize maxHttpHeaderSize) { - setMaxHttpRequestHeaderSize(maxHttpHeaderSize); - } - public DataSize getMaxHttpRequestHeaderSize() { return this.maxHttpRequestHeaderSize; } @@ -475,7 +464,7 @@ public class ServerProperties { /** * Whether to reject requests with illegal header names or values. */ - @Deprecated(since = "2.7.12", forRemoval = true) + @Deprecated(since = "2.7.12", forRemoval = true) // Remove in 3.3 private boolean rejectIllegalHeader = true; /** @@ -1409,11 +1398,6 @@ public class ServerProperties { */ private DataSize initialBufferSize = DataSize.ofBytes(128); - /** - * Maximum chunk size that can be decoded for an HTTP request. - */ - private DataSize maxChunkSize = DataSize.ofKilobytes(8); - /** * Maximum length that can be decoded for an HTTP request's initial line. */ @@ -1460,17 +1444,6 @@ public class ServerProperties { this.initialBufferSize = initialBufferSize; } - @Deprecated(since = "3.0.0", forRemoval = true) - @DeprecatedConfigurationProperty(reason = "Deprecated for removal in Reactor Netty") - public DataSize getMaxChunkSize() { - return this.maxChunkSize; - } - - @Deprecated(since = "3.0.0", forRemoval = true) - public void setMaxChunkSize(DataSize maxChunkSize) { - this.maxChunkSize = maxChunkSize; - } - public DataSize getMaxInitialLineLength() { return this.maxInitialLineLength; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java index c1d6ba684b8..acfade5b98d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizer.java @@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.web.embedded; import java.time.Duration; import io.netty.channel.ChannelOption; -import reactor.netty.http.server.HttpRequestDecoderSpec; import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.cloud.CloudPlatform; @@ -87,7 +86,6 @@ public class NettyWebServerFactoryCustomizer .to((maxHttpRequestHeader) -> httpRequestDecoderSpec .maxHeaderSize((int) maxHttpRequestHeader.toBytes())); ServerProperties.Netty nettyProperties = this.serverProperties.getNetty(); - maxChunkSize(propertyMapper, httpRequestDecoderSpec, nettyProperties); propertyMapper.from(nettyProperties.getMaxInitialLineLength()) .whenNonNull() .to((maxInitialLineLength) -> httpRequestDecoderSpec @@ -106,14 +104,6 @@ public class NettyWebServerFactoryCustomizer })); } - @SuppressWarnings({ "deprecation", "removal" }) - private void maxChunkSize(PropertyMapper propertyMapper, HttpRequestDecoderSpec httpRequestDecoderSpec, - ServerProperties.Netty nettyProperties) { - propertyMapper.from(nettyProperties.getMaxChunkSize()) - .whenNonNull() - .to((maxChunkSize) -> httpRequestDecoderSpec.maxChunkSize((int) maxChunkSize.toBytes())); - } - private void customizeIdleTimeout(NettyReactiveWebServerFactory factory, Duration idleTimeout) { factory.addServerCustomizers((httpServer) -> httpServer.idleTimeout(idleTimeout)); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java index e92256d6004..f3e8097248f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java @@ -31,7 +31,6 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureOrder; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -403,24 +402,6 @@ public class WebMvcAutoConfiguration { this.beanFactory = beanFactory; } - @Bean - @Override - public RequestMappingHandlerAdapter requestMappingHandlerAdapter( - @Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager, - @Qualifier("mvcConversionService") FormattingConversionService conversionService, - @Qualifier("mvcValidator") Validator validator) { - RequestMappingHandlerAdapter adapter = super.requestMappingHandlerAdapter(contentNegotiationManager, - conversionService, validator); - setIgnoreDefaultModelOnRedirect(adapter); - return adapter; - } - - @SuppressWarnings({ "deprecation", "removal" }) - private void setIgnoreDefaultModelOnRedirect(RequestMappingHandlerAdapter adapter) { - adapter.setIgnoreDefaultModelOnRedirect( - this.mvcProperties == null || this.mvcProperties.isIgnoreDefaultModelOnRedirect()); - } - @Override protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter() { if (this.mvcRegistrations != null) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java index 6037fa974a8..0c73524c8f9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java @@ -21,7 +21,6 @@ import java.util.LinkedHashMap; import java.util.Map; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.validation.DefaultMessageCodesResolver; @@ -57,12 +56,6 @@ public class WebMvcProperties { */ private boolean dispatchOptionsRequest = true; - /** - * Whether the content of the "default" model should be ignored during redirect - * scenarios. - */ - private boolean ignoreDefaultModelOnRedirect = true; - /** * Whether to publish a ServletRequestHandledEvent at the end of each request. */ @@ -120,17 +113,6 @@ public class WebMvcProperties { return this.format; } - @Deprecated(since = "3.0.0", forRemoval = true) - @DeprecatedConfigurationProperty(reason = "Deprecated for removal in Spring MVC") - public boolean isIgnoreDefaultModelOnRedirect() { - return this.ignoreDefaultModelOnRedirect; - } - - @Deprecated(since = "3.0.0", forRemoval = true) - public void setIgnoreDefaultModelOnRedirect(boolean ignoreDefaultModelOnRedirect) { - this.ignoreDefaultModelOnRedirect = ignoreDefaultModelOnRedirect; - } - public boolean isPublishRequestHandledEvents() { return this.publishRequestHandledEvents; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index dae3a6e6cdf..be821293afa 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -115,6 +115,13 @@ "level": "error" } }, + { + "name": "server.max-http-header-size", + "deprecation": { + "replacement": "server.max-http-request-header-size", + "level": "error" + } + }, { "name": "server.max-http-post-size", "type": "java.lang.Integer", @@ -125,6 +132,13 @@ "level": "error" } }, + { + "name": "server.netty.max-chunk-size", + "deprecation": { + "reason": "Deprecated for removal in Reactor Netty.", + "level": "error" + } + }, { "name": "server.port", "defaultValue": 8080 @@ -210,7 +224,10 @@ }, { "name": "server.servlet.session.cookie.comment", - "description": "Comment for the cookie." + "description": "Comment for the cookie.", + "deprecation": { + "level": "error" + } }, { "name": "server.servlet.session.cookie.domain", @@ -2043,6 +2060,13 @@ "level": "error" } }, + { + "name": "spring.liquibase.labels", + "deprecation": { + "replacement": "spring.liquibase.label-filter", + "level": "error" + } + }, { "name": "spring.mail.test-connection", "description": "Whether to test that the mail server is available on startup.", @@ -2105,6 +2129,13 @@ "description": "Whether to enable Spring's HiddenHttpMethodFilter.", "defaultValue": false }, + { + "name": "spring.mvc.ignore-default-model-on-redirect", + "deprecation": { + "reason": "Deprecated for removal in Spring MVC.", + "level": "error" + } + }, { "name": "spring.mvc.locale", "type": "java.util.Locale", diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java index b05e9b0f010..3c66a600970 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java @@ -379,14 +379,6 @@ class LiquibaseAutoConfigurationTests { .run(assertLiquibase((liquibase) -> assertThat(liquibase.getLabelFilter()).isEqualTo("test, production"))); } - @Test - @Deprecated(since = "3.0.0", forRemoval = true) - void overrideLabelFilterWithDeprecatedLabelsProperty() { - this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) - .withPropertyValues("spring.liquibase.labels:test, production") - .run(assertLiquibase((liquibase) -> assertThat(liquibase.getLabelFilter()).isEqualTo("test, production"))); - } - @Test @SuppressWarnings("unchecked") void testOverrideParameters() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java index eaf0b45c2b0..379aa6e32ce 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java @@ -205,24 +205,6 @@ class ServerPropertiesTests { assertThat(this.properties.getTomcat().getUriEncoding()).isEqualTo(StandardCharsets.US_ASCII); } - @Test - @SuppressWarnings("removal") - @Deprecated(since = "3.0.0", forRemoval = true) - void testCustomizeHeaderSize() { - bind("server.max-http-header-size", "1MB"); - assertThat(this.properties.getMaxHttpHeaderSize()).isEqualTo(DataSize.ofMegabytes(1)); - assertThat(this.properties.getMaxHttpRequestHeaderSize()).isEqualTo(DataSize.ofMegabytes(1)); - } - - @Test - @SuppressWarnings("removal") - @Deprecated(since = "3.0.0", forRemoval = true) - void testCustomizeHeaderSizeUseBytesByDefault() { - bind("server.max-http-header-size", "1024"); - assertThat(this.properties.getMaxHttpHeaderSize()).isEqualTo(DataSize.ofKilobytes(1)); - assertThat(this.properties.getMaxHttpRequestHeaderSize()).isEqualTo(DataSize.ofKilobytes(1)); - } - @Test void testCustomizeMaxHttpRequestHeaderSize() { bind("server.max-http-request-header-size", "1MB"); @@ -538,14 +520,6 @@ class ServerPropertiesTests { .isEqualTo(UndertowOptions.DEFAULT_MAX_ENTITY_SIZE); } - @Test - @Deprecated(since = "3.0.0", forRemoval = true) - @SuppressWarnings("removal") - void nettyMaxChunkSizeMatchesHttpDecoderSpecDefault() { - assertThat(this.properties.getNetty().getMaxChunkSize().toBytes()) - .isEqualTo(HttpDecoderSpec.DEFAULT_MAX_CHUNK_SIZE); - } - @Test void nettyMaxInitialLineLengthMatchesHttpDecoderSpecDefault() { assertThat(this.properties.getNetty().getMaxInitialLineLength().toBytes()) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java index c024fc15c6c..a4367e15064 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/JettyWebServerFactoryCustomizerTests.java @@ -263,30 +263,6 @@ class JettyWebServerFactoryCustomizerTests { then(factory).should().setUseForwardHeaders(true); } - @Test - void customizeMaxHttpHeaderSize() { - bind("server.max-http-header-size=2048"); - JettyWebServer server = customizeAndGetServer(); - List requestHeaderSizes = getRequestHeaderSizes(server); - assertThat(requestHeaderSizes).containsOnly(2048); - } - - @Test - void customMaxHttpHeaderSizeIgnoredIfNegative() { - bind("server.max-http-header-size=-1"); - JettyWebServer server = customizeAndGetServer(); - List requestHeaderSizes = getRequestHeaderSizes(server); - assertThat(requestHeaderSizes).containsOnly(8192); - } - - @Test - void customMaxHttpHeaderSizeIgnoredIfZero() { - bind("server.max-http-header-size=0"); - JettyWebServer server = customizeAndGetServer(); - List requestHeaderSizes = getRequestHeaderSizes(server); - assertThat(requestHeaderSizes).containsOnly(8192); - } - @Test void customizeMaxRequestHttpHeaderSize() { bind("server.max-http-request-header-size=2048"); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java index e2267a005a7..51945e666a5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java @@ -132,7 +132,6 @@ class NettyWebServerFactoryCustomizerTests { nettyProperties.setValidateHeaders(false); nettyProperties.setInitialBufferSize(DataSize.ofBytes(512)); nettyProperties.setH2cMaxContentLength(DataSize.ofKilobytes(1)); - setMaxChunkSize(nettyProperties); nettyProperties.setMaxInitialLineLength(DataSize.ofKilobytes(32)); NettyReactiveWebServerFactory factory = mock(NettyReactiveWebServerFactory.class); this.customizer.customize(factory); @@ -143,20 +142,9 @@ class NettyWebServerFactoryCustomizerTests { assertThat(decoder.validateHeaders()).isFalse(); assertThat(decoder.initialBufferSize()).isEqualTo(nettyProperties.getInitialBufferSize().toBytes()); assertThat(decoder.h2cMaxContentLength()).isEqualTo(nettyProperties.getH2cMaxContentLength().toBytes()); - assertMaxChunkSize(nettyProperties, decoder); assertThat(decoder.maxInitialLineLength()).isEqualTo(nettyProperties.getMaxInitialLineLength().toBytes()); } - @SuppressWarnings("removal") - private void setMaxChunkSize(ServerProperties.Netty nettyProperties) { - nettyProperties.setMaxChunkSize(DataSize.ofKilobytes(16)); - } - - @SuppressWarnings({ "deprecation", "removal" }) - private void assertMaxChunkSize(ServerProperties.Netty nettyProperties, HttpRequestDecoderSpec decoder) { - assertThat(decoder.maxChunkSize()).isEqualTo(nettyProperties.getMaxChunkSize().toBytes()); - } - private void verifyConnectionTimeout(NettyReactiveWebServerFactory factory, Integer expected) { if (expected == null) { then(factory).should(never()).addServerCustomizers(any(NettyServerCustomizer.class)); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java index c24b4f179cd..f885699393a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java @@ -176,47 +176,6 @@ class TomcatWebServerFactoryCustomizerTests { (server) -> assertThat(server.getTomcat().getConnector().getMaxPostSize()).isEqualTo(10000)); } - @Test - void customMaxHttpHeaderSize() { - bind("server.max-http-header-size=1KB"); - customizeAndRunServer((server) -> assertThat( - ((AbstractHttp11Protocol) server.getTomcat().getConnector().getProtocolHandler()) - .getMaxHttpRequestHeaderSize()) - .isEqualTo(DataSize.ofKilobytes(1).toBytes())); - } - - @Test - void customMaxHttpHeaderSizeWithHttp2() { - bind("server.max-http-header-size=1KB", "server.http2.enabled=true"); - customizeAndRunServer((server) -> { - AbstractHttp11Protocol protocolHandler = (AbstractHttp11Protocol) server.getTomcat() - .getConnector() - .getProtocolHandler(); - long expectedSize = DataSize.ofKilobytes(1).toBytes(); - assertThat(protocolHandler.getMaxHttpRequestHeaderSize()).isEqualTo(expectedSize); - assertThat(((Http2Protocol) protocolHandler.getUpgradeProtocol("h2c")).getMaxHeaderSize()) - .isEqualTo(expectedSize); - }); - } - - @Test - void customMaxHttpHeaderSizeIgnoredIfNegative() { - bind("server.max-http-header-size=-1"); - customizeAndRunServer((server) -> assertThat( - ((AbstractHttp11Protocol) server.getTomcat().getConnector().getProtocolHandler()) - .getMaxHttpRequestHeaderSize()) - .isEqualTo(DataSize.ofKilobytes(8).toBytes())); - } - - @Test - void customMaxHttpHeaderSizeIgnoredIfZero() { - bind("server.max-http-header-size=0"); - customizeAndRunServer((server) -> assertThat( - ((AbstractHttp11Protocol) server.getTomcat().getConnector().getProtocolHandler()) - .getMaxHttpRequestHeaderSize()) - .isEqualTo(DataSize.ofKilobytes(8).toBytes())); - } - @Test void defaultMaxHttpRequestHeaderSize() { customizeAndRunServer((server) -> assertThat( @@ -436,16 +395,6 @@ class TomcatWebServerFactoryCustomizerTests { assertThat(factory.getEngineValves()).isEmpty(); } - @Test - @Deprecated(since = "2.7.12", forRemoval = true) - void testCustomizeRejectIllegalHeader() { - bind("server.tomcat.reject-illegal-header=false"); - customizeAndRunServer((server) -> assertThat( - ((AbstractHttp11Protocol) server.getTomcat().getConnector().getProtocolHandler()) - .getRejectIllegalHeader()) - .isFalse()); - } - @Test void errorReportValveIsConfiguredToNotReportStackTraces() { TomcatWebServer server = customizeAndGetServer(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java index 15289d60e41..e5a2c95e827 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java @@ -86,20 +86,20 @@ class UndertowWebServerFactoryCustomizerTests { } @Test - void customMaxHttpHeaderSize() { - bind("server.max-http-header-size=2048"); + void customMaxHttpRequestHeaderSize() { + bind("server.max-http-request-header-size=2048"); assertThat(boundServerOption(UndertowOptions.MAX_HEADER_SIZE)).isEqualTo(2048); } @Test - void customMaxHttpHeaderSizeIgnoredIfNegative() { - bind("server.max-http-header-size=-1"); + void customMaxHttpRequestHeaderSizeIgnoredIfNegative() { + bind("server.max-http-request-header-size=-1"); assertThat(boundServerOption(UndertowOptions.MAX_HEADER_SIZE)).isNull(); } @Test - void customMaxHttpHeaderSizeIgnoredIfZero() { - bind("server.max-http-header-size=0"); + void customMaxHttpRequestHeaderSizeIgnoredIfZero() { + bind("server.max-http-request-header-size=0"); assertThat(boundServerOption(UndertowOptions.MAX_HEADER_SIZE)).isNull(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java index 7cff1379844..c428ff17819 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryCustomizerTests.java @@ -28,11 +28,11 @@ import org.springframework.boot.context.properties.bind.Bindable; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.boot.context.properties.source.ConfigurationPropertySource; import org.springframework.boot.context.properties.source.MapConfigurationPropertySource; +import org.springframework.boot.web.server.Cookie; import org.springframework.boot.web.server.Shutdown; import org.springframework.boot.web.server.Ssl; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; import org.springframework.boot.web.servlet.server.Jsp; -import org.springframework.boot.web.servlet.server.Session.Cookie; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -97,7 +97,6 @@ class ServletWebServerFactoryCustomizerTests { } @Test - @SuppressWarnings("removal") void customizeSessionProperties() { Map map = new HashMap<>(); map.put("server.servlet.session.timeout", "123"); @@ -105,7 +104,6 @@ class ServletWebServerFactoryCustomizerTests { map.put("server.servlet.session.cookie.name", "testname"); map.put("server.servlet.session.cookie.domain", "testdomain"); map.put("server.servlet.session.cookie.path", "/testpath"); - map.put("server.servlet.session.cookie.comment", "testcomment"); map.put("server.servlet.session.cookie.http-only", "true"); map.put("server.servlet.session.cookie.secure", "true"); map.put("server.servlet.session.cookie.max-age", "60"); @@ -118,7 +116,6 @@ class ServletWebServerFactoryCustomizerTests { assertThat(cookie.getName()).isEqualTo("testname"); assertThat(cookie.getDomain()).isEqualTo("testdomain"); assertThat(cookie.getPath()).isEqualTo("/testpath"); - assertThat(cookie.getComment()).isEqualTo("testcomment"); assertThat(cookie.getHttpOnly()).isTrue(); assertThat(cookie.getMaxAge()).hasSeconds(60); })); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index 4b8737d0424..c2ebbb6d158 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -380,29 +380,6 @@ class WebMvcAutoConfigurationTests { }); } - @Test - @Deprecated(since = "3.0.0", forRemoval = true) - @SuppressWarnings("deprecation") - void customThemeResolverWithMatchingNameReplacesDefaultThemeResolver() { - this.contextRunner.withBean("themeResolver", CustomThemeResolver.class, CustomThemeResolver::new) - .run((context) -> { - assertThat(context).hasSingleBean(org.springframework.web.servlet.ThemeResolver.class); - assertThat(context.getBean("themeResolver")).isInstanceOf(CustomThemeResolver.class); - }); - } - - @Test - @Deprecated(since = "3.0.0", forRemoval = true) - @SuppressWarnings("deprecation") - void customThemeResolverWithDifferentNameDoesNotReplaceDefaultThemeResolver() { - this.contextRunner.withBean("customThemeResolver", CustomThemeResolver.class, CustomThemeResolver::new) - .run((context) -> { - assertThat(context.getBean("customThemeResolver")).isInstanceOf(CustomThemeResolver.class); - assertThat(context.getBean("themeResolver")) - .isInstanceOf(org.springframework.web.servlet.theme.FixedThemeResolver.class); - }); - } - @Test void customFlashMapManagerWithMatchingNameReplacesDefaultFlashMapManager() { this.contextRunner.withBean("flashMapManager", CustomFlashMapManager.class, CustomFlashMapManager::new) @@ -493,21 +470,6 @@ class WebMvcAutoConfigurationTests { .isNotNull()); } - @Test - void ignoreDefaultModelOnRedirectIsTrue() { - this.contextRunner.run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class)) - .extracting("ignoreDefaultModelOnRedirect") - .isEqualTo(true)); - } - - @Test - void overrideIgnoreDefaultModelOnRedirect() { - this.contextRunner.withPropertyValues("spring.mvc.ignore-default-model-on-redirect:false") - .run((context) -> assertThat(context.getBean(RequestMappingHandlerAdapter.class)) - .extracting("ignoreDefaultModelOnRedirect") - .isEqualTo(false)); - } - @Test void customViewResolver() { this.contextRunner.withUserConfiguration(CustomViewResolver.class) @@ -1464,20 +1426,6 @@ class WebMvcAutoConfigurationTests { } - @Deprecated(since = "3.0.0", forRemoval = true) - static class CustomThemeResolver implements org.springframework.web.servlet.ThemeResolver { - - @Override - public String resolveThemeName(HttpServletRequest request) { - return "custom"; - } - - @Override - public void setThemeName(HttpServletRequest request, HttpServletResponse response, String themeName) { - } - - } - static class CustomFlashMapManager extends AbstractFlashMapManager { @Override diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListener.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListener.java deleted file mode 100644 index e3fbb4d61b9..00000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListener.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2012-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure; - -import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport; -import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportMessage; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.test.context.ApplicationContextFailureProcessor; -import org.springframework.test.context.TestContext; -import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; - -/** - * Since 3.0.0 this class has been replaced by - * {@link ConditionReportApplicationContextFailureProcessor} and is not used internally. - * - * @author Phillip Webb - * @since 1.4.1 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link ApplicationContextFailureProcessor} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -public class SpringBootDependencyInjectionTestExecutionListener extends DependencyInjectionTestExecutionListener { - - @Override - public void prepareTestInstance(TestContext testContext) throws Exception { - try { - super.prepareTestInstance(testContext); - } - catch (Exception ex) { - outputConditionEvaluationReport(testContext); - throw ex; - } - } - - private void outputConditionEvaluationReport(TestContext testContext) { - try { - ApplicationContext context = testContext.getApplicationContext(); - if (context instanceof ConfigurableApplicationContext configurableContext) { - ConditionEvaluationReport report = ConditionEvaluationReport.get(configurableContext.getBeanFactory()); - System.err.println(new ConditionEvaluationReportMessage(report)); - } - } - catch (Exception ex) { - // Allow original failure to be reported - } - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetrics.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetrics.java deleted file mode 100644 index 44ec896236d..00000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetrics.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.actuate.metrics; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability; - -/** - * Annotation that can be applied to a test class to enable auto-configuration for metrics - * exporters. - * - * @author Chris Bono - * @since 2.4.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link AutoConfigureObservability @AutoConfigureObservability} - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Inherited -@Deprecated(since = "3.0.0", forRemoval = true) -@AutoConfigureObservability(tracing = false) -public @interface AutoConfigureMetrics { - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/metrics/package-info.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/metrics/package-info.java deleted file mode 100644 index 6dfcc180e66..00000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/actuate/metrics/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012-2020 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Auto-configuration for handling metrics in tests. - */ -package org.springframework.boot.test.autoconfigure.actuate.metrics; diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetricsMissingIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetricsMissingIntegrationTests.java deleted file mode 100644 index ff4e924a993..00000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetricsMissingIntegrationTests.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.actuate.metrics; - -import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.simple.SimpleMeterRegistry; -import io.micrometer.prometheus.PrometheusMeterRegistry; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.ApplicationContext; -import org.springframework.core.env.Environment; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration test to verify behaviour when - * {@link AutoConfigureMetrics @AutoConfigureMetrics} is not present on the test class. - * - * @author Chris Bono - */ -@SpringBootTest -class AutoConfigureMetricsMissingIntegrationTests { - - @Test - void customizerRunsAndOnlyEnablesSimpleMeterRegistryWhenNoAnnotationPresent( - @Autowired ApplicationContext applicationContext) { - assertThat(applicationContext.getBean(MeterRegistry.class)).isInstanceOf(SimpleMeterRegistry.class); - assertThat(applicationContext.getBeansOfType(PrometheusMeterRegistry.class)).isEmpty(); - } - - @Test - void customizerRunsAndSetsExclusionPropertiesWhenNoAnnotationPresent(@Autowired Environment environment) { - assertThat(environment.getProperty("management.defaults.metrics.export.enabled")).isEqualTo("false"); - assertThat(environment.getProperty("management.simple.metrics.export.enabled")).isEqualTo("true"); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetricsPresentIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetricsPresentIntegrationTests.java deleted file mode 100644 index dfdef02bdb2..00000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetricsPresentIntegrationTests.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.actuate.metrics; - -import io.micrometer.prometheus.PrometheusMeterRegistry; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.ApplicationContext; -import org.springframework.core.env.Environment; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration test to verify behaviour when - * {@link AutoConfigureMetrics @AutoConfigureMetrics} is present on the test class. - * - * @author Chris Bono - */ -@SuppressWarnings("removal") -@SpringBootTest -@AutoConfigureMetrics -@Deprecated(since = "3.0.0", forRemoval = true) -class AutoConfigureMetricsPresentIntegrationTests { - - @Test - void customizerDoesNotDisableAvailableMeterRegistriesWhenAnnotationPresent( - @Autowired ApplicationContext applicationContext) { - assertThat(applicationContext.getBeansOfType(PrometheusMeterRegistry.class)).hasSize(1); - } - - @Test - void customizerDoesNotSetExclusionPropertiesWhenAnnotationPresent(@Autowired Environment environment) { - assertThat(environment.containsProperty("management.defaults.metrics.export.enabled")).isFalse(); - assertThat(environment.containsProperty("management.simple.metrics.export.enabled")).isFalse(); - } - -} diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetricsSpringBootApplication.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetricsSpringBootApplication.java deleted file mode 100644 index 31c699a44b8..00000000000 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/actuate/metrics/AutoConfigureMetricsSpringBootApplication.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.autoconfigure.actuate.metrics; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration; -import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; -import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration; - -/** - * Example {@link SpringBootApplication @SpringBootApplication} for use with - * {@link AutoConfigureMetrics @AutoConfigureMetrics} tests. - * - * @author Chris Bono - */ -@SpringBootConfiguration -@EnableAutoConfiguration(exclude = { CassandraAutoConfiguration.class, MongoAutoConfiguration.class, - MongoReactiveAutoConfiguration.class }) -class AutoConfigureMetricsSpringBootApplication { - -} diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/DefaultTestExecutionListenersPostProcessor.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/DefaultTestExecutionListenersPostProcessor.java deleted file mode 100644 index 695c3f460f6..00000000000 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/DefaultTestExecutionListenersPostProcessor.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.context; - -import java.util.List; - -import org.springframework.test.context.ApplicationContextFailureProcessor; -import org.springframework.test.context.TestExecutionListener; - -/** - * Callback interface trigger from {@link SpringBootTestContextBootstrapper} that can be - * used to post-process the list of default {@link TestExecutionListener - * TestExecutionListeners} to be used by a test. Can be used to add or remove existing - * listeners. - * - * @author Phillip Webb - * @since 1.4.1 - * @deprecated since 3.0.0 removal in 3.2.0 in favor of - * {@link ApplicationContextFailureProcessor} - */ -@FunctionalInterface -@Deprecated(since = "3.0.0", forRemoval = true) -public interface DefaultTestExecutionListenersPostProcessor { - - /** - * Post process the list of default {@link TestExecutionListener listeners} to be - * used. - * @param listeners the source listeners - * @return the actual listeners that should be used - * @since 3.0.0 - */ - List postProcessDefaultTestExecutionListeners(List listeners); - -} diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java index 0f812a30ebb..ce07386b1a7 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java @@ -38,7 +38,6 @@ import org.springframework.core.annotation.MergedAnnotation; import org.springframework.core.annotation.MergedAnnotations; import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; import org.springframework.core.env.Environment; -import org.springframework.core.io.support.SpringFactoriesLoader; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfigurationAttributes; import org.springframework.test.context.ContextCustomizer; @@ -48,7 +47,6 @@ import org.springframework.test.context.MergedContextConfiguration; import org.springframework.test.context.TestContext; import org.springframework.test.context.TestContextAnnotationUtils; import org.springframework.test.context.TestContextBootstrapper; -import org.springframework.test.context.TestExecutionListener; import org.springframework.test.context.aot.AotTestAttributes; import org.springframework.test.context.support.DefaultTestContextBootstrapper; import org.springframework.test.context.support.TestPropertySourceUtils; @@ -122,18 +120,6 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr return context; } - @Override - @SuppressWarnings("removal") - protected List getDefaultTestExecutionListeners() { - List listeners = new ArrayList<>(super.getDefaultTestExecutionListeners()); - List postProcessors = SpringFactoriesLoader - .loadFactories(DefaultTestExecutionListenersPostProcessor.class, getClass().getClassLoader()); - for (DefaultTestExecutionListenersPostProcessor postProcessor : postProcessors) { - listeners = postProcessor.postProcessDefaultTestExecutionListeners(listeners); - } - return listeners; - } - @Override protected ContextLoader resolveContextLoader(Class testClass, List configAttributesList) { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/bootstrap/SpringBootTestContextBootstrapperIntegrationTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/bootstrap/SpringBootTestContextBootstrapperIntegrationTests.java index 38edac15537..fb275a756e0 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/bootstrap/SpringBootTestContextBootstrapperIntegrationTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/bootstrap/SpringBootTestContextBootstrapperIntegrationTests.java @@ -45,8 +45,6 @@ class SpringBootTestContextBootstrapperIntegrationTests { @Autowired private SpringBootTestContextBootstrapperExampleConfig config; - boolean defaultTestExecutionListenersPostProcessorCalled = false; - @Test void findConfigAutomatically() { assertThat(this.config).isNotNull(); @@ -62,11 +60,6 @@ class SpringBootTestContextBootstrapperIntegrationTests { assertThat(this.context.getBean(ExampleBean.class)).isNotNull(); } - @Test - void defaultTestExecutionListenersPostProcessorShouldBeCalled() { - assertThat(this.defaultTestExecutionListenersPostProcessorCalled).isTrue(); - } - @TestConfiguration(proxyBeanMethods = false) static class TestConfig { diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/bootstrap/TestDefaultTestExecutionListenersPostProcessor.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/bootstrap/TestDefaultTestExecutionListenersPostProcessor.java deleted file mode 100644 index 7587c23f93f..00000000000 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/bootstrap/TestDefaultTestExecutionListenersPostProcessor.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.test.context.bootstrap; - -import java.util.List; - -import org.springframework.boot.test.context.DefaultTestExecutionListenersPostProcessor; -import org.springframework.test.context.TestContext; -import org.springframework.test.context.TestExecutionListener; -import org.springframework.test.context.support.AbstractTestExecutionListener; - -/** - * Test {@link DefaultTestExecutionListenersPostProcessor}. - * - * @author Phillip Webb - */ -@SuppressWarnings("removal") -public class TestDefaultTestExecutionListenersPostProcessor implements DefaultTestExecutionListenersPostProcessor { - - @Override - public List postProcessDefaultTestExecutionListeners(List listeners) { - listeners.add(new ExampleTestExecutionListener()); - return listeners; - } - - static class ExampleTestExecutionListener extends AbstractTestExecutionListener { - - @Override - public void prepareTestInstance(TestContext testContext) throws Exception { - Object testInstance = testContext.getTestInstance(); - if (testInstance instanceof SpringBootTestContextBootstrapperIntegrationTests test) { - test.defaultTestExecutionListenersPostProcessorCalled = true; - } - } - - } - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolverTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolverTests.java index 9f85011de40..4f45a734cb1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolverTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolverTests.java @@ -146,17 +146,6 @@ class PropertyDescriptorResolverTests { .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); } - @Test - @Deprecated(since = "3.0.0", forRemoval = true) - @SuppressWarnings("removal") - void propertiesWithMultiConstructorAndDeprecatedAnnotation() { - process(org.springframework.boot.configurationsample.immutable.DeprecatedImmutableMultiConstructorProperties.class, - propertyNames((stream) -> assertThat(stream).containsExactly("name", "description"))); - process(org.springframework.boot.configurationsample.immutable.DeprecatedImmutableMultiConstructorProperties.class, - properties((stream) -> assertThat(stream) - .allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); - } - @Test void propertiesWithMultiConstructorNoDirective() { process(TwoConstructorsExample.class, propertyNames((stream) -> assertThat(stream).containsExactly("name"))); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/DeprecatedConstructorBinding.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/DeprecatedConstructorBinding.java deleted file mode 100644 index ee1ae440f81..00000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/DeprecatedConstructorBinding.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.configurationsample; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Alternative to Spring Boot's deprecated - * {@code @org.springframework.boot.context.properties.ConstructorBinding} for testing - * (removes the need for a dependency on the real annotation). - * - * @author Stephane Nicoll - */ -@Target(ElementType.CONSTRUCTOR) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@ConstructorBinding -@Deprecated(since = "3.0.0", forRemoval = true) -public @interface DeprecatedConstructorBinding { - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/immutable/DeprecatedImmutableMultiConstructorProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/immutable/DeprecatedImmutableMultiConstructorProperties.java deleted file mode 100644 index d2e0305fc14..00000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/immutable/DeprecatedImmutableMultiConstructorProperties.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.configurationsample.immutable; - -/** - * Simple immutable properties with several constructors. - * - * @author Stephane Nicoll - */ -@SuppressWarnings("unused") -@Deprecated(since = "3.0.0", forRemoval = true) -public class DeprecatedImmutableMultiConstructorProperties { - - private final String name; - - /** - * Test description. - */ - private final String description; - - public DeprecatedImmutableMultiConstructorProperties(String name) { - this(name, null); - } - - @SuppressWarnings("removal") - @org.springframework.boot.configurationsample.DeprecatedConstructorBinding - public DeprecatedImmutableMultiConstructorProperties(String name, String description) { - this.name = name; - this.description = description; - } - -} diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationProperties.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationProperties.java index 86510c2b53a..7c8c41e05ad 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationProperties.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2023 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,6 +22,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.springframework.boot.context.properties.bind.ConstructorBinding; import org.springframework.core.annotation.AliasFor; import org.springframework.stereotype.Indexed; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBinding.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBinding.java deleted file mode 100644 index 49c95249ee9..00000000000 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBinding.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.context.properties; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation that can be used to indicate which constructor to use when binding - * configuration properties using constructor arguments rather than by calling setters. A - * single parameterized constructor implicitly indicates that constructor binding should - * be used unless the constructor is annotated with `@Autowired`. - *

- * Note: To use constructor binding the class must be enabled using - * {@link EnableConfigurationProperties @EnableConfigurationProperties} or configuration - * property scanning. Constructor binding cannot be used with beans that are created by - * the regular Spring mechanisms (e.g. - * {@link org.springframework.stereotype.Component @Component} beans, beans created via - * {@link org.springframework.context.annotation.Bean @Bean} methods or beans loaded using - * {@link org.springframework.context.annotation.Import @Import}). - * - * @author Phillip Webb - * @since 2.2.0 - * @see ConfigurationProperties - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link org.springframework.boot.context.properties.bind.ConstructorBinding} - */ -@Target({ ElementType.CONSTRUCTOR, ElementType.ANNOTATION_TYPE }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Deprecated(since = "3.0.0", forRemoval = true) -@org.springframework.boot.context.properties.bind.ConstructorBinding -public @interface ConstructorBinding { - -} diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBound.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBound.java index 4b1a4fea9e4..bd5fe6d92bd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBound.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConstructorBound.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2022 the original author or authors. + * Copyright 2019-2023 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. @@ -17,6 +17,7 @@ package org.springframework.boot.context.properties; import org.springframework.beans.factory.BeanFactory; +import org.springframework.boot.context.properties.bind.ConstructorBinding; /** * Helper class to programmatically bind configuration properties that use constructor diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonMixinModule.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonMixinModule.java index 09ed12dd40b..9364c73bf70 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonMixinModule.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonMixinModule.java @@ -16,14 +16,9 @@ package org.springframework.boot.jackson; -import java.util.Collection; - import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.module.SimpleModule; -import org.springframework.context.ApplicationContext; -import org.springframework.util.Assert; - /** * Spring Bean and Jackson {@link Module} to find and * {@link SimpleModule#setMixInAnnotation(Class, Class) register} @@ -36,22 +31,6 @@ import org.springframework.util.Assert; */ public class JsonMixinModule extends SimpleModule { - public JsonMixinModule() { - } - - /** - * Create a new {@link JsonMixinModule} instance. - * @param context the source application context - * @param basePackages the packages to check for annotated classes - * @deprecated since 3.0.0 in favor of - * {@link #registerEntries(JsonMixinModuleEntries, ClassLoader)} - */ - @Deprecated(since = "3.0.0", forRemoval = true) - public JsonMixinModule(ApplicationContext context, Collection basePackages) { - Assert.notNull(context, "Context must not be null"); - registerEntries(JsonMixinModuleEntries.scan(context, basePackages), context.getClassLoader()); - } - /** * Register the specified {@link JsonMixinModuleEntries entries}. * @param entries the entries to register to this instance diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/ClientHttpRequestFactorySupplier.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/ClientHttpRequestFactorySupplier.java deleted file mode 100644 index 7fce4e31cf0..00000000000 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/ClientHttpRequestFactorySupplier.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2012-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.web.client; - -import java.util.function.Supplier; - -import org.springframework.http.client.ClientHttpRequestFactory; - -/** - * A supplier for {@link ClientHttpRequestFactory} that detects the preferred candidate - * based on the available implementations on the classpath. - * - * @author Stephane Nicoll - * @author Moritz Halbritter - * @since 2.1.0 - * @deprecated since 3.0.0 for removal in 3.2.0 in favor of - * {@link ClientHttpRequestFactories} - */ -@Deprecated(since = "3.0.0", forRemoval = true) -public class ClientHttpRequestFactorySupplier implements Supplier { - - @Override - public ClientHttpRequestFactory get() { - return ClientHttpRequestFactories.get(ClientHttpRequestFactorySettings.DEFAULTS); - } - -} diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java index 93e4e1b9184..7f61703632b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java @@ -325,8 +325,9 @@ public class RestTemplateBuilder { } /** - * Set the {@link ClientHttpRequestFactorySupplier} that should be called each time we - * {@link #build()} a new {@link RestTemplate} instance. + * Set the request factory function that should be called to provide a + * {@link ClientHttpRequestFactory} each time we {@link #build()} a new + * {@link RestTemplate} instance. * @param requestFactoryFunction the settings to request factory function * @return a new builder instance * @since 3.0.0 diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactory.java index 349212d7e6c..04f62213500 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactory.java @@ -39,6 +39,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory; +import org.springframework.boot.web.server.Cookie; import org.springframework.boot.web.server.MimeMappings; import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.util.Assert; @@ -335,14 +336,12 @@ public abstract class AbstractServletWebServerFactory extends AbstractConfigurab configureSessionCookie(servletContext.getSessionCookieConfig()); } - @SuppressWarnings("removal") private void configureSessionCookie(SessionCookieConfig config) { - Session.Cookie cookie = this.session.getCookie(); + Cookie cookie = this.session.getCookie(); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); map.from(cookie::getName).to(config::setName); map.from(cookie::getDomain).to(config::setDomain); map.from(cookie::getPath).to(config::setPath); - map.from(cookie::getComment).to(config::setComment); map.from(cookie::getHttpOnly).to(config::setHttpOnly); map.from(cookie::getSecure).to(config::setSecure); map.from(cookie::getMaxAge).asInt(Duration::getSeconds).to(config::setMaxAge); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/Session.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/Session.java index 336c03ced54..df95dc47479 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/Session.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/Session.java @@ -21,8 +21,9 @@ import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.Set; -import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; +import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.boot.convert.DurationUnit; +import org.springframework.boot.web.server.Cookie; /** * Session properties. @@ -44,6 +45,7 @@ public class Session { */ private File storeDir; + @NestedConfigurationProperty private final Cookie cookie = new Cookie(); private final SessionStoreDirectory sessionStoreDirectory = new SessionStoreDirectory(); @@ -101,34 +103,6 @@ public class Session { return this.sessionStoreDirectory; } - /** - * Session cookie properties. - */ - public static class Cookie extends org.springframework.boot.web.server.Cookie { - - /** - * Comment for the session cookie. - */ - private String comment; - - /** - * Return the comment for the session cookie. - * @return the session cookie comment - * @deprecated since 3.0.0 without replacement - */ - @Deprecated(since = "3.0.0", forRemoval = true) - @DeprecatedConfigurationProperty - public String getComment() { - return this.comment; - } - - @Deprecated(since = "3.0.0", forRemoval = true) - public void setComment(String comment) { - this.comment = comment; - } - - } - /** * Available session tracking modes (mirrors * {@link jakarta.servlet.SessionTrackingMode}. diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanTests.java index f48d5be9527..7e361c87471 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanTests.java @@ -233,24 +233,6 @@ class ConfigurationPropertiesBeanTests { .isNotNull(); } - @Test - void forValueObjectWithDeprecatedConstructorBindingAnnotatedClassReturnsBean() { - ConfigurationPropertiesBean propertiesBean = ConfigurationPropertiesBean - .forValueObject(DeprecatedConstructorBindingOnConstructor.class, "valueObjectBean"); - assertThat(propertiesBean.getName()).isEqualTo("valueObjectBean"); - assertThat(propertiesBean.getInstance()).isNull(); - assertThat(propertiesBean.getType()).isEqualTo(DeprecatedConstructorBindingOnConstructor.class); - assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT); - assertThat(propertiesBean.getAnnotation()).isNotNull(); - Bindable target = propertiesBean.asBindTarget(); - assertThat(target.getType()) - .isEqualTo(ResolvableType.forClass(DeprecatedConstructorBindingOnConstructor.class)); - assertThat(target.getValue()).isNull(); - assertThat(BindConstructorProvider.DEFAULT.getBindConstructor(DeprecatedConstructorBindingOnConstructor.class, - false)) - .isNotNull(); - } - @Test void forValueObjectWithRecordReturnsBean() { Class implicitConstructorBinding = new ByteBuddy(ClassFileVersion.JAVA_V16).makeRecord() @@ -558,20 +540,6 @@ class ConfigurationPropertiesBeanTests { } - @ConfigurationProperties - @SuppressWarnings("removal") - static class DeprecatedConstructorBindingOnConstructor { - - DeprecatedConstructorBindingOnConstructor(String name) { - this(name, -1); - } - - @org.springframework.boot.context.properties.ConstructorBinding - DeprecatedConstructorBindingOnConstructor(String name, int age) { - } - - } - @ConfigurationProperties static class ConstructorBindingOnMultipleConstructors { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jackson/JsonMixinModuleTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jackson/JsonMixinModuleTests.java index 42bf7a8f818..768a1c0b8da 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jackson/JsonMixinModuleTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jackson/JsonMixinModuleTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.jackson; import java.util.Arrays; -import java.util.Collections; import java.util.List; import com.fasterxml.jackson.databind.Module; @@ -35,7 +34,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.util.ClassUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; /** * Tests for {@link JsonMixinModule}. @@ -53,14 +51,6 @@ class JsonMixinModuleTests { } } - @Test - @Deprecated(since = "3.0.0", forRemoval = true) - @SuppressWarnings("removal") - void createWhenContextIsNullShouldThrowException() { - assertThatIllegalArgumentException().isThrownBy(() -> new JsonMixinModule(null, Collections.emptyList())) - .withMessageContaining("Context must not be null"); - } - @Test void jsonWithModuleWithRenameMixInClassShouldBeMixedIn() throws Exception { load(RenameMixInClass.class); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java index 6e1851e72dc..46e8eb59ebf 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java @@ -120,11 +120,6 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); } - @Override - protected boolean isCookieCommentSupported() { - return false; - } - // JMX MBean names clash if you get more than one Engine with the same name... @Test void tomcatEngineNames() { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java index adadee3b8a0..12a9aea44cc 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java @@ -204,10 +204,6 @@ public abstract class AbstractServletWebServerFactoryTests { } } - protected boolean isCookieCommentSupported() { - return true; - } - @Test void startServlet() throws Exception { AbstractServletWebServerFactory factory = getFactory(); @@ -870,13 +866,11 @@ public abstract class AbstractServletWebServerFactoryTests { } @Test - @SuppressWarnings("removal") void sessionCookieConfiguration() { AbstractServletWebServerFactory factory = getFactory(); factory.getSession().getCookie().setName("testname"); factory.getSession().getCookie().setDomain("testdomain"); factory.getSession().getCookie().setPath("/testpath"); - factory.getSession().getCookie().setComment("testcomment"); factory.getSession().getCookie().setHttpOnly(true); factory.getSession().getCookie().setSecure(true); factory.getSession().getCookie().setMaxAge(Duration.ofSeconds(60)); @@ -886,9 +880,6 @@ public abstract class AbstractServletWebServerFactoryTests { assertThat(sessionCookieConfig.getName()).isEqualTo("testname"); assertThat(sessionCookieConfig.getDomain()).isEqualTo("testdomain"); assertThat(sessionCookieConfig.getPath()).isEqualTo("/testpath"); - if (isCookieCommentSupported()) { - assertThat(sessionCookieConfig.getComment()).isEqualTo("testcomment"); - } assertThat(sessionCookieConfig.isHttpOnly()).isTrue(); assertThat(sessionCookieConfig.isSecure()).isTrue(); assertThat(sessionCookieConfig.getMaxAge()).isEqualTo(60); @@ -1143,7 +1134,6 @@ public abstract class AbstractServletWebServerFactoryTests { } @Test - @SuppressWarnings("removal") void sessionConfiguration() { AbstractServletWebServerFactory factory = getFactory(); factory.getSession().setTimeout(Duration.ofSeconds(123)); @@ -1151,7 +1141,6 @@ public abstract class AbstractServletWebServerFactoryTests { factory.getSession().getCookie().setName("testname"); factory.getSession().getCookie().setDomain("testdomain"); factory.getSession().getCookie().setPath("/testpath"); - factory.getSession().getCookie().setComment("testcomment"); factory.getSession().getCookie().setHttpOnly(true); factory.getSession().getCookie().setSecure(true); factory.getSession().getCookie().setMaxAge(Duration.ofMinutes(1)); @@ -1163,9 +1152,6 @@ public abstract class AbstractServletWebServerFactoryTests { assertThat(servletContext.getSessionCookieConfig().getName()).isEqualTo("testname"); assertThat(servletContext.getSessionCookieConfig().getDomain()).isEqualTo("testdomain"); assertThat(servletContext.getSessionCookieConfig().getPath()).isEqualTo("/testpath"); - if (isCookieCommentSupported()) { - assertThat(servletContext.getSessionCookieConfig().getComment()).isEqualTo("testcomment"); - } assertThat(servletContext.getSessionCookieConfig().isHttpOnly()).isTrue(); assertThat(servletContext.getSessionCookieConfig().isSecure()).isTrue(); assertThat(servletContext.getSessionCookieConfig().getMaxAge()).isEqualTo(60);