Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-3709

interceptFrom and from(Endpoint) don't work together

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.5.0, 2.6.0
    • 2.7.0
    • camel-core
    • None

    Description

      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").

      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
      
      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() { }
      }
      

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            sm Søren Markert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: