Skip to content

Commit

Permalink
CAMEL-7513: Fixed POJO aggregating when the parameter type was referr…
Browse files Browse the repository at this point in the history
…ing to a type that was class annotated.
  • Loading branch information
davsclaus committed Jun 16, 2014
1 parent 9f90b02 commit 85ced06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.camel.processor.aggregate;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -62,10 +63,11 @@ protected AggregationStrategyMethodInfo createMethodInfo() {
}

// must not have annotations as they are not supported (yet)
for (int i = 0; i < size; i++) {
Class<?> type = parameterTypes[i];
if (type.getAnnotations().length > 0) {
throw new IllegalArgumentException("Parameter annotations at index " + i + " is not supported on method: " + method);
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
for (int i = 0; i < parameterAnnotations.length; i++) {
Annotation[] annotations = parameterAnnotations[i];
if (annotations.length > 0) {
throw new IllegalArgumentException("Method parameter annotation: " + annotations[0] + " at index: " + i + " is not supported on method: " + method);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
Expand Down Expand Up @@ -66,6 +67,10 @@ public List<String> addUsers(List<String> names, User user) {
}
}

/**
* We support annotations on the types.
*/
@XmlRootElement(name = "user")
public static final class User {
private String name;

Expand Down

0 comments on commit 85ced06

Please sign in to comment.