You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/11/19 14:52:43 UTC

(commons-logging) branch master updated (f173161 -> f02f8cb)

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

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


    from f173161  Update version
     new e13a4ff  Remove unused exclusion
     new f03afeb  Remove redundant final (PMD)
     new b7a456d  Remove redundant final (PMD)
     new 8ae9ca7  Remove redundant final (PMD)
     new 33af4b5  Better comment and name
     new 1f3ec50  No need to use a FQCN for String here
     new 98e5591  Better local names
     new 12ae9e6  Remove obsolete comments
     new f02f8cb  Add missing @Deprecated

The 9 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:
 pmd.xml                                            |   1 -
 .../org/apache/commons/logging/LogFactory.java     | 134 ++++++++++-----------
 .../java/org/apache/commons/logging/LogSource.java |  12 +-
 .../logging/impl/Jdk13LumberjackLogger.java        |   9 +-
 .../apache/commons/logging/impl/Jdk14Logger.java   |   3 +-
 .../apache/commons/logging/impl/Log4JLogger.java   |  66 +++++-----
 .../commons/logging/impl/LogFactoryImpl.java       |  23 ++--
 .../apache/commons/logging/impl/LogKitLogger.java  |  12 +-
 .../org/apache/commons/logging/impl/SimpleLog.java |  36 +++---
 .../config/FirstPriorityConfigTestCase.java        |   6 +-
 .../logging/config/PriorityConfigTestCase.java     |   6 +-
 .../logging/jdk14/CustomConfigTestCase.java        |  15 +--
 .../logging/log4j/log4j12/TestAppender.java        |   6 +-
 .../commons/logging/logkit/StandardTestCase.java   |  12 +-
 .../commons/logging/noop/NoOpLogTestCase.java      |   3 +-
 .../simple/DateTimeCustomConfigTestCase.java       |   6 +-
 .../commons/logging/simple/DecoratedSimpleLog.java |  12 +-
 .../logging/tccl/log/TcclDisabledTestCase.java     |   6 +-
 .../logging/tccl/log/TcclEnabledTestCase.java      |   6 +-
 .../tccl/logfactory/TcclDisabledTestCase.java      |   6 +-
 .../tccl/logfactory/TcclEnabledTestCase.java       |   6 +-
 21 files changed, 159 insertions(+), 227 deletions(-)


(commons-logging) 01/09: Remove unused exclusion

Posted by gg...@apache.org.
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/commons-logging.git

commit e13a4ff80f6d57383ba64c6cfd1e71bda06c730d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 19 09:32:59 2023 -0500

    Remove unused exclusion
---
 pmd.xml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pmd.xml b/pmd.xml
index ceefc84..d988308 100644
--- a/pmd.xml
+++ b/pmd.xml
@@ -21,6 +21,5 @@ limitations under the License.
     xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
   <description>Excludes from default PMD rules.</description>
   <rule ref="rulesets/java/unusedcode.xml">
-    <exclude name="UnnecessaryParentheses"/>
   </rule>
 </ruleset>
\ No newline at end of file


(commons-logging) 07/09: Better local names

Posted by gg...@apache.org.
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/commons-logging.git

commit 98e559141d871877190877ca3fa94086fe99579d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 19 09:41:32 2023 -0500

    Better local names
---
 src/main/java/org/apache/commons/logging/impl/SimpleLog.java | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/logging/impl/SimpleLog.java b/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
index f3d332b..4e47c5f 100644
--- a/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
+++ b/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
@@ -143,12 +143,12 @@ public class SimpleLog implements Log, Serializable {
         if (null != in) {
             try {
                 simpleLogProps.load(in);
-            } catch (final IOException e) {
+            } catch (final IOException ignore) {
                 // ignored
             } finally {
                 try {
                     in.close();
-                } catch (final IOException e) {
+                } catch (final IOException ignore) {
                     // ignored
                 }
             }
@@ -171,9 +171,9 @@ public class SimpleLog implements Log, Serializable {
         }
     }
 
-    private static boolean getBooleanProperty(final String name, final boolean dephault) {
+    private static boolean getBooleanProperty(final String name, final boolean defaultValue) {
         final String prop = getStringProperty(name);
-        return prop == null ? dephault : "true".equalsIgnoreCase(prop);
+        return prop == null ? defaultValue : "true".equalsIgnoreCase(prop);
     }
 
     /**
@@ -258,9 +258,9 @@ public class SimpleLog implements Log, Serializable {
         }
         return prop == null ? simpleLogProps.getProperty(name) : prop;
     }
-    private static String getStringProperty(final String name, final String dephault) {
+    private static String getStringProperty(final String name, final String defaultValue) {
         final String prop = getStringProperty(name);
-        return prop == null ? dephault : prop;
+        return prop == null ? defaultValue : prop;
     }
     /** The name of this simple log instance */
     protected volatile String logName;


(commons-logging) 04/09: Remove redundant final (PMD)

Posted by gg...@apache.org.
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/commons-logging.git

commit 8ae9ca7740af0e2af37268f4f3973b0725fcf220
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 19 09:38:16 2023 -0500

    Remove redundant final (PMD)
---
 src/main/java/org/apache/commons/logging/LogFactory.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java
index f281d3b..1452abb 100644
--- a/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -1355,7 +1355,7 @@ public abstract class LogFactory {
      *
      * @param msg is the diagnostic message to be output.
      */
-    private static final void logDiagnostic(final String msg) {
+    private static void logDiagnostic(final String msg) {
         if (DIAGNOSTICS_STREAM != null) {
             DIAGNOSTICS_STREAM.print(diagnosticPrefix);
             DIAGNOSTICS_STREAM.println(msg);


(commons-logging) 02/09: Remove redundant final (PMD)

Posted by gg...@apache.org.
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/commons-logging.git

commit f03afeb1d99600351f291490939d9ac661146d34
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 19 09:35:18 2023 -0500

    Remove redundant final (PMD)
---
 src/main/java/org/apache/commons/logging/LogFactory.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java
index 747bd98..c517574 100644
--- a/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -461,7 +461,7 @@ public abstract class LogFactory {
      * that LogFactory.release(contextClassLoader) is called whenever a
      * webapp is undeployed.
      */
-    private static final Hashtable createFactoryStore() {
+    private static Hashtable createFactoryStore() {
         Hashtable result = null;
         String storeImplementationClass;
         try {


(commons-logging) 08/09: Remove obsolete comments

Posted by gg...@apache.org.
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/commons-logging.git

commit 12ae9e6324af0371779eb221b7f602830e67c169
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 19 09:51:16 2023 -0500

    Remove obsolete comments
    
    Move static block
---
 .../org/apache/commons/logging/LogFactory.java     | 108 ++++++++++-----------
 .../java/org/apache/commons/logging/LogSource.java |  12 +--
 .../logging/impl/Jdk13LumberjackLogger.java        |   9 +-
 .../apache/commons/logging/impl/Jdk14Logger.java   |   3 +-
 .../apache/commons/logging/impl/Log4JLogger.java   |  65 ++++++-------
 .../commons/logging/impl/LogFactoryImpl.java       |  21 ++--
 .../apache/commons/logging/impl/LogKitLogger.java  |  12 +--
 .../org/apache/commons/logging/impl/SimpleLog.java |  24 ++---
 .../config/FirstPriorityConfigTestCase.java        |   6 +-
 .../logging/config/PriorityConfigTestCase.java     |   6 +-
 .../logging/jdk14/CustomConfigTestCase.java        |  15 +--
 .../logging/log4j/log4j12/TestAppender.java        |   6 +-
 .../commons/logging/logkit/StandardTestCase.java   |  12 +--
 .../commons/logging/noop/NoOpLogTestCase.java      |   3 +-
 .../simple/DateTimeCustomConfigTestCase.java       |   6 +-
 .../commons/logging/simple/DecoratedSimpleLog.java |  12 +--
 .../logging/tccl/log/TcclDisabledTestCase.java     |   6 +-
 .../logging/tccl/log/TcclEnabledTestCase.java      |   6 +-
 .../tccl/logfactory/TcclDisabledTestCase.java      |   6 +-
 .../tccl/logfactory/TcclEnabledTestCase.java       |   6 +-
 20 files changed, 138 insertions(+), 206 deletions(-)

diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java
index f5b3baf..a024670 100644
--- a/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -68,8 +68,7 @@ public abstract class LogFactory {
     // lib and JCL have the necessary permissions even when the untrusted
     // caller does not. That's a pretty hard route to exploit though.
 
-    // ----------------------------------------------------- Manifest Constants
-
+    
     /**
      * The name ({@code priority}) of the key in the config file used to
      * specify the priority of that particular config file. The associated value
@@ -203,16 +202,14 @@ public abstract class LogFactory {
      */
     private static final int MAX_BROKEN_SERVICES = 3;
 
-    // ----------------------------------------------------------- Constructors
-
+    
     /**
      * The previously constructed {@code LogFactory} instances, keyed by
      * the {@code ClassLoader} with which it was created.
      */
     protected static Hashtable factories;
 
-    // --------------------------------------------------------- Public Methods
-
+    
     /**
      * Previously constructed {@code LogFactory} instance as in the
      * {@code factories} map, but for the case where
@@ -231,39 +228,6 @@ public abstract class LogFactory {
     @Deprecated
     protected static volatile LogFactory nullClassLoaderFactory;
 
-    static {
-        // note: it's safe to call methods before initDiagnostics (though
-        // diagnostic output gets discarded).
-        final ClassLoader thisClassLoader = getClassLoader(LogFactory.class);
-        thisClassLoaderRef = new WeakReference<>(thisClassLoader);
-        // In order to avoid confusion where multiple instances of JCL are
-        // being used via different classloaders within the same app, we
-        // ensure each logged message has a prefix of form
-        // [LogFactory from classloader OID]
-        //
-        // Note that this prefix should be kept consistent with that
-        // in LogFactoryImpl. However here we don't need to output info
-        // about the actual *instance* of LogFactory, as all methods that
-        // output diagnostics from this class are static.
-        String classLoaderName;
-        try {
-            if (thisClassLoader == null) {
-                classLoaderName = "BOOTLOADER";
-            } else {
-                classLoaderName = objectId(thisClassLoader);
-            }
-        } catch (final SecurityException e) {
-            classLoaderName = "UNKNOWN";
-        }
-        diagnosticPrefix = "[LogFactory from " + classLoaderName + "] ";
-        DIAGNOSTICS_STREAM = initDiagnostics();
-        logClassLoaderEnvironment(LogFactory.class);
-        factories = createFactoryStore();
-        if (isDiagnosticsEnabled()) {
-            logDiagnostic("BOOTSTRAP COMPLETED");
-        }
-    }
-
     /**
      * Remember this factory, so later calls to LogFactory.getCachedFactory
      * can return the previously created object (together with all its
@@ -567,8 +531,7 @@ public abstract class LogFactory {
         return (LogFactory) factories.get(contextClassLoader);
     }
 
-    // ------------------------------------------------------- Static Variables
-
+    
     /**
      * Safely get access to the classloader for the specified class.
      * <p>
@@ -728,8 +691,7 @@ public abstract class LogFactory {
         return directGetContextClassLoader();
     }
 
-    // --------------------------------------------------------- Static Methods
-
+    
     /**
      * Calls LogFactory.directGetContextClassLoader under the control of an
      * AccessController class. This means that java code running under a
@@ -1142,8 +1104,7 @@ public abstract class LogFactory {
                 (PrivilegedAction) () -> System.getProperty(key, def));
     }
 
-    // ------------------------------------------------------ Protected Methods
-
+    
     /**
      * Checks whether the supplied Throwable is one that needs to be
      * re-thrown and ignores all others.
@@ -1656,9 +1617,18 @@ public abstract class LogFactory {
      * @param name Name of the attribute to remove
      */
     public abstract void removeAttribute(String name);
+    
+    /**
+     * Sets the configuration attribute with the specified name.  Calling
+     * this with a {@code null} value is equivalent to calling
+     * {@code removeAttribute(name)}.
+     *
+     * @param name Name of the attribute to set
+     * @param value Value of the attribute to set, or {@code null}
+     *  to remove any setting for this attribute
+     */
+    public abstract void setAttribute(String name, Object value);
 
-    // ----------------------------------------------------------------------
-    // Static initializer block to perform initialization at class load time.
     //
     // We can't do this in the class constructor, as there are many
     // static methods on this class that can be called before any
@@ -1674,16 +1644,38 @@ public abstract class LogFactory {
     //
     // So the wisest thing to do is just to place this code at the very end
     // of the class file.
-    // ----------------------------------------------------------------------
 
-    /**
-     * Sets the configuration attribute with the specified name.  Calling
-     * this with a {@code null} value is equivalent to calling
-     * {@code removeAttribute(name)}.
-     *
-     * @param name Name of the attribute to set
-     * @param value Value of the attribute to set, or {@code null}
-     *  to remove any setting for this attribute
-     */
-    public abstract void setAttribute(String name, Object value);
+    static {
+        // note: it's safe to call methods before initDiagnostics (though
+        // diagnostic output gets discarded).
+        final ClassLoader thisClassLoader = getClassLoader(LogFactory.class);
+        thisClassLoaderRef = new WeakReference<>(thisClassLoader);
+        // In order to avoid confusion where multiple instances of JCL are
+        // being used via different classloaders within the same app, we
+        // ensure each logged message has a prefix of form
+        // [LogFactory from classloader OID]
+        //
+        // Note that this prefix should be kept consistent with that
+        // in LogFactoryImpl. However here we don't need to output info
+        // about the actual *instance* of LogFactory, as all methods that
+        // output diagnostics from this class are static.
+        String classLoaderName;
+        try {
+            if (thisClassLoader == null) {
+                classLoaderName = "BOOTLOADER";
+            } else {
+                classLoaderName = objectId(thisClassLoader);
+            }
+        } catch (final SecurityException e) {
+            classLoaderName = "UNKNOWN";
+        }
+        diagnosticPrefix = "[LogFactory from " + classLoaderName + "] ";
+        DIAGNOSTICS_STREAM = initDiagnostics();
+        logClassLoaderEnvironment(LogFactory.class);
+        factories = createFactoryStore();
+        if (isDiagnosticsEnabled()) {
+            logDiagnostic("BOOTSTRAP COMPLETED");
+        }
+    }
+
 }
diff --git a/src/main/java/org/apache/commons/logging/LogSource.java b/src/main/java/org/apache/commons/logging/LogSource.java
index 3201331..ca3444a 100644
--- a/src/main/java/org/apache/commons/logging/LogSource.java
+++ b/src/main/java/org/apache/commons/logging/LogSource.java
@@ -53,8 +53,7 @@ import org.apache.commons.logging.impl.NoOpLog;
 @Deprecated
 public class LogSource {
 
-    // ------------------------------------------------------- Class Attributes
-
+    
     /**
      * Logs.
      */
@@ -74,8 +73,7 @@ public class LogSource {
      */
     private static final String[] EMPTY_STRING_ARRAY = {};
 
-    // ----------------------------------------------------- Class Initializers
-
+    
     static {
 
         // Is Log4J Available?
@@ -132,8 +130,7 @@ public class LogSource {
 
     }
 
-    // ------------------------------------------------------------ Constructor
-
+    
     /**
      * Gets a {@code Log} instance by class.
      *
@@ -144,8 +141,7 @@ public class LogSource {
         return getInstance(clazz.getName());
     }
 
-    // ---------------------------------------------------------- Class Methods
-
+    
     /**
      * Gets a {@code Log} instance by class name.
      *
diff --git a/src/main/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java b/src/main/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java
index 7aab178..317e111 100644
--- a/src/main/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java
+++ b/src/main/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java
@@ -41,8 +41,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
     /** Serializable version identifier. */
     private static final long serialVersionUID = -8649807923527610591L;
 
-    // ----------------------------------------------------- Instance Variables
-
+    
     /**
      * This member variable simply ensures that any attempt to initialize
      * this class in a pre-1.4 JVM will result in an ExceptionInInitializerError.
@@ -70,8 +69,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
     /** Class and method found flag. */
     private boolean classAndMethodFound;
 
-    // ----------------------------------------------------------- Constructors
-
+    
     /**
      * Constructs a named instance of this Logger.
      *
@@ -82,8 +80,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
         logger = getLogger();
     }
 
-    // --------------------------------------------------------- Public Methods
-
+    
     /**
      * Logs a message with {@code java.util.logging.Level.FINE}.
      *
diff --git a/src/main/java/org/apache/commons/logging/impl/Jdk14Logger.java b/src/main/java/org/apache/commons/logging/impl/Jdk14Logger.java
index 80c4c09..f866ce1 100644
--- a/src/main/java/org/apache/commons/logging/impl/Jdk14Logger.java
+++ b/src/main/java/org/apache/commons/logging/impl/Jdk14Logger.java
@@ -41,8 +41,7 @@ public class Jdk14Logger implements Log, Serializable {
      */
     protected static final Level dummyLevel = Level.FINE;
 
-    // ----------------------------------------------------------- Constructors
-
+    
     /**
      * The underlying Logger implementation we are using.
      */
diff --git a/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java b/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java
index 90ffca4..59c3ee3 100644
--- a/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java
+++ b/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java
@@ -53,43 +53,9 @@ public class Log4JLogger implements Log, Serializable {
 
     private static final Priority traceLevel;
 
-    static {
-        if (!Priority.class.isAssignableFrom(Level.class)) {
-            // nope, this is log4j 1.3, so force an ExceptionInInitializerError
-            throw new InstantiationError("Log4J 1.2 not available");
-        }
-
-        // Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
-        // versions do not. If TRACE is not available, then we have to map
-        // calls to Log.trace(...) onto the DEBUG level.
-
-        Priority _traceLevel;
-        try {
-            _traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
-        } catch (final Exception ex) {
-            // ok, trace not available
-            _traceLevel = Level.DEBUG;
-        }
-        traceLevel = _traceLevel;
-    }
-
     /** Log to this logger */
     private transient volatile Logger logger;
 
-    // ------------------------------------------------------------
-    // Static Initializer.
-    //
-    // Note that this must come after the static variable declarations
-    // otherwise initializer expressions associated with those variables
-    // will override any settings done here.
-    //
-    // Verify that log4j is available, and that it is version 1.2.
-    // If an ExceptionInInitializerError is generated, then LogFactoryImpl
-    // will treat that as meaning that the appropriate underlying logging
-    // library is just not present - if discovery is in progress then
-    // discovery will continue.
-    // ------------------------------------------------------------
-
     /** Logger name */
     private final String name;
 
@@ -333,4 +299,35 @@ public class Log4JLogger implements Log, Serializable {
     public void warn(final Object message, final Throwable t) {
         getLogger().log(FQCN, Level.WARN, message, t);
     }
+
+    //
+    // Note that this must come after the static variable declarations
+    // otherwise initializer expressions associated with those variables
+    // will override any settings done here.
+    //
+    // Verify that log4j is available, and that it is version 1.2.
+    // If an ExceptionInInitializerError is generated, then LogFactoryImpl
+    // will treat that as meaning that the appropriate underlying logging
+    // library is just not present - if discovery is in progress then
+    // discovery will continue.    
+    static {
+        if (!Priority.class.isAssignableFrom(Level.class)) {
+            // nope, this is log4j 1.3, so force an ExceptionInInitializerError
+            throw new InstantiationError("Log4J 1.2 not available");
+        }
+
+        // Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
+        // versions do not. If TRACE is not available, then we have to map
+        // calls to Log.trace(...) onto the DEBUG level.
+
+        Priority _traceLevel;
+        try {
+            _traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
+        } catch (final Exception ex) {
+            // ok, trace not available
+            _traceLevel = Level.DEBUG;
+        }
+        traceLevel = _traceLevel;
+    }
+
 }
diff --git a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
index 2d7d01f..be3ffab 100644
--- a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
+++ b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
@@ -80,16 +80,14 @@ public class LogFactoryImpl extends LogFactory {
      */
     private static final String[] EMPTY_STRING_ARRAY = {};
 
-    // ----------------------------------------------------------- Constructors
-
+    
     /**
      * The name ({@code org.apache.commons.logging.Log}) of the system
      * property identifying our {@link Log} implementation class.
      */
     public static final String LOG_PROPERTY = "org.apache.commons.logging.Log";
 
-    // ----------------------------------------------------- Manifest Constants
-
+    
     /**
      * The deprecated system property used for backwards compatibility with
      * old versions of JCL.
@@ -169,8 +167,7 @@ public class LogFactoryImpl extends LogFactory {
         return LogFactory.getClassLoader(clazz);
     }
 
-    // ----------------------------------------------------- Instance Variables
-
+    
     /**
      * Gets the context ClassLoader.
      * This method is a workaround for a java 1.2 compiler bug.
@@ -280,8 +277,7 @@ public class LogFactoryImpl extends LogFactory {
      */
     protected Class[] logConstructorSignature = { String.class };
 
-    // --------------------------------------------------------- Public Methods
-
+    
     /**
      * The one-argument {@code setLogFactory} method of the selected
      * {@link org.apache.commons.logging.Log} method, if it exists.
@@ -492,13 +488,11 @@ public class LogFactoryImpl extends LogFactory {
         return logAdapter;
     }
 
-    // ------------------------------------------------------
-    // Static Methods
+        // Static Methods
     //
     // These methods only defined as workarounds for a java 1.2 bug;
     // theoretically none of these are needed.
-    // ------------------------------------------------------
-
+    
     /**
      * Attempts to create a Log instance for the given category name.
      * Follows the discovery process described in the class javadoc.
@@ -664,8 +658,7 @@ public class LogFactoryImpl extends LogFactory {
         return attributes.get(name);
     }
 
-    // ------------------------------------------------------ Protected Methods
-
+    
     /**
      * Return an array containing the names of all currently defined
      * configuration attributes.  If there are no such attributes, a zero
diff --git a/src/main/java/org/apache/commons/logging/impl/LogKitLogger.java b/src/main/java/org/apache/commons/logging/impl/LogKitLogger.java
index 354278d..f429794 100644
--- a/src/main/java/org/apache/commons/logging/impl/LogKitLogger.java
+++ b/src/main/java/org/apache/commons/logging/impl/LogKitLogger.java
@@ -40,16 +40,14 @@ public class LogKitLogger implements Log, Serializable {
     /** Serializable version identifier. */
     private static final long serialVersionUID = 3768538055836059519L;
 
-    // ------------------------------------------------------------- Attributes
-
+    
     /** Logging goes to this {@code LogKit} logger */
     protected transient volatile Logger logger;
 
     /** Name of this logger */
     protected String name;
 
-    // ------------------------------------------------------------ Constructor
-
+    
     /**
      * Constructs {@code LogKitLogger} which wraps the {@code LogKit}
      * logger with given name.
@@ -61,8 +59,7 @@ public class LogKitLogger implements Log, Serializable {
         this.logger = getLogger();
     }
 
-    // --------------------------------------------------------- Public Methods
-
+    
     /**
      * Logs a message with {@code org.apache.log.Priority.DEBUG}.
      *
@@ -76,8 +73,7 @@ public class LogKitLogger implements Log, Serializable {
         }
     }
 
-    // ----------------------------------------------------- Log Implementation
-
+    
     /**
      * Logs a message with {@code org.apache.log.Priority.DEBUG}.
      *
diff --git a/src/main/java/org/apache/commons/logging/impl/SimpleLog.java b/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
index 4e47c5f..f1b4225 100644
--- a/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
+++ b/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
@@ -74,8 +74,7 @@ public class SimpleLog implements Log, Serializable {
     /** Serializable version identifier. */
     private static final long serialVersionUID = 136942970684951178L;
 
-    // ------------------------------------------------------- Class Attributes
-
+    
     /** All system properties used by {@code SimpleLog} start with this */
     static protected final String systemPrefix = "org.apache.commons.logging.simplelog.";
 
@@ -111,8 +110,7 @@ public class SimpleLog implements Log, Serializable {
      */
     static protected DateFormat dateFormatter;
 
-    // ---------------------------------------------------- Log Level Constants
-
+    
     /** "Trace" level logging. */
     public static final int LOG_LEVEL_TRACE  = 1;
     /** "Debug" level logging. */
@@ -132,8 +130,7 @@ public class SimpleLog implements Log, Serializable {
     /** Enable no logging levels */
     public static final int LOG_LEVEL_OFF    = LOG_LEVEL_FATAL + 1;
 
-    // ------------------------------------------------------------ Initializer
-
+    
     // Initialize class attributes.
     // Load properties file, if found.
     // Override with system properties.
@@ -247,8 +244,7 @@ public class SimpleLog implements Log, Serializable {
             });
     }
 
-    // ------------------------------------------------------------- Attributes
-
+    
     private static String getStringProperty(final String name) {
         String prop = null;
         try {
@@ -265,13 +261,11 @@ public class SimpleLog implements Log, Serializable {
     /** The name of this simple log instance */
     protected volatile String logName;
 
-    // ------------------------------------------------------------ Constructor
-
+    
     /** The current log level */
     protected volatile int currentLogLevel;
 
-    // -------------------------------------------------------- Properties
-
+    
     /** The short name of this simple log instance */
     private volatile String shortLogName;
 
@@ -320,8 +314,7 @@ public class SimpleLog implements Log, Serializable {
         }
     }
 
-    // -------------------------------------------------------- Logging Methods
-
+    
     /**
      * Logs a message with
      * {@code org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG}.
@@ -378,8 +371,7 @@ public class SimpleLog implements Log, Serializable {
         }
     }
 
-    // -------------------------------------------------------- Log Implementation
-
+    
     /**
      * Log a message with {@code org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL}.
      *
diff --git a/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java b/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java
index 76b5ca7..70d33ba 100644
--- a/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java
@@ -41,8 +41,7 @@ import junit.framework.TestCase;
  */
 public class FirstPriorityConfigTestCase extends TestCase {
 
-    // ------------------------------------------- JUnit Infrastructure Methods
-
+    
 
     /**
      * Return the tests included in this test suite.
@@ -100,8 +99,7 @@ public class FirstPriorityConfigTestCase extends TestCase {
         LogFactory.releaseAll();
     }
 
-    // ----------------------------------------------------------- Test Methods
-
+    
     /**
      * Verify that the config file being used is the one containing
      * the desired configId value.
diff --git a/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java b/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java
index 2609f48..4019bc5 100644
--- a/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java
@@ -48,8 +48,7 @@ import junit.framework.TestCase;
 
 public class PriorityConfigTestCase extends TestCase {
 
-    // ------------------------------------------- JUnit Infrastructure Methods
-
+    
 
     /**
      * Return the tests included in this test suite.
@@ -118,8 +117,7 @@ public class PriorityConfigTestCase extends TestCase {
         LogFactory.releaseAll();
     }
 
-    // ----------------------------------------------------------- Test Methods
-
+    
     /**
      * Verify that the config file being used is the one containing
      * the desired configId value.
diff --git a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java
index 0e33e1c..7cc4c2e 100644
--- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java
@@ -45,8 +45,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
 
     protected static final String HANDLER_NAME = "org.apache.commons.logging.jdk14.TestHandler";
 
-    // ----------------------------------------------------------- Constructors
-
+    
 
     /**
      * Make a class available in the system classloader even when its classfile is
@@ -84,8 +83,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
     }
 
 
-    // ----------------------------------------------------- Instance Variables
-
+    
 
     /**
      * Given the name of a class that is somewhere in the classpath of the provided
@@ -157,8 +155,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
     protected LogManager manager;
 
 
-    // ------------------------------------------- JUnit Infrastructure Methods
-
+    
 
     /**
      * <p>The message levels that should have been logged.</p>
@@ -237,8 +234,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
     }
 
 
-    // ----------------------------------------------------------- Test Methods
-
+    
 
     // Log the messages with exceptions
     protected void logExceptionMessages() {
@@ -311,8 +307,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
     }
 
 
-    // -------------------------------------------------------- Support Methods
-
+    
 
     // Set up LogManager instance
     protected void setUpManager(final String config) throws Exception {
diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/TestAppender.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/TestAppender.java
index b5a42a0..4a9ac63 100644
--- a/src/test/java/org/apache/commons/logging/log4j/log4j12/TestAppender.java
+++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/TestAppender.java
@@ -36,8 +36,7 @@ public class TestAppender extends AppenderSkeleton {
     // The set of logged events for this appender
     private final List events;
 
-    // ----------------------------------------------------- Instance Variables
-
+    
 
     /**
      * Constructor.
@@ -47,8 +46,7 @@ public class TestAppender extends AppenderSkeleton {
     }
 
 
-    // ------------------------------------------------------- Appender Methods
-
+    
     @Override
     protected void append(final LoggingEvent event) {
         final StandardTests.LogEvent lev = new StandardTests.LogEvent();
diff --git a/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java b/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java
index aed7ade..1000a71 100644
--- a/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java
+++ b/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java
@@ -39,8 +39,7 @@ import junit.framework.Test;
 public class StandardTestCase extends AbstractLogTest {
 
 
-    // ----------------------------------------------------- Instance Variables
-
+    
 
     /**
      * Return the tests included in this test suite.
@@ -65,8 +64,7 @@ public class StandardTestCase extends AbstractLogTest {
     protected LogFactory factory;
 
 
-    // ------------------------------------------- JUnit Infrastructure Methods
-
+    
 
     /**
      * <p>The {@link Log} implementation we have selected.</p>
@@ -101,8 +99,7 @@ public class StandardTestCase extends AbstractLogTest {
         return new LogKitLogger(this.getClass().getName());
     }
 
-    // ----------------------------------------------------------- Test Methods
-
+    
     /**
      * Sets up instance variables required by this test case.
      */
@@ -147,8 +144,7 @@ public class StandardTestCase extends AbstractLogTest {
     }
 
 
-    // -------------------------------------------------------- Support Methods
-
+    
     // Test Serializability of standard instance
     public void testSerializable() throws Exception {
         checkStandard();
diff --git a/src/test/java/org/apache/commons/logging/noop/NoOpLogTestCase.java b/src/test/java/org/apache/commons/logging/noop/NoOpLogTestCase.java
index 868d02a..717137f 100644
--- a/src/test/java/org/apache/commons/logging/noop/NoOpLogTestCase.java
+++ b/src/test/java/org/apache/commons/logging/noop/NoOpLogTestCase.java
@@ -83,8 +83,7 @@ public class NoOpLogTestCase extends AbstractLogTest
     }
 
 
-    // -------------------------------------------------------- Support Methods
-
+    
     // Test Serializability of standard instance
     public void testSerializable() throws Exception {
         Log log = LogFactory.getLog(this.getClass().getName());
diff --git a/src/test/java/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java b/src/test/java/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java
index 21e914e..6c880e7 100644
--- a/src/test/java/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/simple/DateTimeCustomConfigTestCase.java
@@ -32,8 +32,7 @@ import junit.framework.Test;
  */
 public class DateTimeCustomConfigTestCase extends CustomConfigTestCase {
 
-    // ----------------------------------------------------------- Constructors
-
+    
     /**
      * Return the tests included in this test suite.
      * <p>
@@ -79,8 +78,7 @@ public class DateTimeCustomConfigTestCase extends CustomConfigTestCase {
     }
 
 
-    // ----------------------------------------------------------- Methods
-
+    
     /**
      * Sets up system properties required by this unit test. Here, we
      * set up the props defined in the parent class setProperties method,
diff --git a/src/test/java/org/apache/commons/logging/simple/DecoratedSimpleLog.java b/src/test/java/org/apache/commons/logging/simple/DecoratedSimpleLog.java
index 6aaa317..ef33552 100644
--- a/src/test/java/org/apache/commons/logging/simple/DecoratedSimpleLog.java
+++ b/src/test/java/org/apache/commons/logging/simple/DecoratedSimpleLog.java
@@ -33,8 +33,7 @@ import org.apache.commons.logging.impl.SimpleLog;
 public class DecoratedSimpleLog extends SimpleLog {
 
 
-    // ------------------------------------------------------------ Constructor
-
+    
 
     /**
      * Generated serial version ID.
@@ -45,8 +44,7 @@ public class DecoratedSimpleLog extends SimpleLog {
     protected ArrayList cache = new ArrayList();
 
 
-    // ------------------------------------------------------------- Properties
-
+    
     public DecoratedSimpleLog(final String name) {
         super(name);
     }
@@ -74,16 +72,14 @@ public class DecoratedSimpleLog extends SimpleLog {
     }
 
 
-    // ------------------------------------------------------- Protected Methods
-
+    
 
     public String getLogName() {
         return logName;
     }
 
 
-    // ---------------------------------------------------------- Public Methods
-
+    
 
     public boolean getShowDateTime() {
         return showDateTime;
diff --git a/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java
index 5a9adf2..7d94d46 100644
--- a/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/log/TcclDisabledTestCase.java
@@ -42,8 +42,7 @@ public class TcclDisabledTestCase extends TestCase {
     public static final String MY_LOG_IMPL =
         MY_LOG_PKG + ".MyLog";
 
-    // ------------------------------------------- JUnit Infrastructure Methods
-
+    
     /**
      * Return the tests included in this test suite.
      */
@@ -104,8 +103,7 @@ public class TcclDisabledTestCase extends TestCase {
         LogFactory.releaseAll();
     }
 
-    // ----------------------------------------------------------- Test Methods
-
+    
     /**
      * Verify that MyLog is only loadable via the tccl.
      */
diff --git a/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java
index 2c9e1f8..c4a9d6b 100644
--- a/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/log/TcclEnabledTestCase.java
@@ -42,8 +42,7 @@ public class TcclEnabledTestCase extends TestCase {
     public static final String MY_LOG_IMPL =
         MY_LOG_PKG + ".MyLog";
 
-    // ------------------------------------------- JUnit Infrastructure Methods
-
+    
     /**
      * Return the tests included in this test suite.
      */
@@ -104,8 +103,7 @@ public class TcclEnabledTestCase extends TestCase {
         LogFactory.releaseAll();
     }
 
-    // ----------------------------------------------------------- Test Methods
-
+    
     /**
      * Verify that MyLogFactoryImpl is only loadable via the tccl.
      */
diff --git a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java
index e7d7af2..2e5038b 100644
--- a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclDisabledTestCase.java
@@ -41,8 +41,7 @@ public class TcclDisabledTestCase extends TestCase {
     public static final String MY_LOG_FACTORY_IMPL =
         MY_LOG_FACTORY_PKG + ".MyLogFactoryImpl";
 
-    // ------------------------------------------- JUnit Infrastructure Methods
-
+    
 
     /**
      * Return the tests included in this test suite.
@@ -106,8 +105,7 @@ public class TcclDisabledTestCase extends TestCase {
         LogFactory.releaseAll();
     }
 
-    // ----------------------------------------------------------- Test Methods
-
+    
     /**
      * Verify that MyLogFactoryImpl is only loadable via the tccl.
      */
diff --git a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java
index b2e9326..999f74b 100644
--- a/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java
+++ b/src/test/java/org/apache/commons/logging/tccl/logfactory/TcclEnabledTestCase.java
@@ -35,8 +35,7 @@ import junit.framework.TestCase;
 
 public class TcclEnabledTestCase extends TestCase {
 
-    // ------------------------------------------- JUnit Infrastructure Methods
-
+    
 
     /**
      * Return the tests included in this test suite.
@@ -100,8 +99,7 @@ public class TcclEnabledTestCase extends TestCase {
         LogFactory.releaseAll();
     }
 
-    // ----------------------------------------------------------- Test Methods
-
+    
     /**
      * Verify that MyLogFactoryImpl is only loadable via the tccl.
      */


(commons-logging) 03/09: Remove redundant final (PMD)

Posted by gg...@apache.org.
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/commons-logging.git

commit b7a456d06ecc8c5e4cd1faa3ca41a352b3dcb7ec
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 19 09:36:19 2023 -0500

    Remove redundant final (PMD)
---
 src/main/java/org/apache/commons/logging/LogFactory.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java
index c517574..f281d3b 100644
--- a/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -633,7 +633,7 @@ public abstract class LogFactory {
      * webapps. Webapps can also use explicit priorities to override a configuration
      * file in the shared classpath if needed.
      */
-    private static final Properties getConfigurationFile(final ClassLoader classLoader, final String fileName) {
+    private static Properties getConfigurationFile(final ClassLoader classLoader, final String fileName) {
         Properties props = null;
         double priority = 0.0;
         URL propsUrl = null;


(commons-logging) 09/09: Add missing @Deprecated

Posted by gg...@apache.org.
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/commons-logging.git

commit f02f8cbc5d8837e897f6258e88c34ae2194fab79
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 19 09:52:29 2023 -0500

    Add missing @Deprecated
---
 src/main/java/org/apache/commons/logging/impl/Log4JLogger.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java b/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java
index 59c3ee3..014f008 100644
--- a/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java
+++ b/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java
@@ -43,6 +43,7 @@ import org.apache.log4j.Priority;
  *
  * @deprecated Scheduled for removal since version 1.x of Log4j has reached end-of-life.
  */
+@Deprecated
 public class Log4JLogger implements Log, Serializable {
 
     /** Serializable version identifier. */


(commons-logging) 05/09: Better comment and name

Posted by gg...@apache.org.
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/commons-logging.git

commit 33af4b50dc552ddaadf8b9ff9f8c0889ede8c9cb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 19 09:38:27 2023 -0500

    Better comment and name
---
 .../java/org/apache/commons/logging/LogFactory.java  | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java
index 1452abb..f5b3baf 100644
--- a/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -525,16 +525,16 @@ public abstract class LogFactory {
 
         try {
             classLoader = Thread.currentThread().getContextClassLoader();
-        } catch (final SecurityException ex) {
-            /**
-             * getContextClassLoader() throws SecurityException when
-             * the context class loader isn't an ancestor of the
-             * calling class's class loader, or if security
-             * permissions are restricted.
-             *
-             * We ignore this exception to be consistent with the previous
-             * behavior (e.g. 1.1.3 and earlier).
-             */
+        } catch (final SecurityException ignore) {
+            //
+            // getContextClassLoader() throws SecurityException when
+            // the context class loader isn't an ancestor of the
+            // calling class's class loader, or if security
+            // permissions are restricted.
+            //
+            // We ignore this exception to be consistent with the previous
+            // behavior (e.g. 1.1.3 and earlier).
+            //
             // ignore
         }
 


(commons-logging) 06/09: No need to use a FQCN for String here

Posted by gg...@apache.org.
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/commons-logging.git

commit 1f3ec507c4c40a2daab3298bf83f2ef1f90d0571
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 19 09:39:24 2023 -0500

    No need to use a FQCN for String here
---
 src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
index 2dc4015..2d7d01f 100644
--- a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
+++ b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
@@ -278,7 +278,7 @@ public class LogFactoryImpl extends LogFactory {
     /**
      * The signature of the Constructor to be used.
      */
-    protected Class[] logConstructorSignature = { java.lang.String.class };
+    protected Class[] logConstructorSignature = { String.class };
 
     // --------------------------------------------------------- Public Methods