You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/12/10 17:32:14 UTC
[04/15] camel git commit: CAMEL-8137: Bean component should detect
override methods that are assignable by type,
so duplicate methods is not reported as error.
CAMEL-8137: Bean component should detect override methods that are assignable by type, so duplicate methods is not reported as error.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9d5c459f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9d5c459f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9d5c459f
Branch: refs/heads/master
Commit: 9d5c459f6532945b5bde2c40927fb713a98b85d1
Parents: 46d464b
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 13:00:55 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 13:00:55 2014 +0100
----------------------------------------------------------------------
.../java/org/apache/camel/component/bean/BeanInfo.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9d5c459f/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 402e738..1c19945 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -306,17 +306,20 @@ public class BeanInfo {
} else {
LOG.trace("Preferring interface methods as class: {} is not public accessible", clazz);
methods = getInterfaceMethods(clazz);
+ // and then we must add its declared methods as well
+ List<Method> extraMethods = Arrays.asList(clazz.getDeclaredMethods());
+ methods.addAll(extraMethods);
}
- // it may have duplicate methods already in the declared list of methods, so lets remove those
+ // it may have duplicate methods already, even from declared or from interfaces + declared
Set<Method> overrides = new HashSet<Method>();
for (Method source : methods) {
for (Method target : methods) {
- // skip overselves
+ // skip ourselves
if (ObjectHelper.isOverridingMethod(source, target, true)) {
continue;
}
-
+ // skip duplicates which may be assign compatible (favor keep first added method when duplicate)
if (ObjectHelper.isOverridingMethod(source, target, false)) {
overrides.add(target);
}
@@ -325,6 +328,7 @@ public class BeanInfo {
methods.removeAll(overrides);
overrides.clear();
+ // if we are a public class, then add non duplicate interface classes also
if (Modifier.isPublic(clazz.getModifiers())) {
// add additional interface methods
List<Method> extraMethods = getInterfaceMethods(clazz);