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/05/13 14:11:44 UTC
[activemq-artemis] branch new-logging updated: adding some known objects to LogProcessor, adding an additional test
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
The following commit(s) were added to refs/heads/new-logging by this push:
new 2a8c387729 adding some known objects to LogProcessor, adding an additional test
2a8c387729 is described below
commit 2a8c3877291664249d7f74c0828f0586462b0fd3
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Fri May 13 10:11:36 2022 -0400
adding some known objects to LogProcessor, adding an additional test
---
.../artemis/logprocessor/LogProcessor.java | 22 +++++++++++++--
.../activemq/artemis/logprocessor/MyObject.java | 32 ++++++++++++++++++++++
.../artemis/logprocessor/SimpleBundle.java | 3 ++
.../artemis/logprocessor/SimpleBundleTest.java | 10 +++++--
4 files changed, 62 insertions(+), 5 deletions(-)
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 70df0b66af..efadf15dc7 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
@@ -229,10 +229,28 @@ public class LogProcessor extends AbstractProcessor {
}
boolean isException(TypeMirror parameter) {
- //TODO: Or Exception? The args are fairly split, some Throwable, some Exception, some custom types.
- if (parameter.toString().equals("java.lang.Throwable")) {
+ if (parameter == null) {
+ // This should never happen, but my OCD can't help here, I'm adding this just in case
+ return false;
+ }
+ String parameterClazz = parameter.toString();
+ if (parameterClazz.equals("java.lang.Throwable") || parameterClazz.endsWith("Exception")) { // bad luck if you named or class with Exception and it was not an exception ;)
return true;
}
+
+ switch(parameterClazz) {
+ // some known types
+ case "java.lang.String":
+ case "java.lang.Object":
+ case "java.lang.Long":
+ case "java.lang.Integer":
+ case "java.lang.Number":
+ case "java.lang.Thread":
+ case "java.lang.ThreadGroup":
+ case "org.apache.activemq.artemis.api.core.SimpleString":
+ return false;
+ }
+
if (parameter instanceof DeclaredType) {
DeclaredType declaredType = (DeclaredType) parameter;
if (declaredType.asElement() instanceof TypeElement) {
diff --git a/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/MyObject.java b/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/MyObject.java
new file mode 100644
index 0000000000..207d334cff
--- /dev/null
+++ b/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/MyObject.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.logprocessor;
+
+public class MyObject {
+ private final String value;
+
+ public MyObject(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+
+}
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 123e09d880..61d54741a3 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
@@ -52,4 +52,7 @@ public interface SimpleBundle {
@Message(id = 9, value = "{} {} {} {}")
String abcd(String a, String b, String c, String d);
+
+ @Message(id = 10, value = "{} {} {} {}")
+ String objectsAbcd(MyObject a, MyObject b, MyObject c, MyObject d);
}
diff --git a/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/SimpleBundleTest.java b/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/SimpleBundleTest.java
index 3ab1da7ac4..642119f380 100644
--- a/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/SimpleBundleTest.java
+++ b/artemis-log-processor/src/test/java/org/apache/activemq/artemis/logprocessor/SimpleBundleTest.java
@@ -27,8 +27,6 @@ import org.slf4j.LoggerFactory;
public class SimpleBundleTest {
- private static final Logger logger = LoggerFactory.getLogger(SimpleBundleTest.class);
-
@Test
public void testSimple() {
Assert.assertEquals("TST1 Test", SimpleBundle.MESSAGES.simpleTest());
@@ -77,7 +75,13 @@ public class SimpleBundleTest {
@Test
public void testABCD() {
- System.out.println(SimpleBundle.MESSAGES.abcd("A", "B", "C", "D")); //TODO: use logger added at same time?
+ System.out.println(SimpleBundle.MESSAGES.abcd("A", "B", "C", "D"));
Assert.assertEquals("TST9 A B C D", SimpleBundle.MESSAGES.abcd("A", "B", "C", "D"));
}
+
+ @Test
+ public void testObjectsABCD() {
+ System.out.println(SimpleBundle.MESSAGES.abcd("A", "B", "C", "D"));
+ Assert.assertEquals("TST10 A B C D", SimpleBundle.MESSAGES.objectsAbcd(new MyObject("A"), new MyObject("B"), new MyObject("C"), new MyObject("D")));
+ }
}