[1/2] camel git commit: CAMEL-10376 BeanInfo should prefer implementation methods instead of bridged methods

2016-10-13 Thread davsclaus
Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x 467ded8f3 -> 92630afb2


CAMEL-10376 BeanInfo should prefer implementation methods instead of bridged 
methods


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/803f7e56
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/803f7e56
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/803f7e56

Branch: refs/heads/camel-2.18.x
Commit: 803f7e56302dca9171a94ceb6d381071725ae756
Parents: 467ded8
Author: Babur Duisenov 
Authored: Mon Oct 10 15:46:09 2016 +0200
Committer: Claus Ibsen 
Committed: Thu Oct 13 10:22:08 2016 +0200

--
 .../apache/camel/component/bean/BeanInfo.java   | 18 +++--
 .../bean/BeanInfoWithBridgedMethodTest.java | 71 
 2 files changed, 85 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/803f7e56/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 87be7ee..1fc4404 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
@@ -328,13 +328,18 @@ public class BeanInfo {
 }
 
 Set overrides = new HashSet();
-Set bridges = new HashSet();
 
 // do not remove duplicates form class from the Java itself as they 
have some "duplicates" we need
 boolean javaClass = clazz.getName().startsWith("java.") || 
clazz.getName().startsWith("javax.");
 if (!javaClass) {
 // it may have duplicate methods already, even from declared or 
from interfaces + declared
 for (Method source : methods) {
+
+// skip bridge methods in duplicate checks (as the bridge 
method is inserted by the compiler due to type erasure)
+if (source.isBridge()) {
+continue;
+}
+
 for (Method target : methods) {
 // skip ourselves
 if (ObjectHelper.isOverridingMethod(source, target, true)) 
{
@@ -354,10 +359,15 @@ public class BeanInfo {
 if (Modifier.isPublic(clazz.getModifiers())) {
 // add additional interface methods
 List extraMethods = getInterfaceMethods(clazz);
-for (Method target : extraMethods) {
-for (Method source : methods) {
+for (Method source : extraMethods) {
+for (Method target : methods) {
 if (ObjectHelper.isOverridingMethod(source, target, 
false)) {
-overrides.add(target);
+overrides.add(source);
+}
+}
+for (Method target : methodMap.keySet()) {
+if (ObjectHelper.isOverridingMethod(source, target, 
false)) {
+overrides.add(source);
 }
 }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/803f7e56/camel-core/src/test/java/org/apache/camel/component/bean/BeanInfoWithBridgedMethodTest.java
--
diff --git 
a/camel-core/src/test/java/org/apache/camel/component/bean/BeanInfoWithBridgedMethodTest.java
 
b/camel-core/src/test/java/org/apache/camel/component/bean/BeanInfoWithBridgedMethodTest.java
new file mode 100644
index 000..813c11e
--- /dev/null
+++ 
b/camel-core/src/test/java/org/apache/camel/component/bean/BeanInfoWithBridgedMethodTest.java
@@ -0,0 +1,71 @@
+package org.apache.camel.component.bean;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Service;
+import org.apache.camel.impl.DefaultExchange;
+
+/**
+ * Unit test for bridged methods.
+ */
+public class BeanInfoWithBridgedMethodTest extends ContextTestSupport {
+
+public void testBridgedMethod() throws Exception {
+BeanInfo beanInfo = new BeanInfo(context, MyService.class);
+
+DefaultExchange exchange = new DefaultExchange(context);
+exchange.getIn().setBody(new Request(1));
+
+try {
+MyService myService = new MyService();
+MethodInvocation mi = beanInfo.createInvocation(null, exchange);
+assertEquals("MyService", 
mi.getMethod().getDeclaringClass().getSimpleName());
+assertEquals(2, mi.getMethod().invoke(myService, new Request(1)));
+} catch (AmbiguousMethodCallException e) {
+fail("This should not be ambiguous!");
+}
+}
+
+public void 

[1/2] camel git commit: CAMEL-10376 BeanInfo should prefer implementation methods instead of bridged methods

2016-10-12 Thread davsclaus
Repository: camel
Updated Branches:
  refs/heads/master ab3e17b73 -> 4d917dfd5


CAMEL-10376 BeanInfo should prefer implementation methods instead of bridged 
methods


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8f0c1541
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8f0c1541
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8f0c1541

Branch: refs/heads/master
Commit: 8f0c15413369d245314fe27f34ea16c1ebc854e2
Parents: ab3e17b
Author: Babur Duisenov 
Authored: Mon Oct 10 15:46:09 2016 +0200
Committer: Claus Ibsen 
Committed: Wed Oct 12 12:57:33 2016 +0200

--
 .../apache/camel/component/bean/BeanInfo.java   | 18 +++--
 .../bean/BeanInfoWithBridgedMethodTest.java | 71 
 2 files changed, 85 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/8f0c1541/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 87be7ee..1fc4404 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
@@ -328,13 +328,18 @@ public class BeanInfo {
 }
 
 Set overrides = new HashSet();
-Set bridges = new HashSet();
 
 // do not remove duplicates form class from the Java itself as they 
have some "duplicates" we need
 boolean javaClass = clazz.getName().startsWith("java.") || 
clazz.getName().startsWith("javax.");
 if (!javaClass) {
 // it may have duplicate methods already, even from declared or 
from interfaces + declared
 for (Method source : methods) {
+
+// skip bridge methods in duplicate checks (as the bridge 
method is inserted by the compiler due to type erasure)
+if (source.isBridge()) {
+continue;
+}
+
 for (Method target : methods) {
 // skip ourselves
 if (ObjectHelper.isOverridingMethod(source, target, true)) 
{
@@ -354,10 +359,15 @@ public class BeanInfo {
 if (Modifier.isPublic(clazz.getModifiers())) {
 // add additional interface methods
 List extraMethods = getInterfaceMethods(clazz);
-for (Method target : extraMethods) {
-for (Method source : methods) {
+for (Method source : extraMethods) {
+for (Method target : methods) {
 if (ObjectHelper.isOverridingMethod(source, target, 
false)) {
-overrides.add(target);
+overrides.add(source);
+}
+}
+for (Method target : methodMap.keySet()) {
+if (ObjectHelper.isOverridingMethod(source, target, 
false)) {
+overrides.add(source);
 }
 }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/8f0c1541/camel-core/src/test/java/org/apache/camel/component/bean/BeanInfoWithBridgedMethodTest.java
--
diff --git 
a/camel-core/src/test/java/org/apache/camel/component/bean/BeanInfoWithBridgedMethodTest.java
 
b/camel-core/src/test/java/org/apache/camel/component/bean/BeanInfoWithBridgedMethodTest.java
new file mode 100644
index 000..813c11e
--- /dev/null
+++ 
b/camel-core/src/test/java/org/apache/camel/component/bean/BeanInfoWithBridgedMethodTest.java
@@ -0,0 +1,71 @@
+package org.apache.camel.component.bean;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Service;
+import org.apache.camel.impl.DefaultExchange;
+
+/**
+ * Unit test for bridged methods.
+ */
+public class BeanInfoWithBridgedMethodTest extends ContextTestSupport {
+
+public void testBridgedMethod() throws Exception {
+BeanInfo beanInfo = new BeanInfo(context, MyService.class);
+
+DefaultExchange exchange = new DefaultExchange(context);
+exchange.getIn().setBody(new Request(1));
+
+try {
+MyService myService = new MyService();
+MethodInvocation mi = beanInfo.createInvocation(null, exchange);
+assertEquals("MyService", 
mi.getMethod().getDeclaringClass().getSimpleName());
+assertEquals(2, mi.getMethod().invoke(myService, new Request(1)));
+} catch (AmbiguousMethodCallException e) {
+fail("This should not be ambiguous!");
+}
+}
+
+public void testPackagePrivate()