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/20 14:59:04 UTC

(commons-logging) branch master updated (2039eeb -> 6b11d8a)

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 2039eeb  Fix compiler warnings
     new 7e340b5  Better error messages
     new 0467d41  Refactor to local variable
     new c265c9d  Deprecate org.apache.commons.logging.impl.WeakHashtable without replacement.
     new 2ea4f44  Document empty blocks
     new 6e6b27c  Document empty blocks
     new d262d09  Document empty blocks
     new 68a33ab  Remove extra whitespace
     new 0899b5b  Fix compiler warning
     new 5360b9c  Better local name
     new 51a3978  Fix compiler warning
     new 6b11d8a  Spelling in comments

The 11 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:
 src/changes/changes.xml                            |  4 +++
 .../org/apache/commons/logging/LogFactory.java     | 42 +++++++++++-----------
 .../java/org/apache/commons/logging/LogSource.java | 17 ++++-----
 .../commons/logging/impl/Log4jApiLogFactory.java   |  1 +
 .../commons/logging/impl/LogFactoryImpl.java       | 26 +++++++-------
 .../org/apache/commons/logging/impl/NoOpLog.java   | 14 ++++++++
 .../logging/impl/ServletContextCleaner.java        | 13 +++----
 .../apache/commons/logging/impl/WeakHashtable.java |  8 +++--
 .../commons/logging/PathableClassLoader.java       |  8 ++---
 .../apache/commons/logging/PathableTestSuite.java  |  4 +--
 .../logging/pathable/ChildFirstTestCase.java       | 10 +++---
 .../logging/pathable/ParentFirstTestCase.java      | 10 +++---
 12 files changed, 87 insertions(+), 70 deletions(-)


(commons-logging) 06/11: Document empty blocks

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 d262d0986eb994934be4c26df9351d99444486a2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 09:46:16 2023 -0500

    Document empty blocks
---
 src/main/java/org/apache/commons/logging/LogSource.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/commons/logging/LogSource.java b/src/main/java/org/apache/commons/logging/LogSource.java
index 5a02c34..60d14b1 100644
--- a/src/main/java/org/apache/commons/logging/LogSource.java
+++ b/src/main/java/org/apache/commons/logging/LogSource.java
@@ -97,7 +97,8 @@ public class LogSource {
             if (name == null) {
                 name = System.getProperty("org.apache.commons.logging.Log");
             }
-        } catch (final Throwable t) {
+        } catch (final Throwable ignore) {
+            // Ignore
         }
         if (name != null) {
             try {
@@ -105,8 +106,8 @@ public class LogSource {
             } catch (final Throwable t) {
                 try {
                     setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
-                } catch (final Throwable u) {
-                    // ignored
+                } catch (final Throwable ignore) {
+                    // Ignore
                 }
             }
         } else {
@@ -121,8 +122,8 @@ public class LogSource {
             } catch (final Throwable t) {
                 try {
                     setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
-                } catch (final Throwable u) {
-                    // ignored
+                } catch (final Throwable ignore) {
+                    // Ignore
                 }
             }
         }


(commons-logging) 08/11: Fix compiler warning

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 0899b5bd2b56cacb9d10a6ffacfb815bb2c47567
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 09:48:00 2023 -0500

    Fix compiler warning
---
 src/main/java/org/apache/commons/logging/LogSource.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/logging/LogSource.java b/src/main/java/org/apache/commons/logging/LogSource.java
index 7711031..7239cc5 100644
--- a/src/main/java/org/apache/commons/logging/LogSource.java
+++ b/src/main/java/org/apache/commons/logging/LogSource.java
@@ -65,7 +65,7 @@ public class LogSource {
     static protected boolean jdk14IsAvailable;
 
     /** Constructor for current log class */
-    static protected Constructor logImplctor;
+    static protected Constructor<?> logImplctor;
 
     /**
      * An empty immutable {@code String} array.


(commons-logging) 10/11: Fix compiler warning

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 51a3978280cf938cd4e7857b3b284b72df20bbe4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 09:54:16 2023 -0500

    Fix compiler warning
---
 .../org/apache/commons/logging/impl/ServletContextCleaner.java     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java b/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java
index fc50642..7c1137d 100644
--- a/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java
+++ b/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java
@@ -48,7 +48,7 @@ import org.apache.commons.logging.LogFactory;
  */
 public class ServletContextCleaner implements ServletContextListener {
 
-    private static final Class[] RELEASE_SIGNATURE = {ClassLoader.class};
+    private static final Class<?>[] RELEASE_SIGNATURE = { ClassLoader.class };
 
     /**
      * Invoked when a webapp is undeployed, this tells the LogFactory
@@ -98,12 +98,13 @@ public class ServletContextCleaner implements ServletContextListener {
             // via this loader, but is accessible via some ancestor then that class
             // will be returned.
             try {
-                final Class logFactoryClass = loader.loadClass("org.apache.commons.logging.LogFactory");
+                @SuppressWarnings("unchecked")
+                final Class<LogFactory> logFactoryClass = (Class<LogFactory>) loader.loadClass("org.apache.commons.logging.LogFactory");
                 final Method releaseMethod = logFactoryClass.getMethod("release", RELEASE_SIGNATURE);
                 releaseMethod.invoke(null, params);
                 loader = logFactoryClass.getClassLoader().getParent();
             } catch (final ClassNotFoundException ex) {
-                // Neither the current classloader nor any of its ancestors could find
+                // Neither the current class loader nor any of its ancestors could find
                 // the LogFactory class, so we can stop now.
                 loader = null;
             } catch (final NoSuchMethodException ex) {


(commons-logging) 04/11: Document empty blocks

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 2ea4f44d2fb4e229f007be9feaaee999cb903473
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 09:45:03 2023 -0500

    Document empty blocks
---
 src/main/java/org/apache/commons/logging/impl/NoOpLog.java | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/main/java/org/apache/commons/logging/impl/NoOpLog.java b/src/main/java/org/apache/commons/logging/impl/NoOpLog.java
index d1a3c5c..26230fd 100644
--- a/src/main/java/org/apache/commons/logging/impl/NoOpLog.java
+++ b/src/main/java/org/apache/commons/logging/impl/NoOpLog.java
@@ -31,6 +31,7 @@ public class NoOpLog implements Log, Serializable {
 
     /** Convenience constructor */
     public NoOpLog() {
+        // no-op
     }
 
     /**
@@ -39,46 +40,55 @@ public class NoOpLog implements Log, Serializable {
      * @param name unused.
      */
     public NoOpLog(final String name) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void debug(final Object message) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void debug(final Object message, final Throwable t) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void error(final Object message) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void error(final Object message, final Throwable t) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void fatal(final Object message) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void fatal(final Object message, final Throwable t) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void info(final Object message) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void info(final Object message, final Throwable t) {
+        // no-op
     }
 
     /**
@@ -144,20 +154,24 @@ public class NoOpLog implements Log, Serializable {
     /** Do nothing */
     @Override
     public void trace(final Object message) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void trace(final Object message, final Throwable t) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void warn(final Object message) {
+        // no-op
     }
 
     /** Do nothing */
     @Override
     public void warn(final Object message, final Throwable t) {
+        // no-op
     }
 }


(commons-logging) 07/11: Remove extra whitespace

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 68a33abb85a48e9cb1b40b9942c4ac7664093e8c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 09:46:41 2023 -0500

    Remove extra whitespace
---
 src/main/java/org/apache/commons/logging/LogSource.java | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/logging/LogSource.java b/src/main/java/org/apache/commons/logging/LogSource.java
index 60d14b1..7711031 100644
--- a/src/main/java/org/apache/commons/logging/LogSource.java
+++ b/src/main/java/org/apache/commons/logging/LogSource.java
@@ -53,7 +53,6 @@ import org.apache.commons.logging.impl.NoOpLog;
 @Deprecated
 public class LogSource {
 
-    
     /**
      * Logs.
      */
@@ -72,7 +71,6 @@ public class LogSource {
      * An empty immutable {@code String} array.
      */
     private static final String[] EMPTY_STRING_ARRAY = {};
-
     
     static {
 
@@ -129,7 +127,6 @@ public class LogSource {
         }
 
     }
-
     
     /**
      * Gets a {@code Log} instance by class.
@@ -140,7 +137,6 @@ public class LogSource {
     static public Log getInstance(final Class<?> clazz) {
         return getInstance(clazz.getName());
     }
-
     
     /**
      * Gets a {@code Log} instance by class name.


(commons-logging) 11/11: Spelling in 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 6b11d8ab2e5ffff36b789ed027c544fdde71b636
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 09:58:59 2023 -0500

    Spelling in comments
---
 src/main/java/org/apache/commons/logging/LogFactory.java | 16 ++++++++--------
 .../org/apache/commons/logging/impl/LogFactoryImpl.java  | 14 +++++++-------
 .../commons/logging/impl/ServletContextCleaner.java      |  6 +++---
 .../org/apache/commons/logging/impl/WeakHashtable.java   |  6 +++---
 .../org/apache/commons/logging/PathableClassLoader.java  |  8 ++++----
 .../org/apache/commons/logging/PathableTestSuite.java    |  4 ++--
 .../commons/logging/pathable/ChildFirstTestCase.java     | 10 +++++-----
 .../commons/logging/pathable/ParentFirstTestCase.java    | 10 +++++-----
 8 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java
index 2043185..61d294c 100644
--- a/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -121,7 +121,7 @@ public abstract class LogFactory {
      * The name ({@code org.apache.commons.logging.diagnostics.dest})
      * of the property used to enable internal commons-logging
      * diagnostic output, in order to get information on what logging
-     * implementations are being discovered, what classloaders they
+     * implementations are being discovered, what class loaders they
      * are loaded through, etc.
      * <p>
      * If a system property of this name is set then the value is
@@ -153,7 +153,7 @@ public abstract class LogFactory {
      * Setting this system property
      * ({@code org.apache.commons.logging.LogFactory.HashtableImpl})
      * value allows the {@code Hashtable} used to store
-     * classloaders to be substituted by an alternative implementation.
+     * class loaders to be substituted by an alternative implementation.
      * <p>
      * <strong>Note:</strong> {@code LogFactory} will print:
      * <pre>
@@ -178,7 +178,7 @@ public abstract class LogFactory {
      * <p>
      * A typical use case is to allow a custom
      * Hashtable implementation using weak references to be substituted.
-     * This will allow classloaders to be garbage collected without
+     * This will allow class loaders to be garbage collected without
      * the need to release them (on 1.3+ JVMs only, of course ;).
      */
     public static final String HASHTABLE_IMPLEMENTATION_PROPERTY =
@@ -337,7 +337,7 @@ public abstract class LogFactory {
                         msg.append("'. ");
                         if (implementsLogFactory) {
                             msg.append("The conflict is caused by the presence of multiple LogFactory classes ");
-                            msg.append("in incompatible classloaders. ");
+                            msg.append("in incompatible class loaders. ");
                             msg.append("Background can be found in http://commons.apache.org/logging/tech.html. ");
                             msg.append("If you have not explicitly specified a custom LogFactory then it is likely ");
                             msg.append("that the container has set one without your knowledge. ");
@@ -537,7 +537,7 @@ public abstract class LogFactory {
      * <p>
      * Even when using an AccessController, however, this method can still
      * throw SecurityException. Commons Logging basically relies on the
-     * ability to access classloaders. A policy that forbids all
+     * ability to access class loaders. A policy that forbids all
      * classloader access will also prevent commons-logging from working:
      * currently this method will throw an exception preventing the entire app
      * from starting up. Maybe it would be good to detect this situation and
@@ -1131,7 +1131,7 @@ public abstract class LogFactory {
                 // LogFactory cannot be loaded by the classloader which loaded the custom factory implementation.
                 // The custom implementation is not viable until this is corrected.
                 // Ensure that the JCL jar and the custom class are available from the same classloader.
-                // Running with diagnostics on should give information about the classloaders used
+                // Running with diagnostics on should give information about the class loaders used
                 // to load the custom factory.
                 //
                 logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by the class loader which loaded "
@@ -1478,7 +1478,7 @@ public abstract class LogFactory {
      */
     public static void releaseAll() {
         if (isDiagnosticsEnabled()) {
-            logDiagnostic("Releasing factory for all classloaders.");
+            logDiagnostic("Releasing factory for all class loaders.");
         }
         // factories is not final and could be replaced in this block.
         final Hashtable<ClassLoader, LogFactory> factories = LogFactory.factories;
@@ -1601,7 +1601,7 @@ public abstract class LogFactory {
         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
+        // being used via different class loaders within the same app, we
         // ensure each logged message has a prefix of form
         // [LogFactory from classloader OID]
         //
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 da9482e..7bdf7e2 100644
--- a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
+++ b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
@@ -102,7 +102,7 @@ public class LogFactoryImpl extends LogFactory {
      * LogFactoryImpl is loaded via a child classloader of the TCCL (this
      * should never happen in sane systems).
      *
-     * Default behavior: true (tolerates bad context classloaders)
+     * Default behavior: true (tolerates bad context class loaders)
      *
      * See also method setAttribute.
      */
@@ -543,7 +543,7 @@ public class LogFactoryImpl extends LogFactory {
         //
         // Note that we deliberately loop here over classesToDiscover and
         // expect method createLogFromClass to loop over the possible source
-        // classloaders. The effect is:
+        // class loaders. The effect is:
         //   for each discoverable log adapter
         //      for each possible classloader
         //          see if it works
@@ -679,7 +679,7 @@ public class LogFactoryImpl extends LogFactory {
      * <p>
      * The only time when the classloader which loaded this class is a
      * descendant (rather than the same as or an ancestor of the context
-     * classloader) is when an app has created custom classloaders but
+     * classloader) is when an app has created custom class loaders but
      * failed to correctly set the context classloader. This is a bug in
      * the calling application; however we provide the option for JCL to
      * simply generate a warning rather than fail outright.
@@ -698,7 +698,7 @@ public class LogFactoryImpl extends LogFactory {
                 contextClassLoader, thisClassLoader);
 
         if (baseClassLoader == null) {
-           // The two classloaders are not part of a parent child relationship.
+           // The two class loaders are not part of a parent child relationship.
            // In some classloading setups (e.g. JBoss with its
            // UnifiedLoaderRepository) this can still work, so if user hasn't
            // forbidden it, just return the contextClassLoader.
@@ -722,7 +722,7 @@ public class LogFactoryImpl extends LogFactory {
             // We really should just use the contextClassLoader as the starting
             // point for scanning for log adapter classes. However it is expected
             // that there are a number of broken systems out there which create
-            // custom classloaders but fail to set the context classloader so
+            // custom class loaders but fail to set the context classloader so
             // we handle those flawed systems anyway.
             if (!allowFlawedContext) {
                 throw new LogConfigurationException(
@@ -895,7 +895,7 @@ public class LogFactoryImpl extends LogFactory {
     //  ------------------------------------------------------ Private Methods
 
     /**
-     * Given two related classloaders, return the one which is a child of
+     * Given two related class loaders, return the one which is a child of
      * the other.
      * <p>
      * @param c1 is a classloader (including the null classloader)
@@ -905,7 +905,7 @@ public class LogFactoryImpl extends LogFactory {
      * and null if neither is an ancestor of the other.
      */
     private ClassLoader getLowestClassLoader(final ClassLoader c1, final ClassLoader c2) {
-        // TODO: use AccessController when dealing with classloaders here
+        // TODO: use AccessController when dealing with class loaders here
 
         if (c1 == null) {
             return c2;
diff --git a/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java b/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java
index 7c1137d..b0fc41d 100644
--- a/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java
+++ b/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java
@@ -33,7 +33,7 @@ import org.apache.commons.logging.LogFactory;
  * In general, the WeakHashtable support added in commons-logging release 1.1
  * ensures that logging classes do not hold references that prevent an
  * undeployed webapp's memory from being garbage-collected even when multiple
- * copies of commons-logging are deployed via multiple classloaders (a
+ * copies of commons-logging are deployed via multiple class loaders (a
  * situation that earlier versions had problems with). However there are
  * some rare cases where the WeakHashtable approach does not work; in these
  * situations specifying this class as a listener for the web application will
@@ -62,7 +62,7 @@ public class ServletContextCleaner implements ServletContextListener {
         final Object[] params = new Object[1];
         params[0] = tccl;
 
-        // Walk up the tree of classloaders, finding all the available
+        // Walk up the tree of class loaders, finding all the available
         // LogFactory classes and releasing any objects associated with
         // the tccl (ie the webapp).
         //
@@ -87,7 +87,7 @@ public class ServletContextCleaner implements ServletContextListener {
         // to is expected to have been loaded via the TCCL, so the
         // underlying logging lib is only initialized/configured once.
         // These references from ancestor LogFactory classes down to
-        // TCCL classloaders are held via weak references and so should
+        // TCCL class loaders are held via weak references and so should
         // be released but there are circumstances where they may not.
         // Walking up the classloader ancestry ladder releasing
         // the current tccl at each level tree, though, will definitely
diff --git a/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java b/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java
index a2111b0..bb053ac 100644
--- a/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java
+++ b/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java
@@ -47,7 +47,7 @@ import java.util.Set;
  * <strong>Usage:</strong> typical use case is as a drop-in replacement
  * for the {@code Hashtable} used in {@code LogFactory} for J2EE environments
  * running 1.3+ JVMs. Use of this class <i>in most cases</i> (see below) will
- * allow classloaders to be collected by the garbage collector without the need
+ * allow class loaders to be collected by the garbage collector without the need
  * to call {@link org.apache.commons.logging.LogFactory#release(ClassLoader) LogFactory.release(ClassLoader)}.
  * <p>
  * {@code org.apache.commons.logging.LogFactory} checks whether this class
@@ -64,7 +64,7 @@ import java.util.Set;
  * <p>
  * The reason all this is necessary is due to a issue which
  * arises during hot deploy in a J2EE-like containers.
- * Each component running in the container owns one or more classloaders; when
+ * Each component running in the container owns one or more class loaders; when
  * the component loads a LogFactory instance via the component classloader
  * a reference to it gets stored in the static LogFactory.factories member,
  * keyed by the component's classloader so different components don't
@@ -73,7 +73,7 @@ import java.util.Set;
  * component's classes get garbage-collected. However there's still a
  * reference to the component's classloader from a key in the "global"
  * {@code LogFactory}'s factories member! If {@code LogFactory.release()}
- * is called whenever component is unloaded, the classloaders will be correctly
+ * is called whenever component is unloaded, the class loaders will be correctly
  * garbage collected; this <i>should</i> be done by any container that
  * bundles commons-logging by default. However, holding the classloader
  * references weakly ensures that the classloader will be garbage collected
diff --git a/src/test/java/org/apache/commons/logging/PathableClassLoader.java b/src/test/java/org/apache/commons/logging/PathableClassLoader.java
index 7dbdb78..03e04b0 100644
--- a/src/test/java/org/apache/commons/logging/PathableClassLoader.java
+++ b/src/test/java/org/apache/commons/logging/PathableClassLoader.java
@@ -348,7 +348,7 @@ public class PathableClassLoader extends URLClassLoader {
      * Checking with the parent first is the normal approach for java, but
      * components within containers such as servlet engines can use
      * child-first lookup instead, to allow the components to override libs
-     * which are visible in shared classloaders provided by the container.
+     * which are visible in shared class loaders provided by the container.
      * <p>
      * Note that the method getResources always behaves as if parentFirst=true,
      * because of limitations in java 1.4; see the javadoc for method
@@ -393,15 +393,15 @@ public class PathableClassLoader extends URLClassLoader {
      * <ul>
      * <li>If code calls getClassLoader on a class loaded via
      * "lookaside", then traces up its inheritance chain, it
-     * will see the "real" classloaders. When the class is remapped
+     * will see the "real" class loaders. When the class is remapped
      * into this classloader via addLogicalLib, the classloader
      * chain seen is this object plus ancestors.
      * <li>If two different jars contain classes in the same
      * package, then it is not possible to load both jars into
      * the same "lookaside" classloader (eg the system classloader)
      * then map one of those subsets from here. Of course they could
-     * be loaded into two different "lookaside" classloaders and
-     * then a prefix used to map from here to one of those classloaders.
+     * be loaded into two different "lookaside" class loaders and
+     * then a prefix used to map from here to one of those class loaders.
      * </ul>
      */
     public void useExplicitLoader(final String prefix, final ClassLoader loader) {
diff --git a/src/test/java/org/apache/commons/logging/PathableTestSuite.java b/src/test/java/org/apache/commons/logging/PathableTestSuite.java
index 1024513..fd414a6 100644
--- a/src/test/java/org/apache/commons/logging/PathableTestSuite.java
+++ b/src/test/java/org/apache/commons/logging/PathableTestSuite.java
@@ -58,7 +58,7 @@ import junit.framework.TestSuite;
  * <p>
  * This class will run each test methods within the specified TestCase using
  * the specified context classloader and system classloader. If different
- * tests within the same class require different context classloaders,
+ * tests within the same class require different context class loaders,
  * then the context classloader passed to the constructor should be the
  * "lowest" one available, and tests that need the context set to some parent
  * of this "lowest" classloader can call
@@ -81,7 +81,7 @@ import junit.framework.TestSuite;
  * is different from the class whose suite() method was executed to determine
  * the classpath. This means that the suite method cannot communicate with
  * the test cases simply by setting static variables (for example to make the
- * custom classloaders available to the test methods or setUp/tearDown fixtures).
+ * custom class loaders available to the test methods or setUp/tearDown fixtures).
  * If this is really necessary then it is possible to use reflection to invoke
  * static methods on the class object passed to the constructor of this class.
  * <p>
diff --git a/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java b/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java
index 37cd2a6..e5a367a 100644
--- a/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java
+++ b/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java
@@ -107,7 +107,7 @@ public class ChildFirstTestCase extends TestCase {
     }
 
     /**
-     * Utility method to return the set of all classloaders in the
+     * Utility method to return the set of all class loaders in the
      * parent chain starting from the one that loaded the class for
      * this object instance.
      */
@@ -123,7 +123,7 @@ public class ChildFirstTestCase extends TestCase {
 
     /**
      * Test that the classloader hierarchy is as expected, and that
-     * calling loadClass() on various classloaders works as expected.
+     * calling loadClass() on various class loaders works as expected.
      * Note that for this test case, parent-first classloading is
      * in effect.
      */
@@ -167,7 +167,7 @@ public class ChildFirstTestCase extends TestCase {
                         systemLoader.getClass().getName()));
 
         // junit classes should be visible; their classloader is not
-        // in the hierarchy of parent classloaders for this class,
+        // in the hierarchy of parent class loaders for this class,
         // though it is accessible due to trickery in the PathableClassLoader.
         final Class junitTest = contextLoader.loadClass("junit.framework.Test");
         final Set ancestorCLs = getAncestorCLs();
@@ -180,7 +180,7 @@ public class ChildFirstTestCase extends TestCase {
                 logClass.getClassLoader(), parentLoader);
 
         // jcl adapter classes should be visible via both parent and child. However
-        // as the classloaders are child-first we should see the child one.
+        // as the class loaders are child-first we should see the child one.
         final Class log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
         assertSame("Log4JLogger not loaded via child",
                 log4jClass.getClassLoader(), thisLoader);
@@ -226,7 +226,7 @@ public class ChildFirstTestCase extends TestCase {
         resource = childLoader.getResource("org/apache/commons/logging/PathableTestSuite.class");
         assertNotNull("Unable to locate PathableTestSuite.class resource", resource);
 
-        // getResource where it is accessible to both classloaders. The one visible
+        // getResource where it is accessible to both class loaders. The one visible
         // to the child should be returned. The URL returned will be of form
         //  jar:file:/x/y.jar!path/to/resource. The file name part should include the jarname
         // of form commons-logging-adapters-nnnn.jar, not commons-logging-nnnn.jar
diff --git a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
index 427d45c..836e361 100644
--- a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
+++ b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
@@ -105,7 +105,7 @@ public class ParentFirstTestCase extends TestCase {
     }
 
     /**
-     * Utility method to return the set of all classloaders in the
+     * Utility method to return the set of all class loaders in the
      * parent chain starting from the one that loaded the class for
      * this object instance.
      */
@@ -121,7 +121,7 @@ public class ParentFirstTestCase extends TestCase {
 
     /**
      * Test that the classloader hierarchy is as expected, and that
-     * calling loadClass() on various classloaders works as expected.
+     * calling loadClass() on various class loaders works as expected.
      * Note that for this test case, parent-first classloading is
      * in effect.
      */
@@ -164,7 +164,7 @@ public class ParentFirstTestCase extends TestCase {
                 systemLoader.getClass().getName());
 
         // junit classes should be visible; their classloader is not
-        // in the hierarchy of parent classloaders for this class,
+        // in the hierarchy of parent class loaders for this class,
         // though it is accessible due to trickery in the PathableClassLoader.
         final Class junitTest = contextLoader.loadClass("junit.framework.Test");
         final Set ancestorCLs = getAncestorCLs();
@@ -177,7 +177,7 @@ public class ParentFirstTestCase extends TestCase {
                 logClass.getClassLoader(), parentLoader);
 
         // jcl adapter classes should be visible via both parent and child. However
-        // as the classloaders are parent-first we should see the parent one.
+        // as the class loaders are parent-first we should see the parent one.
         final Class log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
         assertSame("Log4JLogger not loaded via parent",
                 log4jClass.getClassLoader(), parentLoader);
@@ -223,7 +223,7 @@ public class ParentFirstTestCase extends TestCase {
         resource = childLoader.getResource("org/apache/commons/logging/PathableTestSuite.class");
         assertNotNull("Unable to locate PathableTestSuite.class resource", resource);
 
-        // getResource where it is accessible to both classloaders. The one visible
+        // getResource where it is accessible to both class loaders. The one visible
         // to the parent should be returned. The URL returned will be of form
         //  jar:file:/x/y.jar!path/to/resource. The file name part should include the jarname
         // of form commons-logging-nnnn.jar, not commons-logging-adapters-nnnn.jar


(commons-logging) 03/11: Deprecate org.apache.commons.logging.impl.WeakHashtable without replacement.

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 c265c9d46ebd0f8949dd0075c6a01984ecd650dc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 09:43:37 2023 -0500

    Deprecate org.apache.commons.logging.impl.WeakHashtable without
    replacement.
---
 src/changes/changes.xml                                          | 4 ++++
 src/main/java/org/apache/commons/logging/impl/WeakHashtable.java | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c3071cb..f075f16 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,10 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="add" due-to="Piotr P. Karwasz">
         Add support for Log4j API and SLF4J #177.
       </action>
+      <!-- REMOVE -->
+      <action dev="ggregory" type="add" due-to="Piotr P. Karwasz">
+        Deprecate org.apache.commons.logging.impl.WeakHashtable without replacement.
+      </action>
       <!-- FIX -->
       <action issue="LOGGING-165" dev="britter" type="add">
         Add Automatic-Module-Name Manifest Header for Java 9 compatibility.
diff --git a/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java b/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java
index e332954..a2111b0 100644
--- a/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java
+++ b/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java
@@ -106,7 +106,9 @@ import java.util.Set;
  * for most or all users.
  *
  * @since 1.1
+ * @deprecated No longer used.
  */
+@Deprecated
 public final class WeakHashtable extends Hashtable {
 
     /** Entry implementation */


(commons-logging) 05/11: Document empty blocks

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 6e6b27c9577e3dc5892f2164a7b2269cf251f26f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 09:45:25 2023 -0500

    Document empty blocks
---
 src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java b/src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java
index 5400219..b951d87 100644
--- a/src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java
+++ b/src/main/java/org/apache/commons/logging/impl/Log4jApiLogFactory.java
@@ -212,6 +212,7 @@ public final class Log4jApiLogFactory extends LogFactory {
         try {
             adapter.close();
         } catch (final IOException ignored) {
+            // Ignore
         }
     }
 


(commons-logging) 01/11: Better error messages

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 7e340b5d7383cf0c79889a6692f569cb8e07400f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 08:56:47 2023 -0500

    Better error messages
---
 .../org/apache/commons/logging/LogFactory.java     | 26 ++++++++++------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java
index 14bf582..98154f2 100644
--- a/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -441,11 +441,11 @@ public abstract class LogFactory {
                 // if the user's trying to set up a custom implementation, give a clue
                 if (isDiagnosticsEnabled()) {
                     // use internal logging to issue the warning
-                    logDiagnostic("[ERROR] LogFactory: Load of custom hashtable failed");
+                    logDiagnostic("[ERROR] LogFactory: Load of custom Hashtable failed");
                 } else {
                     // we *really* want this output, even if diagnostics weren't
                     // explicitly enabled by the user.
-                    System.err.println("[ERROR] LogFactory: Load of custom hashtable failed");
+                    System.err.println("[ERROR] LogFactory: Load of custom Hashtable failed");
                 }
             }
         }
@@ -1100,15 +1100,13 @@ public abstract class LogFactory {
                     logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader");
                 } else {
                     logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader);
-                    final Class factoryFromCustomLoader
-                        = Class.forName("org.apache.commons.logging.LogFactory", false, logFactoryClassLoader);
+                    final Class factoryFromCustomLoader = Class.forName("org.apache.commons.logging.LogFactory", false, logFactoryClassLoader);
                     implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass);
                     if (implementsLogFactory) {
-                        logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() +
-                                      " implements LogFactory but was loaded by an incompatible classloader.");
+                        logDiagnostic(
+                                "[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " implements LogFactory but was loaded by an incompatible classloader.");
                     } else {
-                        logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() +
-                                      " does not implement LogFactory.");
+                        logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " does not implement LogFactory.");
                     }
                 }
             } catch (final SecurityException e) {
@@ -1117,8 +1115,8 @@ public abstract class LogFactory {
                 // This will make it very hard to diagnose issues with JCL.
                 // Consider running less securely whilst debugging this issue.
                 //
-                logDiagnostic("[CUSTOM LOG FACTORY] SecurityException thrown whilst trying to determine whether " +
-                              "the compatibility was caused by a classloader conflict: " + e.getMessage());
+                logDiagnostic("[CUSTOM LOG FACTORY] SecurityException caught trying to determine whether "
+                        + "the compatibility was caused by a class loader conflict: " + e.getMessage());
             } catch (final LinkageError e) {
                 //
                 // This should be an unusual circumstance.
@@ -1126,8 +1124,8 @@ public abstract class LogFactory {
                 // Another possibility may be an exception thrown by an initializer.
                 // Time for a clean rebuild?
                 //
-                logDiagnostic("[CUSTOM LOG FACTORY] LinkageError thrown whilst trying to determine whether " +
-                              "the compatibility was caused by a classloader conflict: " + e.getMessage());
+                logDiagnostic("[CUSTOM LOG FACTORY] LinkageError caught trying to determine whether "
+                        + "the compatibility was caused by a class loader conflict: " + e.getMessage());
             } catch (final ClassNotFoundException e) {
                 //
                 // LogFactory cannot be loaded by the classloader which loaded the custom factory implementation.
@@ -1136,8 +1134,8 @@ public abstract class LogFactory {
                 // Running with diagnostics on should give information about the classloaders used
                 // to load the custom factory.
                 //
-                logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by classloader which loaded " +
-                              "the custom LogFactory implementation. Is the custom factory in the right classloader?");
+                logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by the class loader which loaded "
+                        + "the custom LogFactory implementation. Is the custom factory in the right class loader?");
             }
         }
         return implementsLogFactory;


(commons-logging) 09/11: Better local 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 5360b9cf848de651b148e35aa08dc8a39f4da451
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 09:49:42 2023 -0500

    Better local name
---
 .../java/org/apache/commons/logging/impl/LogFactoryImpl.java | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

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 1d2fc56..da9482e 100644
--- a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
+++ b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
@@ -367,9 +367,9 @@ public class LogFactoryImpl extends LogFactory {
                     }
                 }
 
-                Class c;
+                Class clazz;
                 try {
-                    c = Class.forName(logAdapterClassName, true, currentCL);
+                    clazz = Class.forName(logAdapterClassName, true, currentCL);
                 } catch (final ClassNotFoundException originalClassNotFoundException) {
                     // The current classloader was unable to find the log adapter
                     // in this or any ancestor classloader. There's no point in
@@ -385,7 +385,7 @@ public class LogFactoryImpl extends LogFactory {
                         // classloading strategy is not consistent with the
                         // Java 1.2 classloading guidelines but JCL can
                         // and so should handle this case.
-                        c = Class.forName(logAdapterClassName);
+                        clazz = Class.forName(logAdapterClassName);
                     } catch (final ClassNotFoundException secondaryClassNotFoundException) {
                         // no point continuing: this adapter isn't available
                         msg = secondaryClassNotFoundException.getMessage();
@@ -395,7 +395,7 @@ public class LogFactoryImpl extends LogFactory {
                     }
                 }
 
-                constructor = c.getConstructor(logConstructorSignature);
+                constructor = clazz.getConstructor(logConstructorSignature);
                 final Object o = constructor.newInstance(params);
 
                 // Note that we do this test after trying to create an instance
@@ -403,7 +403,7 @@ public class LogFactoryImpl extends LogFactory {
                 // we don't complain about Log hierarchy problems when the
                 // adapter couldn't be instantiated anyway.
                 if (o instanceof Log) {
-                    logAdapterClass = c;
+                    logAdapterClass = clazz;
                     logAdapter = (Log) o;
                     break;
                 }
@@ -418,7 +418,7 @@ public class LogFactoryImpl extends LogFactory {
                 // The handleFlawedHierarchy method will throw
                 // LogConfigurationException if it regards this problem as
                 // fatal, and just return if not.
-                handleFlawedHierarchy(currentCL, c);
+                handleFlawedHierarchy(currentCL, clazz);
             } catch (final NoClassDefFoundError e) {
                 // We were able to load the adapter but it had references to
                 // other classes that could not be found. This simply means that


(commons-logging) 02/11: Refactor to local variable

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 0467d4151a443b4aa6d8d073e2838d5c52b83723
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 20 08:58:24 2023 -0500

    Refactor to local variable
---
 src/main/java/org/apache/commons/logging/LogFactory.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java
index 98154f2..2043185 100644
--- a/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -1102,11 +1102,11 @@ public abstract class LogFactory {
                     logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader);
                     final Class factoryFromCustomLoader = Class.forName("org.apache.commons.logging.LogFactory", false, logFactoryClassLoader);
                     implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass);
+                    final String logFactoryClassName = logFactoryClass.getName();
                     if (implementsLogFactory) {
-                        logDiagnostic(
-                                "[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " implements LogFactory but was loaded by an incompatible classloader.");
+                        logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClassName + " implements LogFactory but was loaded by an incompatible classloader.");
                     } else {
-                        logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + " does not implement LogFactory.");
+                        logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClassName + " does not implement LogFactory.");
                     }
                 }
             } catch (final SecurityException e) {