You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/04/22 09:38:47 UTC

[camel] branch main updated: CAMEL-17894: avoid compiling the regex everytime

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 4ca66228a14 CAMEL-17894: avoid compiling the regex everytime
4ca66228a14 is described below

commit 4ca66228a1488ba5da8f12120c122b39ae5d30e3
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Apr 22 09:32:02 2022 +0200

    CAMEL-17894: avoid compiling the regex everytime
---
 .../main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java
index 8bd0943dc98..fc320536204 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java
@@ -28,6 +28,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 import javax.annotation.Generated;
@@ -68,6 +69,7 @@ import static org.apache.camel.tooling.util.PackageHelper.loadText;
 @Mojo(name = "generate-endpoint-dsl", threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
       defaultPhase = LifecyclePhase.PROCESS_CLASSES)
 public class EndpointDslMojo extends AbstractGeneratorMojo {
+    private static final transient Pattern COMMA_PRESERVER_PATTERN = Pattern.compile(",(\\S)");
 
     /**
      * The project build directory
@@ -817,7 +819,7 @@ public class EndpointDslMojo extends AbstractGeneratorMojo {
                         method.setName(ms.getName());
                         // roaster dont preserve the message body with nicely formatted space after comma
                         String body = ms.getBody();
-                        body = body.replaceAll(",(\\S)", ", $1");
+                        body = COMMA_PRESERVER_PATTERN.matcher(body).replaceAll(", $1");
                         method.setBody(body);
                         method.setReturnType(getQualifiedType(ms.getReturnType()));
                         for (Object o : ms.getParameters()) {