-
Bug
-
Resolution: Done
-
Major
-
fuse-6.3-R16-GA
-
None
Using Camel 2.17.0.redhat-630446 (Fuse 6.3.0 R16), the BeanInfo class is skipping the class method introspection (ExchangeBasedDynamicRouter.initialiseEndpoints) and, as a result, it is binding to the generic interface with a runtime ClassCastException. Instead, the binding process is correct using Camel 2.15.1.redhat-621084 (Fuse 6.2.1).
Here we have the following class hierarchy:
MyDynamicRouter (generic interface) |_ ExchangeBasedDynamicRouter (abstract class) |_ ReportingDynamicRouter
The method generateEndpoints is defined by the interface and implemented by the abstract class. For some reason Camel 2.17 BeanInfo filter out the abstract class which contains the actual method implementation.
If you trace the MethodInfo invocation you have:
# 2.15 2020-07-17 17:13:01,715 [ main] TRACE amel.component.bean.MethodInfo - >>>> invoking: public java.util.List it.fvaleri.integ.ExchangeBasedDynamicRouter.initialiseEndpoints(org.apache.camel.Exchange) on bean: it.fvaleri.integ.ReportingDynamicRouter@3f191845 with arguments: \{Exchange[Message: foo]} for exchange: Exchange[Message: foo] # 2.17 2020-07-17 17:10:28,789 [ main] TRACE amel.component.bean.MethodInfo - >>>> invoking: public abstract java.util.List it.fvaleri.integ.DynamicRouter.initialiseEndpoints(java.lang.Object) on bean: it.fvaleri.integ.ReportingDynamicRouter@5032714f with arguments: \{foo} for exchange: Exchange[]
Complete stack:
java.lang.ClassCastException: java.lang.String cannot be cast to org.apache.camel.Exchange at it.fvaleri.integ.ExchangeBasedDynamicRouter.initialiseEndpoints(ExchangeBasedDynamicRouter.java:9) ~[classes/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_232] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_232] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232] at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:177) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:68) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:211) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:126) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:138) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.processor.SetHeaderProcessor.process(SetHeaderProcessor.java:52) ~[camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.processor.Pipeline.process(Pipeline.java:121) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:221) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:144) [camel-core-2.17.0.redhat-630446.jar:2.17.0.redhat-630446] at it.fvaleri.integ.DynamicRouterTest.test(DynamicRouterTest.java:37) [test-classes/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_232] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_232] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_232] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_232] at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12] at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12] at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12] at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) [junit-4.12.jar:4.12] at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) [junit-4.12.jar:4.12] at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) [junit-4.12.jar:4.12] at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) [junit-4.12.jar:4.12] at org.junit.rules.RunRules.evaluate(RunRules.java:20) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) [junit-4.12.jar:4.12] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12] at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) [junit-4.12.jar:4.12] at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12] at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365) [surefire-junit4-2.22.1.jar:2.22.1] at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273) [surefire-junit4-2.22.1.jar:2.22.1] at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238) [surefire-junit4-2.22.1.jar:2.22.1] at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159) [surefire-junit4-2.22.1.jar:2.22.1] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384) [surefire-booter-2.22.1.jar:2.22.1] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345) [surefire-booter-2.22.1.jar:2.22.1] at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126) [surefire-booter-2.22.1.jar:2.22.1] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418) [surefire-booter-2.22.1.jar:2.22.1]
- links to