camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-8492: Bean introspection should skip bridge methods in its override method filtering. Thanks to Peter Geletka for reporting and the unit tests.
Date Tue, 17 Mar 2015 08:11:33 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 325d3d131 -> 9b2deb8f6
  refs/heads/master 0223d842e -> b232d59dc


CAMEL-8492: Bean introspection should skip bridge methods in its override method filtering.
Thanks to Peter Geletka for reporting and the unit tests.


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

Branch: refs/heads/master
Commit: b232d59dc67a4c1270865854c9581dce390f9e7e
Parents: 0223d84
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Mar 17 09:13:06 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Mar 17 09:13:06 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/component/bean/BeanInfo.java   |  6 +++
 .../issues/BeanInfoSingleMethodServiceTest.java | 56 ++++++++++++++++++++
 .../bean/issues/SingleMethodService.java        | 22 ++++++++
 .../bean/issues/SingleMethodServiceImpl.java    | 25 +++++++++
 4 files changed, 109 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b232d59d/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 c478d8b..d33eb7f 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
@@ -319,6 +319,12 @@ public class BeanInfo {
         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)) {

http://git-wip-us.apache.org/repos/asf/camel/blob/b232d59d/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanInfoSingleMethodServiceTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanInfoSingleMethodServiceTest.java
b/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanInfoSingleMethodServiceTest.java
new file mode 100644
index 0000000..6121720
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanInfoSingleMethodServiceTest.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.bean.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.bean.BeanInfo;
+
+public class BeanInfoSingleMethodServiceTest extends ContextTestSupport {
+
+    private SingleMethodService myService = new SingleMethodServiceImpl();
+
+    public void testBeanInfoSingleMethodRoute() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("You said Hello World");
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testBeanInfoSingleMethod() throws Exception {
+        BeanInfo beaninfo = new BeanInfo(context, SingleMethodService.class);
+        assertEquals("Should find the single method", 1, beaninfo.getMethods().size());
+    }
+
+    public void testBeanInfoSingleMethodImpl() throws Exception {
+        BeanInfo beaninfo = new BeanInfo(context, SingleMethodServiceImpl.class);
+        assertEquals("Should find the single method", 1, beaninfo.getMethods().size());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .bean(myService)
+                    .to("mock:result");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/b232d59d/camel-core/src/test/java/org/apache/camel/component/bean/issues/SingleMethodService.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/issues/SingleMethodService.java
b/camel-core/src/test/java/org/apache/camel/component/bean/issues/SingleMethodService.java
new file mode 100644
index 0000000..f3fe2e0
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/issues/SingleMethodService.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.bean.issues;
+
+public interface SingleMethodService<S, T> {
+
+    public T doSomething(S foo);
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/b232d59d/camel-core/src/test/java/org/apache/camel/component/bean/issues/SingleMethodServiceImpl.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/issues/SingleMethodServiceImpl.java
b/camel-core/src/test/java/org/apache/camel/component/bean/issues/SingleMethodServiceImpl.java
new file mode 100644
index 0000000..c477669
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/issues/SingleMethodServiceImpl.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.bean.issues;
+
+public class SingleMethodServiceImpl implements SingleMethodService<String, String>
{
+
+    @Override
+    public String doSomething(String foo) {
+        return "You said " + foo;
+    }
+}


Mime
View raw message