You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2023/01/12 10:18:47 UTC

[uima-uimaj] branch bugfix/267-UIMA-Log4jLogger_impl-not-compatible-with-log4j-2.18.0 created (now fddc9c793)

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

rec pushed a change to branch bugfix/267-UIMA-Log4jLogger_impl-not-compatible-with-log4j-2.18.0
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git


      at fddc9c793 Issue #267 - UIMA Log4jLogger_impl not compatible with log4j 2.18.0+

This branch includes the following new commits:

     new fddc9c793 Issue #267 - UIMA Log4jLogger_impl not compatible with log4j 2.18.0+

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.



[uima-uimaj] 01/01: Issue #267 - UIMA Log4jLogger_impl not compatible with log4j 2.18.0+

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

rec pushed a commit to branch bugfix/267-UIMA-Log4jLogger_impl-not-compatible-with-log4j-2.18.0
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git

commit fddc9c793b8a9924d36b1d30e02909f71b447d2a
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Thu Jan 12 11:18:40 2023 +0100

    Issue #267 - UIMA Log4jLogger_impl not compatible with log4j 2.18.0+
    
    - Use proper API instead of reflection to obtain the marker
---
 .../org/apache/uima/util/impl/Log4jLogger_impl.java    | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/uimaj-core/src/main/java/org/apache/uima/util/impl/Log4jLogger_impl.java b/uimaj-core/src/main/java/org/apache/uima/util/impl/Log4jLogger_impl.java
index 7b6dd09c0..1f3f0e9da 100644
--- a/uimaj-core/src/main/java/org/apache/uima/util/impl/Log4jLogger_impl.java
+++ b/uimaj-core/src/main/java/org/apache/uima/util/impl/Log4jLogger_impl.java
@@ -18,10 +18,10 @@
  */
 package org.apache.uima.util.impl;
 
-import java.lang.reflect.Field;
 import java.text.MessageFormat;
 
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.MarkerManager;
 import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.Filter.Result;
 import org.apache.logging.log4j.core.LogEvent;
@@ -42,7 +42,6 @@ import org.slf4j.Marker;
  */
 public class Log4jLogger_impl extends Logger_common_impl {
 
-  final static private Object[] zeroLengthArray = new Object[0];
   /**
    * <p>
    * Markers that are for marking levels not supported by log4j.
@@ -246,19 +245,7 @@ public class Log4jLogger_impl extends Logger_common_impl {
       return null;
     }
 
-    Field markerField = null;
-    try {
-      markerField = m.getClass().getDeclaredField("marker");
-      markerField.setAccessible(true);
-      return (org.apache.logging.log4j.Marker) markerField.get(m);
-    } catch (Exception e) {
-      // Well, best effort...
-      return null;
-    } finally {
-      if (markerField != null) {
-        markerField.setAccessible(false);
-      }
-    }
+    return MarkerManager.getMarker(m.getName());
   }
 
   /*
@@ -412,5 +399,4 @@ public class Log4jLogger_impl extends Logger_common_impl {
   public boolean isWarnEnabled(Marker arg0) {
     return logger.isWarnEnabled(m(arg0));
   }
-
 }