camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] camel git commit: CAMEL-9243: Invocation of Bean fails when Bean extends and abstract which implements the actual method. Thanks to Alex Paransky for unit test.
Date Sat, 24 Oct 2015 14:00:35 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 4cbc8cd26 -> d9a19d70c
  refs/heads/camel-2.16.x d90d0ad42 -> 5005e3f74
  refs/heads/master 9ff11b57f -> 1957a8282


CAMEL-9243: Invocation of Bean fails when Bean extends and abstract which implements the actual
method. Thanks to Alex Paransky for unit test.


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

Branch: refs/heads/master
Commit: 1957a8282e6681edd8f547e225bda66feb640173
Parents: 9ff11b5
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Oct 24 15:59:01 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Oct 24 16:02:11 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/bean/BeanInfo.java   |  4 ++-
 .../component/bean/BeanHandlerMethodTest.java   | 34 ++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1957a828/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 d3c7214..a2f6ce8 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
@@ -987,7 +987,9 @@ public class BeanInfo {
         Iterator<MethodInfo> it = methods.iterator();
         while (it.hasNext()) {
             MethodInfo info = it.next();
-            if (Modifier.isAbstract(info.getMethod().getModifiers())) {
+            // if the class is an interface then keep the method
+            boolean isFromInterface = Modifier.isInterface(info.getMethod().getDeclaringClass().getModifiers());
+            if (!isFromInterface && Modifier.isAbstract(info.getMethod().getModifiers()))
{
                 // we cannot invoke an abstract method
                 it.remove();
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/1957a828/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
index c0300dc..4b7f69a 100644
--- a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
@@ -28,6 +28,16 @@ import org.apache.camel.impl.DefaultExchange;
  */
 public class BeanHandlerMethodTest extends ContextTestSupport {
 
+    public void testInterfaceBeanMethod() throws Exception {
+        BeanInfo info = new BeanInfo(context, MyConcreteBean.class);
+
+        Exchange exchange = new DefaultExchange(context);
+        MyConcreteBean pojo = new MyConcreteBean();
+        MethodInvocation mi = info.createInvocation(pojo, exchange);
+        assertNotNull(mi);
+        assertEquals("hello", mi.getMethod().getName());
+    }
+
     public void testNoHandleMethod() throws Exception {
         BeanInfo info = new BeanInfo(context, MyNoDummyBean.class);
 
@@ -97,6 +107,30 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
         }
     }
 
+    public interface MyBaseInterface {
+
+        @Handler
+        String hello(@Body String hi);
+
+    }
+
+    public abstract static class MyAbstractBean implements MyBaseInterface {
+
+        public String hello(@Body String hi) {
+            return "Hello " + hi;
+        }
+
+        public String doCompute(String input) {
+            fail("Should not invoke me");
+            return null;
+        }
+
+    }
+
+    public static class MyConcreteBean extends MyAbstractBean {
+
+    }
+
     public static class MyNoDummyBean {
 
         public String hello(@Body String hi) {


Mime
View raw message