Remove deprecated code
Closes gh-29290
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* 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.
|
||||
@@ -38,33 +38,6 @@ public class InvocationContext {
|
||||
|
||||
private final List<OperationArgumentResolver> argumentResolvers;
|
||||
|
||||
/**
|
||||
* Creates a new context for an operation being invoked by the given
|
||||
* {@code securityContext} with the given available {@code arguments}.
|
||||
* @param securityContext the current security context. Never {@code null}
|
||||
* @param arguments the arguments available to the operation. Never {@code null}
|
||||
*/
|
||||
public InvocationContext(SecurityContext securityContext, Map<String, Object> arguments) {
|
||||
this(null, securityContext, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new context for an operation being invoked by the given
|
||||
* {@code securityContext} with the given available {@code arguments}.
|
||||
* @param apiVersion the API version or {@code null} to use the latest
|
||||
* @param securityContext the current security context. Never {@code null}
|
||||
* @param arguments the arguments available to the operation. Never {@code null}
|
||||
* @since 2.2.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link #InvocationContext(SecurityContext, Map, OperationArgumentResolver[])}
|
||||
*/
|
||||
@Deprecated
|
||||
public InvocationContext(org.springframework.boot.actuate.endpoint.http.ApiVersion apiVersion,
|
||||
SecurityContext securityContext, Map<String, Object> arguments) {
|
||||
this(securityContext, arguments, OperationArgumentResolver.of(ApiVersion.class,
|
||||
() -> (apiVersion != null) ? ApiVersion.valueOf(apiVersion.name()) : null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new context for an operation being invoked by the given
|
||||
* {@code securityContext} with the given available {@code arguments}.
|
||||
@@ -87,32 +60,6 @@ public class InvocationContext {
|
||||
this.argumentResolvers.add(OperationArgumentResolver.of(ApiVersion.class, () -> ApiVersion.LATEST));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the API version in use.
|
||||
* @return the apiVersion the API version
|
||||
* @since 2.2.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link #resolveArgument(Class)} using
|
||||
* {@link org.springframework.boot.actuate.endpoint.ApiVersion}
|
||||
*/
|
||||
@Deprecated
|
||||
public org.springframework.boot.actuate.endpoint.http.ApiVersion getApiVersion() {
|
||||
ApiVersion version = resolveArgument(ApiVersion.class);
|
||||
return (version != null) ? org.springframework.boot.actuate.endpoint.http.ApiVersion.valueOf(version.name())
|
||||
: org.springframework.boot.actuate.endpoint.http.ApiVersion.LATEST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the security context to use for the invocation.
|
||||
* @return the security context
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link #resolveArgument(Class)}
|
||||
*/
|
||||
@Deprecated
|
||||
public SecurityContext getSecurityContext() {
|
||||
return resolveArgument(SecurityContext.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the invocation arguments.
|
||||
* @return the arguments
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.http;
|
||||
|
||||
/**
|
||||
* Media types that can be consumed and produced by Actuator endpoints.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Madhura Bhave
|
||||
* @since 2.0.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link org.springframework.boot.actuate.endpoint.ApiVersion#getProducedMimeType()}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class ActuatorMediaType {
|
||||
|
||||
/**
|
||||
* Constant for the Actuator {@link ApiVersion#V2 v2} media type.
|
||||
*/
|
||||
public static final String V2_JSON = "application/vnd.spring-boot.actuator.v2+json";
|
||||
|
||||
/**
|
||||
* Constant for the Actuator {@link ApiVersion#V3 v3} media type.
|
||||
*/
|
||||
public static final String V3_JSON = "application/vnd.spring-boot.actuator.v3+json";
|
||||
|
||||
private ActuatorMediaType() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.http;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.ProducibleOperationArgumentResolver;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
|
||||
/**
|
||||
* API versions supported for the actuator HTTP API. This enum may be injected into
|
||||
* actuator endpoints in order to return a response compatible with the requested version.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.2.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link org.springframework.boot.actuate.endpoint.ApiVersion}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum ApiVersion {
|
||||
|
||||
/**
|
||||
* Version 2 (supported by Spring Boot 2.0+).
|
||||
*/
|
||||
V2,
|
||||
|
||||
/**
|
||||
* Version 3 (supported by Spring Boot 2.2+).
|
||||
*/
|
||||
V3;
|
||||
|
||||
private static final String MEDIA_TYPE_PREFIX = "application/vnd.spring-boot.actuator.";
|
||||
|
||||
/**
|
||||
* The latest API version.
|
||||
*/
|
||||
public static final ApiVersion LATEST = ApiVersion.V3;
|
||||
|
||||
/**
|
||||
* Return the {@link ApiVersion} to use based on the HTTP request headers. The version
|
||||
* will be deduced based on the {@code Accept} header.
|
||||
* @param headers the HTTP headers
|
||||
* @return the API version to use
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of direct injection with
|
||||
* resolution via the {@link ProducibleOperationArgumentResolver}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ApiVersion fromHttpHeaders(Map<String, List<String>> headers) {
|
||||
ApiVersion version = null;
|
||||
List<String> accepts = headers.get("Accept");
|
||||
if (!CollectionUtils.isEmpty(accepts)) {
|
||||
for (String accept : accepts) {
|
||||
for (String type : MimeTypeUtils.tokenize(accept)) {
|
||||
version = mostRecent(version, forType(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
return (version != null) ? version : LATEST;
|
||||
}
|
||||
|
||||
private static ApiVersion forType(String type) {
|
||||
if (type.startsWith(MEDIA_TYPE_PREFIX)) {
|
||||
type = type.substring(MEDIA_TYPE_PREFIX.length());
|
||||
int suffixIndex = type.indexOf('+');
|
||||
type = (suffixIndex != -1) ? type.substring(0, suffixIndex) : type;
|
||||
try {
|
||||
return valueOf(type.toUpperCase());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ApiVersion mostRecent(ApiVersion existing, ApiVersion candidate) {
|
||||
int existingOrdinal = (existing != null) ? existing.ordinal() : -1;
|
||||
int candidateOrdinal = (candidate != null) ? candidate.ordinal() : -1;
|
||||
return (candidateOrdinal > existingOrdinal) ? candidate : existing;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 endpoint HTTP concerns (not tied to any specific implementation).
|
||||
*/
|
||||
package org.springframework.boot.actuate.endpoint.http;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* 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.
|
||||
@@ -46,21 +46,6 @@ public class MetricsRepositoryMethodInvocationListener implements RepositoryMeth
|
||||
|
||||
private final AutoTimer autoTimer;
|
||||
|
||||
/**
|
||||
* Create a new {@code MetricsRepositoryMethodInvocationListener}.
|
||||
* @param registry the registry to which metrics are recorded
|
||||
* @param tagsProvider provider for metrics tags
|
||||
* @param metricName name of the metric to record
|
||||
* @param autoTimer the auto-timers to apply or {@code null} to disable auto-timing
|
||||
* @deprecated since 2.5.4 for removal in 2.7.0 in favor of
|
||||
* {@link #MetricsRepositoryMethodInvocationListener(Supplier, RepositoryTagsProvider, String, AutoTimer)}
|
||||
*/
|
||||
@Deprecated
|
||||
public MetricsRepositoryMethodInvocationListener(MeterRegistry registry, RepositoryTagsProvider tagsProvider,
|
||||
String metricName, AutoTimer autoTimer) {
|
||||
this(SingletonSupplier.of(registry), tagsProvider, metricName, autoTimer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code MetricsRepositoryMethodInvocationListener}.
|
||||
* @param registrySupplier a supplier for the registry to which metrics are recorded
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* 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.
|
||||
@@ -166,20 +166,6 @@ public final class WebFluxTags {
|
||||
return EXCEPTION_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@code outcome} tag based on the response status of the given
|
||||
* {@code exchange}.
|
||||
* @param exchange the exchange
|
||||
* @return the outcome tag derived from the response status
|
||||
* @since 2.1.0
|
||||
* @deprecated since 2.5.0 for removal in 2.7.0 in favor of
|
||||
* {@link #outcome(ServerWebExchange, Throwable)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static Tag outcome(ServerWebExchange exchange) {
|
||||
return outcome(exchange, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an {@code outcome} tag based on the response status of the given
|
||||
* {@code exchange} and the exception thrown during request processing.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* 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.
|
||||
@@ -36,20 +36,6 @@ class InvocationContextTests {
|
||||
|
||||
private final Map<String, Object> arguments = Collections.singletonMap("test", "value");
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void createWhenApiVersionIsNullUsesLatestVersion() {
|
||||
InvocationContext context = new InvocationContext(null, this.securityContext, this.arguments);
|
||||
assertThat(context.getApiVersion()).isEqualTo(org.springframework.boot.actuate.endpoint.http.ApiVersion.LATEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void whenCreatedWithoutApiVersionThenGetApiVersionReturnsLatestVersion() {
|
||||
InvocationContext context = new InvocationContext(this.securityContext, this.arguments);
|
||||
assertThat(context.getApiVersion()).isEqualTo(org.springframework.boot.actuate.endpoint.http.ApiVersion.LATEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenCreatedWithoutApiVersionThenResolveApiVersionReturnsLatestVersion() {
|
||||
InvocationContext context = new InvocationContext(this.securityContext, this.arguments);
|
||||
@@ -68,21 +54,6 @@ class InvocationContextTests {
|
||||
.withMessage("Arguments must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void getApiVersionReturnsApiVersion() {
|
||||
InvocationContext context = new InvocationContext(org.springframework.boot.actuate.endpoint.http.ApiVersion.V2,
|
||||
this.securityContext, this.arguments);
|
||||
assertThat(context.getApiVersion()).isEqualTo(org.springframework.boot.actuate.endpoint.http.ApiVersion.V2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void getSecurityContextReturnsSecurityContext() {
|
||||
InvocationContext context = new InvocationContext(this.securityContext, this.arguments);
|
||||
assertThat(context.getSecurityContext()).isEqualTo(this.securityContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveSecurityContextReturnsSecurityContext() {
|
||||
InvocationContext context = new InvocationContext(this.securityContext, this.arguments);
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.http;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link ApiVersion}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Deprecated
|
||||
class ApiVersionTests {
|
||||
|
||||
@Test
|
||||
void latestIsLatestVersion() {
|
||||
ApiVersion[] values = ApiVersion.values();
|
||||
assertThat(ApiVersion.LATEST).isEqualTo(values[values.length - 1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenEmptyReturnsLatest() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(Collections.emptyMap());
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasSingleV2HeaderReturnsV2() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader(ActuatorMediaType.V2_JSON));
|
||||
assertThat(version).isEqualTo(ApiVersion.V2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasSingleV3HeaderReturnsV3() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader(ActuatorMediaType.V3_JSON));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasV2AndV3HeaderReturnsV3() {
|
||||
ApiVersion version = ApiVersion
|
||||
.fromHttpHeaders(acceptHeader(ActuatorMediaType.V2_JSON, ActuatorMediaType.V3_JSON));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasV2AndV3AsOneHeaderReturnsV3() {
|
||||
ApiVersion version = ApiVersion
|
||||
.fromHttpHeaders(acceptHeader(ActuatorMediaType.V2_JSON + "," + ActuatorMediaType.V3_JSON));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasSingleHeaderWithoutJsonReturnsHeader() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader("application/vnd.spring-boot.actuator.v2"));
|
||||
assertThat(version).isEqualTo(ApiVersion.V2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenHasUnknownVersionReturnsLatest() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader("application/vnd.spring-boot.actuator.v200"));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void fromHttpHeadersWhenAcceptsEverythingReturnsLatest() {
|
||||
ApiVersion version = ApiVersion.fromHttpHeaders(acceptHeader("*/*"));
|
||||
assertThat(version).isEqualTo(ApiVersion.V3);
|
||||
}
|
||||
|
||||
private Map<String, List<String>> acceptHeader(String... types) {
|
||||
List<String> value = Arrays.asList(types);
|
||||
return value.isEmpty() ? Collections.emptyMap() : Collections.singletonMap("Accept", value);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user