Use HandlerMethod-determined validation groups

Closes gh-36336
This commit is contained in:
Juergen Hoeller
2026-02-17 11:50:07 +01:00
parent db01f07037
commit d291272736
@@ -55,7 +55,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.lang.Contract;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.ValidationAnnotationUtils;
import org.springframework.validation.method.MethodValidator;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.reactive.BindingContext;
@@ -97,8 +96,6 @@ public class InvocableHandlerMethod extends HandlerMethod {
private @Nullable MethodValidator methodValidator;
private Class<?>[] validationGroups = EMPTY_GROUPS;
private @Nullable Scheduler invocationScheduler;
@@ -165,8 +162,6 @@ public class InvocableHandlerMethod extends HandlerMethod {
*/
public void setMethodValidator(@Nullable MethodValidator methodValidator) {
this.methodValidator = methodValidator;
this.validationGroups = (methodValidator != null ?
ValidationAnnotationUtils.determineValidationGroups(getBean(), getBridgedMethod()) : EMPTY_GROUPS);
}
/**
@@ -193,7 +188,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
try {
LocaleContextHolder.setLocaleContext(exchange.getLocaleContext());
this.methodValidator.applyArgumentValidation(
getBean(), getBridgedMethod(), getMethodParameters(), args, this.validationGroups);
getBean(), getBridgedMethod(), getMethodParameters(), args, getValidationGroups());
}
finally {
LocaleContextHolder.resetLocaleContext();