[camel] branch master updated: camel-core - optimize. Avoid using regexp patterns on patterns that are not regexp anyway. This reduced memory in JDK8

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: camel-core - optimize. Avoid using regexp patterns on patterns that are not regexp anyway. This reduced memory in JDK8

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 49f1bbb  camel-core - optimize. Avoid using regexp patterns on patterns that are not regexp anyway. This reduced memory in JDK8
49f1bbb is described below

commit 49f1bbbb55db1ee540fb6b6c455e37a3810c7c52
Author: Claus Ibsen <[hidden email]>
AuthorDate: Mon Feb 17 16:58:48 2020 +0100

    camel-core - optimize. Avoid using regexp patterns on patterns that are not regexp anyway. This reduced memory in JDK8
---
 .../apache/camel/impl/engine/DefaultStreamCachingStrategy.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultStreamCachingStrategy.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultStreamCachingStrategy.java
index 44d88bb..bf01555 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultStreamCachingStrategy.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultStreamCachingStrategy.java
@@ -22,7 +22,6 @@ import java.lang.management.MemoryMXBean;
 import java.util.LinkedHashSet;
 import java.util.Set;
 import java.util.UUID;
-import java.util.regex.Matcher;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
@@ -34,6 +33,7 @@ import org.apache.camel.support.service.ServiceSupport;
 import org.apache.camel.util.FilePathResolver;
 import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.StringHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -244,12 +244,12 @@ public class DefaultStreamCachingStrategy extends ServiceSupport implements Came
 
     protected String defaultManagementName(String path) {
         // must quote the names to have it work as literal replacement
-        String name = Matcher.quoteReplacement(camelContext.getName());
+        String name = camelContext.getName();
 
         // replace tokens
         String answer = path;
-        answer = answer.replaceFirst("#camelId#", name);
-        answer = answer.replaceFirst("#name#", name);
+        answer = StringHelper.replaceAll(answer, "#camelId#", name);
+        answer = StringHelper.replaceAll(answer, "#name#", name);
         // replace custom
         answer = customResolveManagementName(answer);
         return answer;
@@ -258,7 +258,7 @@ public class DefaultStreamCachingStrategy extends ServiceSupport implements Came
     protected String customResolveManagementName(String pattern) {
         if (pattern.contains("#uuid#")) {
             String uuid = UUID.randomUUID().toString();
-            pattern = pattern.replaceFirst("#uuid#", uuid);
+            pattern = StringHelper.replaceAll(pattern, "#uuid#", uuid);
         }
         return FilePathResolver.resolvePath(pattern);
     }