[ https://issues.apache.org/jira/browse/CAMEL-3709?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen updated CAMEL-3709: ------------------------------- Fix Version/s: 2.7.0 > interceptFrom and from(Endpoint) don't work together > ---------------------------------------------------- > > Key: CAMEL-3709 > URL: https://issues.apache.org/jira/browse/CAMEL-3709 > Project: Camel > Issue Type: Bug > Components: camel-core > Affects Versions: 2.5.0, 2.6.0 > Reporter: Søren Markert > Assignee: Claus Ibsen > Priority: Minor > Fix For: 2.7.0 > > > When using interceptFrom(String) together with from(Endpoint), the below > Exception occurs during the routes building process. Looking at > RoutesDefinition.java:217 reveals, that the FromDefintion just created has no > URI. That causes the comparison to all the interceptFroms' URIs to fail. As > far as I can tell, the way to fix this would be to add > {{setUri(myEndpoint.getEndpointUri())}} in the constructor > {{FromDefinition(Endpoint endpoint)}}. > Below the stack trace, there is a unit test that demonstrates the issue. > Until it if fixed, it can be easily circumvented by adding the commented-out > line, and then change to {{from("myEndpoint")}}. > {code} > org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: > null due to: null > at > org.apache.camel.util.EndpointHelper.matchEndpoint(EndpointHelper.java:109) > at > org.apache.camel.model.RoutesDefinition.route(RoutesDefinition.java:217) > at > org.apache.camel.model.RoutesDefinition.from(RoutesDefinition.java:167) > at org.apache.camel.builder.RouteBuilder.from(RouteBuilder.java:101) > at > dk.mobilethink.adc2.endpoint.UnsetUriTest$1.configure(UnsetUriTest.java:18) > at > org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:318) > at > org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:273) > at > org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:259) > at > org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:612) > at > org.apache.camel.test.CamelTestSupport.setUp(CamelTestSupport.java:111) > at junit.framework.TestCase.runBare(TestCase.java:132) > at org.apache.camel.test.TestSupport.runBare(TestSupport.java:65) > at junit.framework.TestResult$1.protect(TestResult.java:110) > at junit.framework.TestResult.runProtected(TestResult.java:128) > at junit.framework.TestResult.run(TestResult.java:113) > at junit.framework.TestCase.run(TestCase.java:124) > at junit.framework.TestSuite.runTest(TestSuite.java:232) > at junit.framework.TestSuite.run(TestSuite.java:227) > at > org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) > at > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) > at > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) > Caused by: java.lang.NullPointerException > at > org.apache.camel.util.UnsafeUriCharactersEncoder.encode(UnsafeUriCharactersEncoder.java:56) > at org.apache.camel.util.URISupport.normalizeUri(URISupport.java:162) > at > org.apache.camel.util.EndpointHelper.matchEndpoint(EndpointHelper.java:107) > ... 24 more > {code} > {code} > package dk.mobilethink.adc2.endpoint; > import org.apache.camel.Endpoint; > import org.apache.camel.builder.RouteBuilder; > import org.apache.camel.test.CamelTestSupport; > public class UnsetUriTest extends CamelTestSupport { > @Override > protected RouteBuilder createRouteBuilder() throws Exception { > return new RouteBuilder() { > public void configure() throws Exception { > interceptFrom("URI1").to("irrelevantURI"); > Endpoint myEndpoint = > getContext().getComponent("direct").createEndpoint("ignoredURI"); > > // getContext().addEndpoint("myEndpoint", > myEndpoint); > from(myEndpoint) > .inOnly("log:foo"); > } > }; > } > public void testNothing() { } > } > {code} -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira