Skip to content

Commit

Permalink
fix: Improved error message (#436)
Browse files Browse the repository at this point in the history
When a method defining `@AsyncGenericOperationBinding` has more than 1 argument and misses the `@Payload` annotation, the provided exception message was confusing.

Instead of `Multi-parameter KafkaListener methods must have one parameter annotated with @payload but none was found` we now provide a more generic `Multi-parameter AsyncListener methods must have one parameter annotated with @payload but none was found`
  • Loading branch information
ctasada authored Nov 10, 2023
1 parent 144a6cb commit 98046d0
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static int getPayloadParameterIndex(
int payloadAnnotatedParameterIndex = getPayloadAnnotatedParameterIndex(parameterAnnotations);
if (payloadAnnotatedParameterIndex == -1) {
String msg =
"Multi-parameter KafkaListener methods must have one parameter annotated with @Payload, "
"Multi-parameter AsyncListener methods must have one parameter annotated with @Payload, "
+ "but none was found: "
+ methodName;

Expand All @@ -68,8 +68,7 @@ static int getPayloadParameterIndex(
static int getPayloadAnnotatedParameterIndex(Annotation[][] parameterAnnotations) {
for (int i = 0, length = parameterAnnotations.length; i < length; i++) {
Annotation[] annotations = parameterAnnotations[i];
boolean hasPayloadAnnotation =
Arrays.stream(annotations).anyMatch(annotation -> annotation instanceof Payload);
boolean hasPayloadAnnotation = Arrays.stream(annotations).anyMatch(Payload.class::isInstance);

if (hasPayloadAnnotation) {
return i;
Expand Down

0 comments on commit 98046d0

Please sign in to comment.