java result%3c %3e_org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: null...

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

Reporter: Søren Markert

Priority: Minor

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

=================

if we want to use uri in interceptfrom

we must make surei there isn't any route like:

we should change it to

>

=============

interceptFrom & ref

I guess would be logically correct to include such an attribute to refer to the endpoints instead of copy/pasting of URIs.

The source code has a TODO in there about that, so yeah its a known issue that interceptXXX uses uris. However you can always use "ref:xxx" to refer to an endpoint by its id, in the uri. So that should work. Its just that the we dont have interceptXXXRef to indicate it expect a reference.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值