You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2021/12/30 15:51:26 UTC

[logging-log4j2] branch master updated: Log4j 1.2 bridge method Category.exists(String) should be static.

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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/master by this push:
     new f914a38  Log4j 1.2 bridge method Category.exists(String) should be static.
f914a38 is described below

commit f914a38aaf8e6d354c7a73547838a0a5be3c3d53
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 30 10:51:23 2021 -0500

    Log4j 1.2 bridge method Category.exists(String) should be static.
---
 log4j-1.2-api/src/main/java/org/apache/log4j/Category.java   | 12 +++++++++++-
 .../src/test/java/org/apache/log4j/CategoryTest.java         |  5 +++++
 src/changes/changes.xml                                      |  3 +++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java b/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
index c4c0ac0..8674e61 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
@@ -407,7 +407,17 @@ public class Category implements AppenderAttachable {
         }
     }
 
-    public boolean exists(final String name) {
+    /**
+     * Tests if the named category exists (in the default hierarchy).
+     * 
+     * @param name The name to test.
+     * @return Whether the name exists.
+     * 
+     * @deprecated Please use {@link LogManager#exists(String)} instead.
+     * @since 0.8.5
+     */
+    @Deprecated
+    public static boolean exists(final String name) {
         return PrivateManager.getContext().hasLogger(name);
     }
 
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java
index 9bc72e3..14592fb 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java
@@ -70,6 +70,11 @@ public class CategoryTest {
         appender.clear();
     }
 
+    @Test
+    public void testExist() throws Exception {
+        assertFalse(Category.exists("Does not exist for sure"));
+    }
+
     /**
      * Tests Category.forcedLog.
      */
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 54aec9c..6d4601d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -194,6 +194,9 @@
       <action dev="ggregory" type="fix">
         Log4j 1.2 bridge class Category should implement AppenderAttachable.
       </action>
+      <action dev="ggregory" type="fix">
+        Log4j 1.2 bridge method Category.exists(String) should be static.
+      </action>
     </release>
     <release version="2.17.1" date="2021-MM-DD" description="GA Release 2.17.1">
       <action issue="LOG4J2-3292" dev="ckozak" type="fix">