This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4d72f6543dcb609b12f09b7d518e6948b7cb37aa
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Aug 7 10:35:00 2022 +0200

    CAMEL-18328: Polished
---
 .../org/apache/camel/model/RoutesDefinition.java   | 24 +++++++++++++---------
 .../model/RouteConfigurationOnExceptionTest.java   |  3 ---
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/RoutesDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/RoutesDefinition.java
index c39cc78e045..1a5b26e0498 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/RoutesDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/RoutesDefinition.java
@@ -255,25 +255,29 @@ public class RoutesDefinition extends 
OptionalIdentifiedDefinition<RoutesDefinit
             List<RouteConfigurationDefinition> globalConfigurations
                     = 
getCamelContext().adapt(ModelCamelContext.class).getRouteConfigurationDefinitions();
             if (globalConfigurations != null) {
-
-                // if there are multiple ids configured then we should apply 
in that same order
                 String[] ids;
                 if (route.getRouteConfigurationId() != null) {
-                    // if the RouteConfigurationId was configured with 
property placeholder it should be resolved
+                    // if the RouteConfigurationId was configured with 
property placeholder it should be resolved first
+                    // and include properties sources from the template 
parameters
                     if (route.getTemplateParameters() != null && 
route.getRouteConfigurationId().startsWith("{{")) {
-                        OrderedLocationProperties locationProperties = new 
OrderedLocationProperties();
-                        locationProperties.putAll("TemplateProperties", new 
HashMap<>(route.getTemplateParameters()));
-                        
camelContext.getPropertiesComponent().setLocalProperties(locationProperties);
-                        ids = camelContext.adapt(ExtendedCamelContext.class)
-                                
.resolvePropertyPlaceholders(route.getRouteConfigurationId(), true)
-                                .split(",");
+                        OrderedLocationProperties props = new 
OrderedLocationProperties();
+                        props.putAll("TemplateProperties", new 
HashMap<>(route.getTemplateParameters()));
+                        
camelContext.getPropertiesComponent().setLocalProperties(props);
+                        try {
+                            ids = 
camelContext.adapt(ExtendedCamelContext.class)
+                                    
.resolvePropertyPlaceholders(route.getRouteConfigurationId(), true)
+                                    .split(",");
+                        } finally {
+                            
camelContext.getPropertiesComponent().setLocalProperties(null);
+                        }
                     } else {
                         ids = route.getRouteConfigurationId().split(",");
                     }
                 } else {
-                    ids = new String[] { "*" };
+                    ids = new String[]{"*"};
                 }
 
+                // if there are multiple ids configured then we should apply 
in that same order
                 for (String id : ids) {
                     // sort according to ordered
                     
globalConfigurations.stream().sorted(OrderedComparator.get())
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/model/RouteConfigurationOnExceptionTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/model/RouteConfigurationOnExceptionTest.java
index 0bcbb0e7bab..03b29874031 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/model/RouteConfigurationOnExceptionTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/model/RouteConfigurationOnExceptionTest.java
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.model;
 
 import org.apache.camel.ContextTestSupport;
@@ -88,7 +87,6 @@ public class RouteConfigurationOnExceptionTest extends 
ContextTestSupport {
 
     @Test
     void testRouteTemplateCanSupportRouteConfiguration() throws Exception {
-
         getMockEndpoint("mock:result").expectedMessageCount(1);
         getMockEndpoint("mock:result").expectedBodiesReceived("Error 
Received");
         template.sendBody("direct:start-template", "foo");
@@ -97,7 +95,6 @@ public class RouteConfigurationOnExceptionTest extends 
ContextTestSupport {
 
     @Test
     void testRouteTemplateCanSupportRouteConfigurationWithParameter() throws 
Exception {
-
         getMockEndpoint("mock:result").expectedMessageCount(1);
         getMockEndpoint("mock:result").expectedBodiesReceived("Error 
Received");
         template.sendBody("direct:start-template-parameter", "foo");

Reply via email to