[
https://issues.apache.org/jira/browse/CAMEL-6400?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-6400:
-------------------------------
Fix Version/s: Future
> CamelContext fails to start using placeholder in "simple" in conjunction with
> BridgePropertyPlaceholder
> -------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-6400
> URL: https://issues.apache.org/jira/browse/CAMEL-6400
> Project: Camel
> Issue Type: Bug
> Components: camel-spring
> Affects Versions: 2.11.0
> Reporter: Nerses Aznauryan
> Fix For: Future
>
> Attachments: tests_to_reproduce_bug.patch
>
>
> Recently after upgrading from 2.10.3 to 2.11.0 I have encountered the
> following bug.
> The problematic part was looking like this:
> {code}
> from("direct:start")
> .setHeader(Exchange.FILE_NAME,
> simple("{{file.rootdir}}/${in.header.CamelFileName}"))
> .to("mock:result");
> {code}
> Camel was failing to start with the following exception
> {code}
> org.apache.camel.FailedToCreateRouteException: Failed to create route route1
> at: >>> SetHeader[CamelFileName, simple{Simple:
> {{file.rootdir}}/${in.header.CamelFileName}}] <<< in route:
> Route(route1)[[From[direct:start]] -> [SetHeader[CamelFileNa... because of
> Could not resolve placeholder 'in.header.CamelFileName' in string value
> "/root/dir/${in.header.CamelFileName}"
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:883)
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:176)
> at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:755)
> at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1857)
> at
> org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:692)
> at
> org.apache.camel.builder.RouteBuilder.populateRoutes(RouteBuilder.java:337)
> at
> org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:264)
> at
> org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:654)
> at
> org.apache.camel.ContextTestSupport.setUp(ContextTestSupport.java:115)
> at
> org.apache.camel.spring.SpringTestSupport.setUp(SpringTestSupport.java:54)
> at org.apache.camel.TestSupport.runBare(TestSupport.java:58)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
> at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
> Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder
> 'in.header.CamelFileName' in string value
> "/root/dir/${in.header.CamelFileName}"
> at
> org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:173)
> at
> org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:125)
> at
> org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer.springResolvePlaceholders(BridgePropertyPlaceholderConfigurer.java:180)
> at
> org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer.parseUri(BridgePropertyPlaceholderConfigurer.java:143)
> at
> org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:161)
> at
> org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:120)
> at
> org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:1100)
> at
> org.apache.camel.model.ProcessorDefinition.resolvePropertyPlaceholders(ProcessorDefinition.java:556)
> at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:471)
> at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:197)
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:880)
> ... 22 more
> {code}
> I have created a small test to reproduce the bug, and thanks to git bisect I
> found the commit that introduced this bug. It is commit ea4c0ab5 "CAMEL-6233:
> BridgePropertyPlaceholderConfigurer does not support nested Spring
> properties". The problem is that it is trying to resolve the whole simple
> with the property resolver but after resolving the spring property it treats
> {{${in.header.CamelFileName}}} as a spring placeholder and fails to
> find it.
> There is a workaround. If {{{{file.rootdir}}}} is
> replaced by {{${properties:file.rootdir}}} then Camel starts just
> fine.
> The test to reproduce is attached.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)