Skip to content

Commit 0a94dce

Browse files
committed
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.
1 parent 9b3afcd commit 0a94dce

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
import java.lang.annotation.Annotation;
2020
import java.lang.reflect.Method;
21-
import java.util.List;
21+
import java.util.Collection;
22+
import java.util.Map;
2223
import java.util.StringJoiner;
2324
import java.util.function.Predicate;
2425
import java.util.stream.Collectors;
@@ -402,7 +403,8 @@ public static boolean checkArguments(Class<?> beanType, MethodParameter[] parame
402403
}
403404
else {
404405
Class<?> type = parameter.getParameterType();
405-
if (merged.stream().anyMatch(VALID_PREDICATE) && List.class.isAssignableFrom(type)) {
406+
if (merged.stream().anyMatch(VALID_PREDICATE) &&
407+
(Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type))) {
406408
return true;
407409
}
408410
}

0 commit comments

Comments
 (0)