You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/06/06 14:59:20 UTC

[5/6] camel git commit: Prevent crash when route IDs contain dollar signs

Prevent crash when route IDs contain dollar signs

Spring Boot configured route get names like `UpdateRelationCamelRoute$$EnhancerBySpringCGLIB$$24c87b04`. The dollar signs are interpreted as group references since the `java.lang.String#replaceFirst()` method works with regular expressions. An alternative to the proposed change is to use the `java.lang.String#replace()` method, assuming users of `MetricsRoutePolicy` don't put the `##routeId##` token multiple places in the name pattern and really want to keep all but the first literal occurrence.

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7ba35223
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7ba35223
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7ba35223

Branch: refs/heads/camel-2.18.x
Commit: 7ba35223c5a662e56c4619a12de51e3b1eca225a
Parents: 035120f
Author: Sune Keller <su...@gmail.com>
Authored: Tue Jun 6 13:26:41 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jun 6 16:58:06 2017 +0200

----------------------------------------------------------------------
 .../camel/component/metrics/routepolicy/MetricsRoutePolicy.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7ba35223/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java
----------------------------------------------------------------------
diff --git a/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java b/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java
index f39b33d..7eaa655 100644
--- a/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java
+++ b/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java
@@ -171,7 +171,7 @@ public class MetricsRoutePolicy extends RoutePolicySupport implements NonManaged
 
         String answer = namePattern;
         answer = answer.replaceFirst("##name##", name);
-        answer = answer.replaceFirst("##routeId##", route.getId());
+        answer = answer.replaceFirst("##routeId##", java.util.regex.Matcher.quoteReplacement(route.getId()));
         answer = answer.replaceFirst("##type##", type);
         return answer;
     }