From 220995b830863fe1870ab558ef21d0ad50fce1d1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 14 Jun 2023 21:52:55 +0200 Subject: [PATCH] Move HandlerMethodValidator to web.method.annotation package Avoiding cycle between web.method.support and web.method.annotation packages. See gh-29825 --- .../{support => annotation}/HandlerMethodValidator.java | 6 ++---- .../method/annotation/RequestMappingHandlerAdapter.java | 2 +- .../mvc/method/annotation/RequestMappingHandlerAdapter.java | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) rename spring-web/src/main/java/org/springframework/web/method/{support => annotation}/HandlerMethodValidator.java (96%) diff --git a/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodValidator.java b/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidator.java similarity index 96% rename from spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodValidator.java rename to spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidator.java index 862fe446838d..6478c8d893b3 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodValidator.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.method.support; +package org.springframework.web.method.annotation; import java.lang.reflect.Method; @@ -35,7 +35,6 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; import org.springframework.web.bind.support.WebBindingInitializer; -import org.springframework.web.method.annotation.ModelFactory; /** * {@link org.springframework.validation.beanvalidation.MethodValidator} for @@ -48,7 +47,6 @@ */ public final class HandlerMethodValidator extends DefaultMethodValidator { - private HandlerMethodValidator(MethodValidationAdapter adapter) { super(adapter); } @@ -86,7 +84,7 @@ private String determineObjectName(MethodParameter param, @Nullable Object argum return Conventions.getVariableNameForParameter(param); } else { - return ((param.getParameterIndex() != -1) ? + return (param.getParameterIndex() != -1 ? ModelFactory.getNameForParameter(param) : ModelFactory.getNameForReturnValue(argument, param)); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java index 966d80047dcf..ef2cc64f0fe2 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java @@ -38,7 +38,7 @@ import org.springframework.validation.beanvalidation.MethodValidator; import org.springframework.web.bind.support.WebBindingInitializer; import org.springframework.web.method.HandlerMethod; -import org.springframework.web.method.support.HandlerMethodValidator; +import org.springframework.web.method.annotation.HandlerMethodValidator; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.DispatchExceptionHandler; import org.springframework.web.reactive.HandlerAdapter; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index 3ce42df0c267..519b6fc0f1da 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -74,6 +74,7 @@ import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.annotation.ErrorsMethodArgumentResolver; import org.springframework.web.method.annotation.ExpressionValueMethodArgumentResolver; +import org.springframework.web.method.annotation.HandlerMethodValidator; import org.springframework.web.method.annotation.InitBinderDataBinderFactory; import org.springframework.web.method.annotation.MapMethodProcessor; import org.springframework.web.method.annotation.ModelFactory; @@ -88,7 +89,6 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite; import org.springframework.web.method.support.HandlerMethodReturnValueHandler; import org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite; -import org.springframework.web.method.support.HandlerMethodValidator; import org.springframework.web.method.support.InvocableHandlerMethod; import org.springframework.web.method.support.ModelAndViewContainer; import org.springframework.web.servlet.ModelAndView;