You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2022/07/28 17:37:28 UTC

[activemq-artemis] branch new-logging updated (815eefb624 -> dba068a0a3)

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

clebertsuconic pushed a change to branch new-logging
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


 discard 815eefb624 Adding safeguard against {} on LogProcessor
     new dba068a0a3 Adding safeguard against {?} on LogProcessor

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (815eefb624)
            \
             N -- N -- N   refs/heads/new-logging (dba068a0a3)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[activemq-artemis] 01/01: Adding safeguard against {?} on LogProcessor

Posted by cl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch new-logging
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit dba068a0a3f21aea16449b804db82eeafdb42422
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Jul 28 13:32:24 2022 -0400

    Adding safeguard against {?} on LogProcessor
---
 .../artemis/logprocessor/LogProcessor.java         | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java
index f7e2ed5279..15fd37e187 100644
--- a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java
+++ b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java
@@ -37,6 +37,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.function.Consumer;
 
 import org.apache.activemq.artemis.logprocessor.annotation.LogBundle;
 import org.apache.activemq.artemis.logprocessor.annotation.GetLogger;
@@ -71,6 +72,23 @@ public class LogProcessor extends AbstractProcessor {
    }
 
 
+   private static void tupples(String arg, char open, char close, Consumer<String> stringConsumer) {
+      int openAt = -1;
+      for (int i = 0; i < arg.length(); i++) {
+         char charAt = arg.charAt(i);
+
+         if (charAt == open) {
+            openAt = i;
+         } else if (charAt == close) {
+            if (openAt >= 0) {
+               stringConsumer.accept(arg.substring(openAt + 1, i));
+            }
+            openAt = -1;
+         }
+
+      }
+   }
+
 
    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
@@ -192,6 +210,14 @@ public class LogProcessor extends AbstractProcessor {
       return true;
    }
 
+   private void verifyLogArguments(String logMessage, Object holder) {
+      tupples(logMessage, '{', '}', (tupple) -> {
+         if (!tupple.equals("")) {
+            throw new IllegalArgumentException("Invalid log argument {" + tupple + "} on message \'" + logMessage + "\' as part of " + holder + "\nreplace it by {}");
+         }
+      });
+   }
+
    private void generateMessage(LogBundle bundleAnnotation,
                                 PrintWriter writerOutput,
                                 ExecutableElement executableMember,
@@ -204,6 +230,8 @@ public class LogProcessor extends AbstractProcessor {
          throw new IllegalStateException("message " + messageAnnotation.id() + " with definition = " + messageAnnotation.value() + " was previously defined as " + previousMessage);
       }
 
+      verifyLogArguments(messageAnnotation.value(), executableMember);
+
       processedMessages.put(messageAnnotation.id(), messageAnnotation.value());
 
       // This is really a debug output
@@ -346,6 +374,8 @@ public class LogProcessor extends AbstractProcessor {
          throw new IllegalStateException("message " + messageAnnotation.id() + " with definition = " + messageAnnotation.value() + " was previously defined as " + previousMessage);
       }
 
+      verifyLogArguments(messageAnnotation.value(), executableMember);
+
       processedMessages.put(messageAnnotation.id(), messageAnnotation.value());
 
       // This is really a debug output