Skip to content

Commit

Permalink
Fix @Param handling to raise exception for Map with specified value
Browse files Browse the repository at this point in the history
Signed-off-by: Daeho Kwon <[email protected]>
  • Loading branch information
kwondh5217 committed Jan 21, 2025
1 parent ffe3bb9 commit f3ba5a2
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,15 @@ private static AnnotatedValueResolver of(AnnotatedElement annotatedElement,
final String name = findName(typeElement, param.value());
// If the parameter is of type Map and the @Param annotation does not specify a value,
// map all query parameters into the Map.
if (Map.class.isAssignableFrom(type) && DefaultValues.isUnspecified(param.value())) {
if (Map.class.isAssignableFrom(type)) {
if (DefaultValues.isSpecified(param.value())) {
throw new IllegalArgumentException(
String.format("Invalid @Param annotation on Map parameter: '%s'. " +
"The @Param annotation specifies a value ('%s'), which is not allowed. " +
"When using a Map, @Param must not specify a value. " +
"Please use @Param Map<String, Object> param without a value.",
annotatedElement, param.value()));
}
return ofQueryParamMap(name, annotatedElement, typeElement, type, description);
}
if (type == File.class || type == Path.class || type == MultipartFile.class) {
Expand Down

0 comments on commit f3ba5a2

Please sign in to comment.