From 91eb2be44cc40c33ee4e003c8cad509ff29b392e Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Tue, 27 Jun 2023 16:34:52 +0100 Subject: [PATCH] Remove no longer supported protected methods Closes gh-26721 --- .../ModelAttributeMethodProcessor.java | 49 ++----------------- .../ModelAttributeMethodArgumentResolver.java | 10 ---- 2 files changed, 3 insertions(+), 56 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java index 8faec818d2f3..e8e89c302723 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java @@ -17,7 +17,6 @@ package org.springframework.web.method.annotation; import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; import java.util.Map; import java.util.Optional; @@ -188,33 +187,16 @@ private static Object wrapAsOptionalIfNecessary(MethodParameter parameter, @Null * @param attributeName the name of the attribute (never {@code null}) * @param parameter the method parameter declaration * @param binderFactory for creating WebDataBinder instance - * @param webRequest the current request - * @return the created model attribute (never {@code null}) - * @throws BindException in case of constructor argument binding failure - * @throws Exception in case of constructor instantiation failure - * @see #constructAttribute(Constructor, String, MethodParameter, WebDataBinderFactory, NativeWebRequest) - * @see BeanUtils#findPrimaryConstructor(Class) + * @param request the current request + * @return the created model attribute, or {@code null} */ @Nullable protected Object createAttribute(String attributeName, MethodParameter parameter, - WebDataBinderFactory binderFactory, NativeWebRequest webRequest) throws Exception { + WebDataBinderFactory binderFactory, NativeWebRequest request) throws Exception { return null; } - /** - * Construct a new attribute instance with the given constructor. - * @since 5.1 - * @deprecated and not called; replaced by built-in support for - * constructor initialization in {@link org.springframework.validation.DataBinder} - */ - @Deprecated(since = "6.1", forRemoval = true) - protected Object constructAttribute(Constructor ctor, String attributeName, MethodParameter parameter, - WebDataBinderFactory binderFactory, NativeWebRequest webRequest) throws Exception { - - throw new UnsupportedOperationException(); - } - /** * Extension point to create the attribute, binding the request to constructor args. * @param binder the data binder instance to use for the binding @@ -234,18 +216,6 @@ protected void bindRequestParameters(WebDataBinder binder, NativeWebRequest requ ((WebRequestDataBinder) binder).bind(request); } - /** - * Resolve the value for a constructor argument. - * @deprecated and not called; replaced by built-in support for - * constructor initialization in {@link org.springframework.validation.DataBinder} - */ - @Deprecated(since = "6.1", forRemoval = true) - public Object resolveConstructorArgument(String paramName, Class paramType, NativeWebRequest request) - throws Exception { - - throw new UnsupportedOperationException(); - } - /** * Validate the model attribute if applicable. *

The default implementation checks for {@code @jakarta.validation.Valid}, @@ -266,19 +236,6 @@ protected void validateIfApplicable(WebDataBinder binder, MethodParameter parame } } - /** - * Validate the specified candidate value if applicable. - * @since 5.1 - * @deprecated and not called; replaced by built-in support for - * constructor initialization in {@link org.springframework.validation.DataBinder} - */ - @Deprecated(since = "6.1", forRemoval = true) - protected void validateValueIfApplicable(WebDataBinder binder, MethodParameter parameter, - Class targetType, String fieldName, @Nullable Object value) { - - throw new UnsupportedOperationException(); - } - /** * Whether to raise a fatal bind exception on validation errors. *

The default implementation delegates to {@link #isBindExceptionRequired(MethodParameter)}. diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java index a68f7fbae93e..73b5431dc9b6 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java @@ -181,16 +181,6 @@ private Object removeReactiveAttribute(String name, Model model) { return null; } - /** - * Protected method to obtain the values for data binding. - * @deprecated and not called; replaced by built-in support for - * constructor initialization in {@link org.springframework.validation.DataBinder} - */ - @Deprecated(since = "6.1", forRemoval = true) - public Mono> getValuesToBind(WebExchangeDataBinder binder, ServerWebExchange exchange) { - throw new UnsupportedOperationException(); - } - /** * Extension point to create the attribute, binding the request to constructor args. * @param binder the data binder instance to use for the binding