Skip to content

Commit

Permalink
Improve HandlerMethod check when method validation applies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rstoyanchev committed Dec 18, 2023
1 parent 9b3afcd commit 0a94dce
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

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;
Expand Down Expand Up @@ -402,7 +403,8 @@ public static boolean checkArguments(Class<?> beanType, MethodParameter[] parame
}
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;
}
}
Expand Down

0 comments on commit 0a94dce

Please sign in to comment.