parent
9409543dac
commit
ade8128060
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -92,45 +89,6 @@ public class MethodArgumentNotValidException extends BindException implements Er
|
|||
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 [")
|
||||
|
|
|
@ -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.
|
||||
|
@ -78,19 +78,6 @@ public class WebExchangeBindException extends ServerWebInputException implements
|
|||
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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -23,10 +23,6 @@ import java.util.LinkedHashMap;
|
|||
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;
|
||||
|
@ -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
|
||||
|
@ -197,30 +177,6 @@ public class HttpRequestValues {
|
|||
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();
|
||||
|
@ -383,17 +339,6 @@ public class HttpRequestValues {
|
|||
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
|
||||
|
@ -412,18 +357,6 @@ public class HttpRequestValues {
|
|||
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.
|
||||
*/
|
||||
|
@ -513,24 +446,6 @@ public class HttpRequestValues {
|
|||
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
|
||||
|
|
|
@ -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.
|
||||
|
@ -18,7 +18,6 @@ package org.springframework.web.service.invoker;
|
|||
|
||||
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;
|
||||
|
@ -32,7 +31,6 @@ import org.springframework.aop.framework.ProxyFactory;
|
|||
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;
|
||||
|
@ -112,17 +110,6 @@ public final class HttpServiceProxyFactory {
|
|||
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.
|
||||
*/
|
||||
|
@ -161,20 +148,6 @@ public final class HttpServiceProxyFactory {
|
|||
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
|
||||
|
@ -207,40 +180,6 @@ public final class HttpServiceProxyFactory {
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.Map;
|
|||
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;
|
||||
|
@ -80,28 +79,6 @@ public final class ReactiveHttpRequestValues extends HttpRequestValues {
|
|||
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();
|
||||
|
@ -211,12 +188,6 @@ public final class ReactiveHttpRequestValues extends HttpRequestValues {
|
|||
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
|
||||
|
@ -242,12 +213,6 @@ public final class ReactiveHttpRequestValues extends HttpRequestValues {
|
|||
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();
|
||||
|
|
|
@ -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.
|
||||
|
@ -155,16 +155,4 @@ public final class WebClientAdapter extends AbstractReactorHttpExchangeAdapter {
|
|||
return new WebClientAdapter(webClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link WebClientAdapter} for the given {@code WebClient} instance.
|
||||
* @param webClient the client to use
|
||||
* @return the created adapter instance
|
||||
* @deprecated in favor of {@link #create(WebClient)} aligning with other adapter
|
||||
* implementations; to be removed in 6.2.
|
||||
*/
|
||||
@Deprecated(since = "6.1", forRemoval = true)
|
||||
public static WebClientAdapter forClient(WebClient webClient) {
|
||||
return new WebClientAdapter(webClient);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -248,24 +248,9 @@ public class FreeMarkerView extends AbstractUrlBasedView {
|
|||
* multiple templates to be rendered into a single view.
|
||||
*/
|
||||
@Override
|
||||
public boolean checkResourceExists(Locale locale) throws Exception {
|
||||
try {
|
||||
// Check that we can get the template, even if we might subsequently get it again.
|
||||
getTemplate(locale);
|
||||
return true;
|
||||
}
|
||||
catch (FileNotFoundException ex) {
|
||||
// Allow for ViewResolver chaining...
|
||||
return false;
|
||||
}
|
||||
catch (ParseException ex) {
|
||||
throw new ApplicationContextException(
|
||||
"Failed to parse FreeMarker template for URL [" + getUrl() + "]", ex);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new ApplicationContextException(
|
||||
"Could not load FreeMarker template for URL [" + getUrl() + "]", ex);
|
||||
}
|
||||
public boolean checkResourceExists(Locale locale) {
|
||||
throw new UnsupportedOperationException(
|
||||
"This should never be called as we override resourceExists returning Mono<Boolean>");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -378,23 +363,6 @@ public class FreeMarkerView extends AbstractUrlBasedView {
|
|||
return (ow != null ? ow : new DefaultObjectWrapperBuilder(version).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the FreeMarker {@link Template} to be rendered by this view, for
|
||||
* the specified locale and using the {@linkplain #setEncoding(String) configured
|
||||
* encoding} if set.
|
||||
* <p>By default, the template specified by the "url" bean property will be retrieved.
|
||||
* @param locale the current locale
|
||||
* @return the FreeMarker template to render
|
||||
* @deprecated since 6.1, in favor of {@link #lookupTemplate(Locale)}, to be
|
||||
* removed in 6.2
|
||||
*/
|
||||
@Deprecated(since = "6.1", forRemoval = true)
|
||||
protected Template getTemplate(Locale locale) throws IOException {
|
||||
return (getEncoding() != null ?
|
||||
obtainConfiguration().getTemplate(getUrl(), locale, getEncoding()) :
|
||||
obtainConfiguration().getTemplate(getUrl(), locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the FreeMarker {@link Template} to be rendered by this view, for
|
||||
* the specified locale and using the {@linkplain #setEncoding(String) configured
|
||||
|
|
|
@ -91,11 +91,11 @@ class FreeMarkerViewTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void checkResourceExists() throws Exception {
|
||||
void checkResourceExists() {
|
||||
freeMarkerView.setConfiguration(this.freeMarkerConfig);
|
||||
freeMarkerView.setUrl("test.ftl");
|
||||
|
||||
assertThat(freeMarkerView.checkResourceExists(Locale.US)).isTrue();
|
||||
assertThat(freeMarkerView.resourceExists(Locale.US).block(Duration.ofSeconds(1))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue