Improve HandlerMethod check when method validation applies
Method validation needs to be used for a container such as a List or Map, but until now we were only checking for a List container. Moreover, in gh-31530 we improved method validation to also cover any Collection. This change aligns with HandlerMethod check for when method validation applies with the underlying ability of method validation.
This commit is contained in:
parent
9b3afcdac7
commit
0a94dce41d
|
|
@ -18,7 +18,8 @@ package org.springframework.web.method;
|
|||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -402,7 +403,8 @@ public class HandlerMethod extends AnnotatedMethod {
|
|||
}
|
||||
else {
|
||||
Class<?> type = parameter.getParameterType();
|
||||
if (merged.stream().anyMatch(VALID_PREDICATE) && List.class.isAssignableFrom(type)) {
|
||||
if (merged.stream().anyMatch(VALID_PREDICATE) &&
|
||||
(Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue