camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-7429) Camel Properties Component concatenation issue
Date Wed, 18 Jun 2014 12:14:10 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-7429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14035629#comment-14035629
] 

Claus Ibsen commented on CAMEL-7429:
------------------------------------

Thanks Anotine, but unfortunately the latest PR breaks in other modules, such as camel-blueprint.

Try running tests for components, eg it should pass for camel-spring, camel-blueprint, camel-test-blueprint,
camel-scala, camel-groovy etc.
{code}
testConfigAdmin(org.apache.camel.test.blueprint.ConfigAdminOverridePropertiesOutsideCamelContextTest)
 Time elapsed: 2.531 sec  <<< ERROR!
org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>>
To[{{destination}}] <<< in route: Route(route1)[[From[direct:start]] -> [Bean[ref:myCoolBean
m... because of Property with key [destination] not found in properties from text: {{destination}}
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:910)
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:175)
	at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:780)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2068)
	at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1816)
	at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1683)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1651)
	at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:177)
	at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:187)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.lang.IllegalArgumentException: Property with key [destination] not found in
properties from text: {{destination}}
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:207)
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:131)
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:90)
	at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:77)
	at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:42)
	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:158)
	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:117)
	at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:1223)
	at org.apache.camel.model.ProcessorDefinition.resolvePropertyPlaceholders(ProcessorDefinition.java:571)
	at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:474)
	at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:212)
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:907)
	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:175)
	at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:780)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2068)
	at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1816)
	at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1683)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1651)
	at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:177)
	at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:187)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
{code}


> Camel Properties Component concatenation issue 
> -----------------------------------------------
>
>                 Key: CAMEL-7429
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7429
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.12.3
>         Environment: Ubuntu 13.10, Windows 7
>            Reporter: Andrea Cosentino
>             Fix For: 2.12.4, 2.13.2, 2.14.0
>
>
> Hi,
> Suppose you have a properties file of this type
> {code}
> #PROPERTIES CONCATENATION
> prop1=file:
> prop2=dirname
> concat.property={{prop1}}{{prop2}}
> #PROPERTIES WITHOUT CONCATENATION
> property.complete=file:dirname
> {code}
> and you want to use the property concat.property. Using Camel 2.10.3 loading this property
doesn't create any kind of problem. When I upgrade to Camel 2.12.3 I get an exception, that
you can reproduce with the following informations.
> In *DefaultPropertiesParser* class of org.apache.camel.component.properties package,
I found a strange behaviour relative to that specific kind of property.  When I execute a
test like the following, (the first try to use concatenated property and the second try to
use property without concatenation):
> {code:title=PropertiesComponentConcatenatePropertiesTest.java}
> import org.apache.camel.CamelContext;
> import org.apache.camel.ContextTestSupport;
> import org.apache.camel.builder.RouteBuilder;
> public class PropertiesComponentConcatenatePropertiesTest extends ContextTestSupport
{
>     
>     @Override
>     protected CamelContext createCamelContext() throws Exception {
>         CamelContext context = super.createCamelContext();
>         context.addComponent("properties", new PropertiesComponent("classpath:org/apache/camel/component/properties/concatenation.properties"));
>         return context;
>     }
>     
>     @Override
>     protected void setUp() throws Exception {
>         System.setProperty("environment", "junit");
>         super.setUp();
>     }
>     
>     @Override
>     protected void tearDown() throws Exception {
>         System.clearProperty("environment");
>         super.tearDown();
>     }
>     
>     public void testConcatPropertiesComponentDefault() throws Exception {
>         context.addRoutes(new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from("direct:start").setBody(simple("${properties:concat.property}"))
>                 .to("mock:result");
>             }
>         });
>         context.start();
>         getMockEndpoint("mock:result").expectedBodiesReceived("file:dirname");
>         template.sendBody("direct:start", "Test");
>         assertMockEndpointsSatisfied();
>     }
>     
>     public void testWithoutConcatPropertiesComponentDefault() throws Exception {
>         context.addRoutes(new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from("direct:start").setBody(simple("${properties:property.complete}"))
>                 .to("mock:result");
>             }
>         });
>         context.start();
>         getMockEndpoint("mock:result").expectedBodiesReceived("file:dirname");
>         template.sendBody("direct:start", "Test");
>         assertMockEndpointsSatisfied();
>     }
> }
> {code}
> The first test return the following exception:
> {code}
> org.apache.camel.CamelExecutionException: Exception occurred during execution on the
exchange: Exchange[Message: Test]
> 	at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1379)
> 	at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:622)
> 	at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467)
> 	at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:463)
> 	at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:139)
> 	at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:144)
> 	at org.apache.camel.component.properties.PropertiesComponentConcatenatePropertiesTest.testConcatPropertiesComponentDefault(PropertiesComponentConcatenatePropertiesTest.java:56)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at junit.framework.TestCase.runTest(TestCase.java:176)
> 	at junit.framework.TestCase.runBare(TestCase.java:141)
> 	at org.apache.camel.TestSupport.runBare(TestSupport.java:58)
> 	at junit.framework.TestResult$1.protect(TestResult.java:122)
> 	at junit.framework.TestResult.runProtected(TestResult.java:142)
> 	at junit.framework.TestResult.run(TestResult.java:125)
> 	at junit.framework.TestCase.run(TestCase.java:129)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:255)
> 	at junit.framework.TestSuite.run(TestSuite.java:250)
> 	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> 	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: org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException:
Expecting }} but found end of string from text: prop1}}{{prop2
> 	at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1363)
> 	at org.apache.camel.builder.ExpressionBuilder$78.evaluate(ExpressionBuilder.java:1784)
> 	at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
> 	at org.apache.camel.builder.SimpleBuilder.evaluate(SimpleBuilder.java:83)
> 	at org.apache.camel.processor.SetBodyProcessor.process(SetBodyProcessor.java:46)
> 	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
> 	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
> 	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
> 	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
> 	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
> 	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
> 	at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:73)
> 	at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:378)
> 	at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:1)
> 	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:242)
> 	at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:346)
> 	at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:184)
> 	at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
> 	at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
> 	... 22 more
> Caused by: java.lang.IllegalArgumentException: Expecting }} but found end of string from
text: prop1}}{{prop2
> 	at org.apache.camel.component.properties.DefaultPropertiesParser.doParseUri(DefaultPropertiesParser.java:90)
> 	at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:51)
> 	at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:38)
> 	at org.apache.camel.component.properties.DefaultPropertiesParser.createPlaceholderPart(DefaultPropertiesParser.java:189)
> 	at org.apache.camel.component.properties.DefaultPropertiesParser.doParseUri(DefaultPropertiesParser.java:105)
> 	at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:51)
> 	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:158)
> 	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:117)
> 	at org.apache.camel.builder.ExpressionBuilder$78.evaluate(ExpressionBuilder.java:1781)
> 	... 40 more
> {code}
> It seems that *DefaultPropertiesParser* doesn't like concatenation of properties. I've
forked Camel project on GitHub and I've added the unit test posted above. Here is the link:
https://github.com/ancosen/camel
> Investigating the history of the particular class I found that the problem should arise
from:
>  *CAMEL-5328 supports resolution of nested properties in PropertiesComponent*
> Here is the link of the commit:
> https://github.com/apache/camel/commit/83f4b0f485521967d05de4e65025c4558a75ff3c
> Thanks.
> Bye



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message