Skip to content

Commit

Permalink
Remove deprecated methods
Browse files Browse the repository at this point in the history
Closes gh-33123
  • Loading branch information
rstoyanchev committed Jul 18, 2024
1 parent 9409543 commit ade8128
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 290 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,16 +16,13 @@

package org.springframework.web.bind;

import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.springframework.context.MessageSource;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ProblemDetail;
import org.springframework.lang.Nullable;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
Expand Down Expand Up @@ -92,45 +89,6 @@ public Object[] getDetailMessageArguments() {
BindErrorUtils.resolveAndJoin(getFieldErrors())};
}

/**
* Convert each given {@link ObjectError} to a String.
* @since 6.0
* @deprecated in favor of using {@link BindErrorUtils} and
* {@link #getAllErrors()}, to be removed in 6.2
*/
@Deprecated(since = "6.1", forRemoval = true)
public static List<String> errorsToStringList(List<? extends ObjectError> errors) {
return BindErrorUtils.resolve(errors).values().stream().toList();
}

/**
* Convert each given {@link ObjectError} to a String, and use a
* {@link MessageSource} to resolve each error.
* @since 6.0
* @deprecated in favor of {@link BindErrorUtils}, to be removed in 6.2
*/
@Deprecated(since = "6.1", forRemoval = true)
public static List<String> errorsToStringList(
List<? extends ObjectError> errors, @Nullable MessageSource messageSource, Locale locale) {

return (messageSource != null ?
BindErrorUtils.resolve(errors, messageSource, locale).values().stream().toList() :
BindErrorUtils.resolve(errors).values().stream().toList());
}

/**
* Resolve global and field errors to messages with the given
* {@link MessageSource} and {@link Locale}.
* @return a Map with errors as keys and resolved messages as values
* @since 6.0.3
* @deprecated in favor of using {@link BindErrorUtils} and
* {@link #getAllErrors()}, to be removed in 6.2
*/
@Deprecated(since = "6.1", forRemoval = true)
public Map<ObjectError, String> resolveErrorMessages(MessageSource messageSource, Locale locale) {
return BindErrorUtils.resolve(getAllErrors(), messageSource, locale);
}

@Override
public String getMessage() {
StringBuilder sb = new StringBuilder("Validation failed for argument [")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -78,19 +78,6 @@ public Object[] getDetailMessageArguments(MessageSource source, Locale locale) {
BindErrorUtils.resolveAndJoin(getFieldErrors(), source, locale)};
}

/**
* Resolve global and field errors to messages with the given
* {@link MessageSource} and {@link Locale}.
* @return a Map with errors as key and resolves messages as value
* @since 6.0.3
* @deprecated in favor of using {@link BindErrorUtils} and
* {@link #getAllErrors()}, to be removed in 6.2
*/
@Deprecated(since = "6.1", forRemoval = true)
public Map<ObjectError, String> resolveErrorMessages(MessageSource messageSource, Locale locale) {
return BindErrorUtils.resolve(getAllErrors(), messageSource, locale);
}


// BindingResult implementation methods

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,10 +23,6 @@
import java.util.List;
import java.util.Map;

import org.reactivestreams.Publisher;

import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
Expand Down Expand Up @@ -80,22 +76,6 @@ public class HttpRequestValues {
private final Object bodyValue;


/**
* Constructor without UriBuilderFactory.
* @deprecated in favour of
* {@link HttpRequestValues#HttpRequestValues(HttpMethod, URI, UriBuilderFactory, String, Map, HttpHeaders, MultiValueMap, Map, Object)}
* to be removed in 6.2.
*/
@Deprecated(since = "6.1", forRemoval = true)
protected HttpRequestValues(@Nullable HttpMethod httpMethod,
@Nullable URI uri, @Nullable String uriTemplate,
Map<String, String> uriVariables,
HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes,
@Nullable Object bodyValue) {

this(httpMethod, uri, null, uriTemplate, uriVariables, headers, cookies, attributes, bodyValue);
}

/**
* Construct {@link HttpRequestValues}.
* @since 6.1
Expand Down Expand Up @@ -197,30 +177,6 @@ public Object getBodyValue() {
return this.bodyValue;
}

/**
* Return the request body as a Publisher.
* <p>This is mutually exclusive with {@link #getBodyValue()}.
* Only one of the two or neither is set.
* @deprecated in favor of {@link ReactiveHttpRequestValues#getBodyPublisher()};
* to be removed in 6.2
*/
@Deprecated(since = "6.1", forRemoval = true)
@Nullable
public Publisher<?> getBody() {
throw new UnsupportedOperationException();
}

/**
* Return the element type for a Publisher body.
* @deprecated in favor of {@link ReactiveHttpRequestValues#getBodyPublisherElementType()};
* to be removed in 6.2
*/
@Deprecated(since = "6.1", forRemoval = true)
@Nullable
public ParameterizedTypeReference<?> getBodyElementType() {
throw new UnsupportedOperationException();
}


public static Builder builder() {
return new Builder();
Expand Down Expand Up @@ -383,17 +339,6 @@ public Builder addRequestPart(String name, Object part) {
return this;
}

/**
* Variant of {@link #addRequestPart(String, Object)} that allows the
* part value to be produced by a {@link Publisher}.
* @deprecated in favor of {@link ReactiveHttpRequestValues.Builder#addRequestPartPublisher};
* to be removed in 6.2
*/
@Deprecated(since = "6.1", forRemoval = true)
public <T, P extends Publisher<T>> Builder addRequestPart(String name, P publisher, ResolvableType type) {
throw new UnsupportedOperationException();
}

/**
* Configure an attribute to associate with the request.
* @param name the attribute name
Expand All @@ -412,18 +357,6 @@ public void setBodyValue(@Nullable Object bodyValue) {
this.bodyValue = bodyValue;
}

/**
* Set the request body as a Reactive Streams Publisher.
* <p>This is mutually exclusive with, and resets any previously set
* {@linkplain #setBodyValue(Object) body value}.
* @deprecated in favor of {@link ReactiveHttpRequestValues.Builder#setBodyPublisher};
* to be removed in 6.2
*/
@Deprecated(since = "6.1", forRemoval = true)
public <T, P extends Publisher<T>> void setBody(P body, ParameterizedTypeReference<T> elementTye) {
throw new UnsupportedOperationException();
}

/**
* Build the {@link HttpRequestValues} instance.
*/
Expand Down Expand Up @@ -513,24 +446,6 @@ private String appendQueryParams(
return uriComponentsBuilder.build().toUriString();
}

/**
* Create {@link HttpRequestValues} from values passed to the {@link Builder}.
* @deprecated in favour of
* {@link Builder#createRequestValues(HttpMethod, URI, UriBuilderFactory, String, Map, HttpHeaders, MultiValueMap, Map, Object)}
* to be removed in 6.2.
*/
@Deprecated(since = "6.1", forRemoval = true)
protected HttpRequestValues createRequestValues(
@Nullable HttpMethod httpMethod,
@Nullable URI uri, @Nullable String uriTemplate,
Map<String, String> uriVars,
HttpHeaders headers, MultiValueMap<String, String> cookies, Map<String, Object> attributes,
@Nullable Object bodyValue) {

return createRequestValues(httpMethod, uri, null, uriTemplate,
uriVars, headers, cookies, attributes, bodyValue);
}

/**
* Create {@link HttpRequestValues} from values passed to the {@link Builder}.
* @since 6.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,6 @@

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -32,7 +31,6 @@
import org.springframework.aop.framework.ReflectiveMethodInvocation;
import org.springframework.core.KotlinDetector;
import org.springframework.core.MethodIntrospector;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.convert.ConversionService;
import org.springframework.format.support.DefaultFormattingConversionService;
Expand Down Expand Up @@ -112,17 +110,6 @@ public static Builder builderFor(HttpExchangeAdapter exchangeAdapter) {
return new Builder().exchangeAdapter(exchangeAdapter);
}

/**
* Return a builder that's initialized with the given client.
* @deprecated in favor of {@link #builderFor(HttpExchangeAdapter)};
* to be removed in 6.2.
*/
@SuppressWarnings("removal")
@Deprecated(since = "6.1", forRemoval = true)
public static Builder builder(HttpClientAdapter clientAdapter) {
return new Builder().exchangeAdapter(clientAdapter.asReactorExchangeAdapter());
}

/**
* Return an empty builder, with the client to be provided to builder.
*/
Expand Down Expand Up @@ -161,20 +148,6 @@ public Builder exchangeAdapter(HttpExchangeAdapter adapter) {
return this;
}

/**
* Provide the HTTP client to perform requests through.
* @param clientAdapter a client adapted to {@link HttpClientAdapter}
* @return this same builder instance
* @deprecated in favor of {@link #exchangeAdapter(HttpExchangeAdapter)};
* to be removed in 6.2
*/
@SuppressWarnings("removal")
@Deprecated(since = "6.1", forRemoval = true)
public Builder clientAdapter(HttpClientAdapter clientAdapter) {
this.exchangeAdapter = clientAdapter.asReactorExchangeAdapter();
return this;
}

/**
* Register a custom argument resolver, invoked ahead of default resolvers.
* @param resolver the resolver to add
Expand Down Expand Up @@ -207,40 +180,6 @@ public Builder embeddedValueResolver(StringValueResolver embeddedValueResolver)
return this;
}

/**
* Set the {@link ReactiveAdapterRegistry} to use to support different
* asynchronous types for HTTP service method return values.
* <p>By default this is {@link ReactiveAdapterRegistry#getSharedInstance()}.
* @return this same builder instance
* @deprecated in favor of setting the same directly on the {@link HttpExchangeAdapter}
*/
@Deprecated(since = "6.1", forRemoval = true)
public Builder reactiveAdapterRegistry(ReactiveAdapterRegistry registry) {
if (this.exchangeAdapter instanceof AbstractReactorHttpExchangeAdapter settable) {
settable.setReactiveAdapterRegistry(registry);
}
return this;
}

/**
* Configure how long to block for the response of an HTTP service method
* with a synchronous (blocking) method signature.
* <p>By default this is not set, in which case the behavior depends on
* connection and request timeout settings of the underlying HTTP client.
* We recommend configuring timeout values directly on the underlying HTTP
* client, which provides more control over such settings.
* @param blockTimeout the timeout value
* @return this same builder instance
* @deprecated in favor of setting the same directly on the {@link HttpExchangeAdapter}
*/
@Deprecated(since = "6.1", forRemoval = true)
public Builder blockTimeout(@Nullable Duration blockTimeout) {
if (this.exchangeAdapter instanceof AbstractReactorHttpExchangeAdapter settable) {
settable.setBlockTimeout(blockTimeout);
}
return this;
}

/**
* Build the {@link HttpServiceProxyFactory} instance.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.reactivestreams.Publisher;

import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -80,28 +79,6 @@ public ParameterizedTypeReference<?> getBodyPublisherElementType() {
return this.bodyElementType;
}

/**
* Return the request body as a {@link Publisher}.
* <p>This is mutually exclusive with {@link #getBodyValue()}.
* Only one of the two or neither is set.
*/
@Override
@SuppressWarnings("removal")
@Nullable
public Publisher<?> getBody() {
return getBodyPublisher();
}

/**
* Return the element type for a {@linkplain #getBodyPublisher() body publisher}.
*/
@Override
@SuppressWarnings("removal")
@Nullable
public ParameterizedTypeReference<?> getBodyElementType() {
return getBodyPublisherElementType();
}


public static Builder builder() {
return new Builder();
Expand Down Expand Up @@ -211,12 +188,6 @@ public <T, P extends Publisher<T>> Builder addRequestPartPublisher(
return this;
}

@SuppressWarnings("removal")
@Override
public <T, P extends Publisher<T>> Builder addRequestPart(String name, P publisher, ResolvableType type) {
return addRequestPartPublisher(name, publisher, ParameterizedTypeReference.forType(type.getType()));
}

/**
* {@inheritDoc}
* <p>This is mutually exclusive with and resets any previously set
Expand All @@ -242,12 +213,6 @@ public <T, P extends Publisher<T>> void setBodyPublisher(P body, ParameterizedTy
super.setBodyValue(null);
}

@SuppressWarnings("removal")
@Override
public <T, P extends Publisher<T>> void setBody(P body, ParameterizedTypeReference<T> elementTye) {
setBodyPublisher(body, elementTye);
}

@Override
public ReactiveHttpRequestValues build() {
return (ReactiveHttpRequestValues) super.build();
Expand Down
Loading

0 comments on commit ade8128

Please sign in to comment.