diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationAdapter.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationAdapter.java index e7e4d9bf262f..053f581a6f7b 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationAdapter.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationAdapter.java @@ -18,7 +18,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.LinkedHashMap; @@ -50,7 +49,6 @@ import org.springframework.core.ParameterNameDiscoverer; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.lang.Nullable; -import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.function.SingletonSupplier; import org.springframework.validation.BeanPropertyBindingResult; @@ -59,6 +57,10 @@ import org.springframework.validation.Errors; import org.springframework.validation.MessageCodesResolver; import org.springframework.validation.annotation.Validated; +import org.springframework.validation.method.MethodValidationResult; +import org.springframework.validation.method.MethodValidator; +import org.springframework.validation.method.ParameterErrors; +import org.springframework.validation.method.ParameterValidationResult; /** * {@link MethodValidator} that uses a Bean Validation @@ -70,12 +72,12 @@ */ public class MethodValidationAdapter implements MethodValidator { + private static final MethodValidationResult emptyValidationResult = MethodValidationResult.emptyResult(); + private static final ObjectNameResolver defaultObjectNameResolver = new DefaultObjectNameResolver(); private static final Comparator resultComparator = new ResultComparator(); - private static final MethodValidationResult emptyResult = new EmptyMethodValidationResult(); - private final Supplier validator; @@ -219,7 +221,7 @@ public final MethodValidationResult validateArguments( invokeValidatorForArguments(target, method, arguments, groups); if (violations.isEmpty()) { - return emptyResult; + return emptyValidationResult; } return adaptViolations(target, method, violations, @@ -257,7 +259,7 @@ public final MethodValidationResult validateReturnValue( invokeValidatorForReturnValue(target, method, returnValue, groups); if (violations.isEmpty()) { - return emptyResult; + return emptyValidationResult; } return adaptViolations(target, method, violations, @@ -320,7 +322,7 @@ else if (node.getKind().equals(ElementKind.RETURN_VALUE)) { cascadedViolations.forEach((node, builder) -> validatonResultList.add(builder.build())); validatonResultList.sort(resultComparator); - return new DefaultMethodValidationResult(target, method, validatonResultList); + return MethodValidationResult.create(target, method, validatonResultList); } private MethodParameter initMethodParameter(Method method, int index) { @@ -534,91 +536,4 @@ private int compareKeys(ParameterErrors errors1, ParameterErrors errors2) { } } - - /** - * Default {@link MethodValidationResult} implementation with non-zero errors. - */ - private static class DefaultMethodValidationResult implements MethodValidationResult { - - private final Object target; - - private final Method method; - - private final List allValidationResults; - - private final boolean forReturnValue; - - - DefaultMethodValidationResult(Object target, Method method, List results) { - Assert.notEmpty(results, "'results' is required and must not be empty"); - Assert.notNull(target, "'target' is required"); - Assert.notNull(method, "Method is required"); - this.target = target; - this.method = method; - this.allValidationResults = results; - this.forReturnValue = (results.get(0).getMethodParameter().getParameterIndex() == -1); - } - - - @Override - public Object getTarget() { - return this.target; - } - - @Override - public Method getMethod() { - return this.method; - } - - @Override - public boolean isForReturnValue() { - return this.forReturnValue; - } - - @Override - public List getAllValidationResults() { - return this.allValidationResults; - } - - - @Override - public String toString() { - return getAllErrors().size() + " validation errors " + - "for " + (isForReturnValue() ? "return value" : "arguments") + " of " + - this.method.toGenericString(); - } - } - - - /** - * {@link MethodValidationResult} for when there are no errors. - */ - private static class EmptyMethodValidationResult implements MethodValidationResult { - - @Override - public Object getTarget() { - throw new UnsupportedOperationException(); - } - - @Override - public Method getMethod() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isForReturnValue() { - throw new UnsupportedOperationException(); - } - - @Override - public List getAllValidationResults() { - return Collections.emptyList(); - } - - @Override - public String toString() { - return "0 validation errors"; - } - } - } diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java index 5b687087b829..06798651d8a6 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java @@ -34,6 +34,8 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.validation.annotation.Validated; +import org.springframework.validation.method.MethodValidationException; +import org.springframework.validation.method.MethodValidationResult; /** * An AOP Alliance {@link MethodInterceptor} implementation that delegates to a diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java index 4ba66ff51254..e7add2e73e87 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java @@ -36,6 +36,8 @@ import org.springframework.util.Assert; import org.springframework.util.function.SingletonSupplier; import org.springframework.validation.annotation.Validated; +import org.springframework.validation.method.MethodValidationException; +import org.springframework.validation.method.MethodValidationResult; /** * A convenient {@link BeanPostProcessor} implementation that delegates to a diff --git a/spring-context/src/main/java/org/springframework/validation/method/DefaultMethodValidationResult.java b/spring-context/src/main/java/org/springframework/validation/method/DefaultMethodValidationResult.java new file mode 100644 index 000000000000..edb3caf393bc --- /dev/null +++ b/spring-context/src/main/java/org/springframework/validation/method/DefaultMethodValidationResult.java @@ -0,0 +1,80 @@ +/* + * Copyright 2002-2023 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.validation.method; + +import java.lang.reflect.Method; +import java.util.List; + +import org.springframework.util.Assert; + +/** + * Default {@link MethodValidationResult} implementation as a simple container. + * + * @author Rossen Stoyanchev + * @since 6.1 + */ +final class DefaultMethodValidationResult implements MethodValidationResult { + + private final Object target; + + private final Method method; + + private final List allValidationResults; + + private final boolean forReturnValue; + + + DefaultMethodValidationResult(Object target, Method method, List results) { + Assert.notEmpty(results, "'results' is required and must not be empty"); + Assert.notNull(target, "'target' is required"); + Assert.notNull(method, "Method is required"); + this.target = target; + this.method = method; + this.allValidationResults = results; + this.forReturnValue = (results.get(0).getMethodParameter().getParameterIndex() == -1); + } + + + @Override + public Object getTarget() { + return this.target; + } + + @Override + public Method getMethod() { + return this.method; + } + + @Override + public boolean isForReturnValue() { + return this.forReturnValue; + } + + @Override + public List getAllValidationResults() { + return this.allValidationResults; + } + + + @Override + public String toString() { + return getAllErrors().size() + " validation errors " + + "for " + (isForReturnValue() ? "return value" : "arguments") + " of " + + this.method.toGenericString(); + } + +} diff --git a/spring-context/src/main/java/org/springframework/validation/method/EmptyMethodValidationResult.java b/spring-context/src/main/java/org/springframework/validation/method/EmptyMethodValidationResult.java new file mode 100644 index 000000000000..484f683f106e --- /dev/null +++ b/spring-context/src/main/java/org/springframework/validation/method/EmptyMethodValidationResult.java @@ -0,0 +1,56 @@ +/* + * Copyright 2002-2023 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.validation.method; + +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.List; + +/** + * {@link MethodValidationResult} with an empty list of results. + * + * @author Rossen Stoyanchev + * @since 6.1 + */ +final class EmptyMethodValidationResult implements MethodValidationResult { + + @Override + public Object getTarget() { + throw new UnsupportedOperationException(); + } + + @Override + public Method getMethod() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isForReturnValue() { + throw new UnsupportedOperationException(); + } + + @Override + public List getAllValidationResults() { + return Collections.emptyList(); + } + + @Override + public String toString() { + return "0 validation errors"; + } + +} diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationException.java b/spring-context/src/main/java/org/springframework/validation/method/MethodValidationException.java similarity index 96% rename from spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationException.java rename to spring-context/src/main/java/org/springframework/validation/method/MethodValidationException.java index 470afa9d2221..5eabc69988e6 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationException.java +++ b/spring-context/src/main/java/org/springframework/validation/method/MethodValidationException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.validation.beanvalidation; +package org.springframework.validation.method; import java.lang.reflect.Method; import java.util.List; diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationResult.java b/spring-context/src/main/java/org/springframework/validation/method/MethodValidationResult.java similarity index 80% rename from spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationResult.java rename to spring-context/src/main/java/org/springframework/validation/method/MethodValidationResult.java index 316dbc0a4242..45474877ab16 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationResult.java +++ b/spring-context/src/main/java/org/springframework/validation/method/MethodValidationResult.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.validation.beanvalidation; +package org.springframework.validation.method; import java.lang.reflect.Method; import java.util.List; @@ -101,4 +101,25 @@ default List getBeanResults() { .toList(); } + + /** + * Factory method to create a {@link MethodValidationResult} instance. + * @param target the target Object + * @param method the target method + * @param results method validation results, expected to be non-empty + * @return the created instance + */ + static MethodValidationResult create(Object target, Method method, List results) { + return new DefaultMethodValidationResult(target, method, results); + } + + /** + * Factory method to create a {@link MethodValidationResult} instance with + * 0 errors, suitable to use as a constant. Getters for a target object or + * method are not supported. + */ + static MethodValidationResult emptyResult() { + return new EmptyMethodValidationResult(); + } + } diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidator.java b/spring-context/src/main/java/org/springframework/validation/method/MethodValidator.java similarity index 98% rename from spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidator.java rename to spring-context/src/main/java/org/springframework/validation/method/MethodValidator.java index 1922383ededb..bf5939ddfb19 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidator.java +++ b/spring-context/src/main/java/org/springframework/validation/method/MethodValidator.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.validation.beanvalidation; +package org.springframework.validation.method; import java.lang.reflect.Method; diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/ParameterErrors.java b/spring-context/src/main/java/org/springframework/validation/method/ParameterErrors.java similarity index 99% rename from spring-context/src/main/java/org/springframework/validation/beanvalidation/ParameterErrors.java rename to spring-context/src/main/java/org/springframework/validation/method/ParameterErrors.java index 5a3d91a90a9e..58c54713bf04 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/ParameterErrors.java +++ b/spring-context/src/main/java/org/springframework/validation/method/ParameterErrors.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.validation.beanvalidation; +package org.springframework.validation.method; import java.util.List; diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/ParameterValidationResult.java b/spring-context/src/main/java/org/springframework/validation/method/ParameterValidationResult.java similarity index 98% rename from spring-context/src/main/java/org/springframework/validation/beanvalidation/ParameterValidationResult.java rename to spring-context/src/main/java/org/springframework/validation/method/ParameterValidationResult.java index 4091f0aec41a..614b0b41889a 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/ParameterValidationResult.java +++ b/spring-context/src/main/java/org/springframework/validation/method/ParameterValidationResult.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.validation.beanvalidation; +package org.springframework.validation.method; import java.util.Collection; import java.util.List; diff --git a/spring-context/src/main/java/org/springframework/validation/method/package-info.java b/spring-context/src/main/java/org/springframework/validation/method/package-info.java new file mode 100644 index 000000000000..001ea1b69c45 --- /dev/null +++ b/spring-context/src/main/java/org/springframework/validation/method/package-info.java @@ -0,0 +1,21 @@ +/** + * Abstractions and support classes for method validation, independent of the + * underlying validation library. + * + *

The main abstractions: + *

    + *
  • {@link org.springframework.validation.method.MethodValidator} to apply + * method validation, and return or handle the results. + *
  • {@link org.springframework.validation.method.MethodValidationResult} and + * related types to represent the results. + *
  • {@link org.springframework.validation.method.MethodValidationException} + * to expose method validation results. + *
+ */ + +@NonNullApi +@NonNullFields +package org.springframework.validation.method; + +import org.springframework.lang.NonNullApi; +import org.springframework.lang.NonNullFields; diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterTests.java index b835c1e0707a..9714afbce837 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterTests.java @@ -33,6 +33,9 @@ import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.validation.FieldError; +import org.springframework.validation.method.MethodValidationResult; +import org.springframework.validation.method.ParameterErrors; +import org.springframework.validation.method.ParameterValidationResult; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidationException.java b/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidationException.java index b1ffa481bde4..749ab35a389f 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidationException.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidationException.java @@ -22,8 +22,8 @@ import org.springframework.context.MessageSource; import org.springframework.http.HttpStatus; -import org.springframework.validation.beanvalidation.MethodValidationResult; -import org.springframework.validation.beanvalidation.ParameterValidationResult; +import org.springframework.validation.method.MethodValidationResult; +import org.springframework.validation.method.ParameterValidationResult; import org.springframework.web.server.ResponseStatusException; import org.springframework.web.util.BindErrorUtils; diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidator.java b/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidator.java index 77e8c3a3cb94..e8a08cd46f8d 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidator.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/HandlerMethodValidator.java @@ -27,16 +27,16 @@ import org.springframework.validation.BindingResult; import org.springframework.validation.MessageCodesResolver; import org.springframework.validation.beanvalidation.MethodValidationAdapter; -import org.springframework.validation.beanvalidation.MethodValidationResult; -import org.springframework.validation.beanvalidation.MethodValidator; -import org.springframework.validation.beanvalidation.ParameterErrors; +import org.springframework.validation.method.MethodValidationResult; +import org.springframework.validation.method.MethodValidator; +import org.springframework.validation.method.ParameterErrors; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.support.ConfigurableWebBindingInitializer; import org.springframework.web.bind.support.WebBindingInitializer; /** - * {@link org.springframework.validation.beanvalidation.MethodValidator} that + * {@link MethodValidator} that * uses Bean Validation to validate {@code @RequestMapping} method arguments. * *

Handles validation results by populating {@link BindingResult} method diff --git a/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java b/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java index 21e4db3b6cb8..87c8b3d3b4ad 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java +++ b/spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java @@ -36,7 +36,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; -import org.springframework.validation.beanvalidation.MethodValidator; +import org.springframework.validation.method.MethodValidator; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.support.SessionStatus; import org.springframework.web.bind.support.WebDataBinderFactory; diff --git a/spring-web/src/test/java/org/springframework/web/ErrorResponseExceptionTests.java b/spring-web/src/test/java/org/springframework/web/ErrorResponseExceptionTests.java index 3c5ced38f875..1427aa964b04 100644 --- a/spring-web/src/test/java/org/springframework/web/ErrorResponseExceptionTests.java +++ b/spring-web/src/test/java/org/springframework/web/ErrorResponseExceptionTests.java @@ -36,7 +36,7 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; -import org.springframework.validation.beanvalidation.MethodValidationResult; +import org.springframework.validation.method.MethodValidationResult; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MissingMatrixVariableException; import org.springframework.web.bind.MissingPathVariableException; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java index e730a07ad9ba..278713647cf3 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java @@ -44,7 +44,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; -import org.springframework.validation.beanvalidation.MethodValidator; +import org.springframework.validation.method.MethodValidator; import org.springframework.web.method.HandlerMethod; import org.springframework.web.reactive.BindingContext; import org.springframework.web.reactive.HandlerResult; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java index 98ddfc7a5ea0..f248bfcc36e3 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java @@ -39,7 +39,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils.MethodFilter; -import org.springframework.validation.beanvalidation.MethodValidator; +import org.springframework.validation.method.MethodValidator; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; 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 ef2cc64f0fe2..3793f1d9a1bf 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 @@ -35,7 +35,7 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; -import org.springframework.validation.beanvalidation.MethodValidator; +import org.springframework.validation.method.MethodValidator; import org.springframework.web.bind.support.WebBindingInitializer; import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.annotation.HandlerMethodValidator; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandler.java index c9bed00458c8..07bb9d02194a 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandler.java @@ -30,7 +30,7 @@ import org.springframework.http.ProblemDetail; import org.springframework.http.ResponseEntity; import org.springframework.lang.Nullable; -import org.springframework.validation.beanvalidation.MethodValidationException; +import org.springframework.validation.method.MethodValidationException; import org.springframework.web.ErrorResponse; import org.springframework.web.ErrorResponseException; import org.springframework.web.bind.annotation.ControllerAdvice; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MethodValidationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MethodValidationTests.java index ee4ad52099e5..5173f46c1ca0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MethodValidationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MethodValidationTests.java @@ -43,7 +43,7 @@ import org.springframework.validation.Validator; import org.springframework.validation.annotation.Validated; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; -import org.springframework.validation.beanvalidation.ParameterValidationResult; +import org.springframework.validation.method.ParameterValidationResult; import org.springframework.validation.beanvalidation.SpringValidatorAdapter; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandlerTests.java index 6da9bb5b1179..e95b10ffc265 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityExceptionHandlerTests.java @@ -37,8 +37,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.util.LinkedMultiValueMap; import org.springframework.validation.BeanPropertyBindingResult; -import org.springframework.validation.beanvalidation.MethodValidationException; -import org.springframework.validation.beanvalidation.MethodValidationResult; +import org.springframework.validation.method.MethodValidationException; +import org.springframework.validation.method.MethodValidationResult; import org.springframework.web.ErrorResponse; import org.springframework.web.ErrorResponseException; import org.springframework.web.bind.support.WebExchangeBindException; 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 519b6fc0f1da..a50dc4a942c4 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 @@ -51,7 +51,7 @@ import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; import org.springframework.util.ReflectionUtils.MethodFilter; -import org.springframework.validation.beanvalidation.MethodValidator; +import org.springframework.validation.method.MethodValidator; import org.springframework.web.accept.ContentNegotiationManager; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.ModelAttribute; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java index fd696be71c01..529261b5697a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java @@ -34,7 +34,7 @@ import org.springframework.http.converter.HttpMessageNotWritableException; import org.springframework.lang.Nullable; import org.springframework.validation.BindException; -import org.springframework.validation.beanvalidation.MethodValidationException; +import org.springframework.validation.method.MethodValidationException; import org.springframework.web.ErrorResponse; import org.springframework.web.ErrorResponseException; import org.springframework.web.HttpMediaTypeNotAcceptableException; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java index 52f946d479d8..a21c37cae07a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java @@ -33,7 +33,7 @@ import org.springframework.lang.Nullable; import org.springframework.validation.BindException; import org.springframework.validation.BindingResult; -import org.springframework.validation.beanvalidation.MethodValidationException; +import org.springframework.validation.method.MethodValidationException; import org.springframework.web.ErrorResponse; import org.springframework.web.HttpMediaTypeNotAcceptableException; import org.springframework.web.HttpMediaTypeNotSupportedException; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MethodValidationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MethodValidationTests.java index dca5849d0d97..d25837a68d37 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MethodValidationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MethodValidationTests.java @@ -39,7 +39,7 @@ import org.springframework.validation.Validator; import org.springframework.validation.annotation.Validated; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; -import org.springframework.validation.beanvalidation.ParameterValidationResult; +import org.springframework.validation.method.ParameterValidationResult; import org.springframework.validation.beanvalidation.SpringValidatorAdapter; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.WebDataBinder; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java index 91d84b474f68..4767bb825d5f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java @@ -43,8 +43,8 @@ import org.springframework.stereotype.Controller; import org.springframework.validation.BindException; import org.springframework.validation.MapBindingResult; -import org.springframework.validation.beanvalidation.MethodValidationException; -import org.springframework.validation.beanvalidation.MethodValidationResult; +import org.springframework.validation.method.MethodValidationException; +import org.springframework.validation.method.MethodValidationResult; import org.springframework.web.ErrorResponse; import org.springframework.web.HttpMediaTypeNotAcceptableException; import org.springframework.web.HttpMediaTypeNotSupportedException;