Repository: camel Updated Branches: refs/heads/camel-2.15.x 218bb3d16 -> a9c704b5e
CAMEL-9032: Bean component - Should filter out abstract methods Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4ac613e8 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4ac613e8 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4ac613e8 Branch: refs/heads/camel-2.15.x Commit: 4ac613e80047f59f04ae5e56d0b82aa605463976 Parents: 218bb3d Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Jul 29 10:11:08 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Jul 29 11:14:46 2015 +0200 ---------------------------------------------------------------------- .../apache/camel/component/bean/BeanInfo.java | 5 +++ .../bean/issues/BaseFoundationClass.java | 23 +++++++++++ .../component/bean/issues/BaseSomething.java | 22 ++++++++++ .../issues/BeanAbstractMethodIssueTest.java | 43 ++++++++++++++++++++ .../component/bean/issues/RealSomething.java | 25 ++++++++++++ 5 files changed, 118 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/4ac613e8/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 67a0893..1b34622 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 @@ -831,6 +831,11 @@ public class BeanInfo { return false; } + // must not be abstract + if (Modifier.isAbstract(method.getModifiers())) { + return false; + } + // return type must not be an Exchange and it should not be a bridge method if ((method.getReturnType() != null && Exchange.class.isAssignableFrom(method.getReturnType())) || method.isBridge()) { return false; http://git-wip-us.apache.org/repos/asf/camel/blob/4ac613e8/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseFoundationClass.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseFoundationClass.java b/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseFoundationClass.java new file mode 100644 index 0000000..a143e54 --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseFoundationClass.java @@ -0,0 +1,23 @@ +/** + * 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 abstract class BaseFoundationClass { + + public abstract Object doSomething(String name); + +} http://git-wip-us.apache.org/repos/asf/camel/blob/4ac613e8/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseSomething.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseSomething.java b/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseSomething.java new file mode 100644 index 0000000..545679c --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/bean/issues/BaseSomething.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 abstract class BaseSomething extends BaseFoundationClass { + + public abstract Long doSomething(String name); +} http://git-wip-us.apache.org/repos/asf/camel/blob/4ac613e8/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanAbstractMethodIssueTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanAbstractMethodIssueTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanAbstractMethodIssueTest.java new file mode 100644 index 0000000..7c0430c --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/bean/issues/BeanAbstractMethodIssueTest.java @@ -0,0 +1,43 @@ +/** + * 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; + +public class BeanAbstractMethodIssueTest extends ContextTestSupport { + + public void testAbstractMethod() throws Exception { + getMockEndpoint("mock:123").expectedMessageCount(1); + + template.sendBody("direct:start", new RealSomething()); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .filter().simple("${body.doSomething} == 123").to("mock:123"); + } + }; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/4ac613e8/camel-core/src/test/java/org/apache/camel/component/bean/issues/RealSomething.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/issues/RealSomething.java b/camel-core/src/test/java/org/apache/camel/component/bean/issues/RealSomething.java new file mode 100644 index 0000000..c89b4f7 --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/bean/issues/RealSomething.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 RealSomething extends BaseSomething { + + @Override + public Long doSomething(String name) { + return 123L; + } +}