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/21 20:58:49 UTC

[activemq-artemis] 27/33: Enforcing exception as the last argument

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 4fd4a1f8d8f23d10908372b4c1ca9e93a236ad88
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Jul 21 10:42:08 2022 -0400

    Enforcing exception as the last argument
---
 .../java/org/apache/activemq/artemis/logprocessor/LogProcessor.java   | 4 ++++
 .../apache/activemq/artemis/logprocessor/annotation/LogBundle.java    | 2 ++
 .../java/org/apache/activemq/artemis/logprocessor/SimpleBundle.java   | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

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 2d7c7f706a..5f077ab0cc 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
@@ -383,6 +383,10 @@ public class LogProcessor extends AbstractProcessor {
             debug("Parameter " + parameter + (isException? "is" : "is not") + " an exception");
          }
 
+         if (bundleAnnotation.enforceExceptionParameterAsLast() && isException && parameters.hasNext()) {
+            throw new IllegalArgumentException("Exception argument " + parameter + " has to be the last argument on the list. Look at " + executableMember);
+         }
+
          if (!isException) {
             nonExceptionParameters.add(parameter);
          }
diff --git a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogBundle.java b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogBundle.java
index e8910bbaf1..fbfcb37fc0 100644
--- a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogBundle.java
+++ b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/annotation/LogBundle.java
@@ -27,4 +27,6 @@ import java.lang.annotation.Target;
 public @interface LogBundle {
 
    String projectCode();
+
+   boolean enforceExceptionParameterAsLast() default true;
 }
diff --git a/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/SimpleBundle.java b/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/SimpleBundle.java
index 5780e13abd..a272894162 100644
--- a/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/SimpleBundle.java
+++ b/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/SimpleBundle.java
@@ -25,7 +25,7 @@ import org.apache.activemq.artemis.logprocessor.annotation.LogMessage;
 import org.apache.activemq.artemis.logprocessor.annotation.Message;
 import org.slf4j.Logger;
 
-@LogBundle(projectCode = "TST")
+@LogBundle(projectCode = "TST", enforceExceptionParameterAsLast = false)
 public interface SimpleBundle {
 
    SimpleBundle MESSAGES = CodeFactory.getCodeClass(SimpleBundle.class);