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
The following commit(s) were added to refs/heads/master by this push: new a28caba Spelling a28caba is described below commit a28caba95bce286b03dcdd463efc864c6b68dc6e Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Nov 25 12:33:33 2023 -0500 Spelling --- .../org/apache/commons/logging/LogFactory.java | 138 ++++++++++----------- .../commons/logging/impl/LogFactoryImpl.java | 112 ++++++++--------- .../logging/impl/ServletContextCleaner.java | 10 +- .../apache/commons/logging/impl/WeakHashtable.java | 26 ++-- .../commons/logging/AltHashtableTestCase.java | 6 +- .../org/apache/commons/logging/LoadTestCase.java | 38 +++--- .../commons/logging/NullClassLoaderTestCase.java | 4 +- .../commons/logging/PathableClassLoader.java | 50 ++++---- .../apache/commons/logging/PathableTestSuite.java | 24 ++-- .../java/org/apache/commons/logging/UserClass.java | 4 +- .../config/FirstPriorityConfigTestCase.java | 6 +- .../logging/config/PriorityConfigTestCase.java | 2 +- .../logging/jdk14/CustomConfigAPITestCase.java | 2 +- .../logging/jdk14/CustomConfigFullTestCase.java | 2 +- .../logging/jdk14/CustomConfigTestCase.java | 12 +- .../log4j12/AppClasspathStandardTestCase.java | 2 +- .../logging/pathable/ChildFirstTestCase.java | 60 ++++----- .../commons/logging/pathable/GeneralTestCase.java | 8 +- .../logging/pathable/ParentFirstTestCase.java | 60 ++++----- .../logging/security/SecurityAllowedTestCase.java | 4 +- .../security/SecurityForbiddenTestCase.java | 12 +- .../serviceloader/internal/ThrowingLogFactory.java | 2 +- .../logging/servlet/BasicServletTestCase.java | 2 +- .../logging/tccl/log/TcclDisabledTestCase.java | 14 +-- .../logging/tccl/log/TcclEnabledTestCase.java | 12 +- .../tccl/logfactory/TcclDisabledTestCase.java | 14 +-- .../tccl/logfactory/TcclEnabledTestCase.java | 14 +-- 27 files changed, 320 insertions(+), 320 deletions(-) diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java index 7b447d8..f3d5588 100644 --- a/src/main/java/org/apache/commons/logging/LogFactory.java +++ b/src/main/java/org/apache/commons/logging/LogFactory.java @@ -190,7 +190,7 @@ public abstract class LogFactory { "org.apache.commons.logging.impl.WeakHashtable"; /** - * A reference to the classloader that loaded this class. This is the + * A reference to the class loader that loaded this class. This is the * same as LogFactory.class.getClassLoader(). However computing this * value isn't quite as simple as that, as we potentially need to use * AccessControllers etc. It's more efficient to compute it once and @@ -219,9 +219,9 @@ public abstract class LogFactory { * This can happen when: * <ul> * <li>using JDK1.1 and the calling code is loaded via the system - * classloader (very common)</li> + * class loader (very common)</li> * <li>using JDK1.2+ and the calling code is loaded via the boot - * classloader (only likely for embedded systems work).</li> + * class loader (only likely for embedded systems work).</li> * </ul> * Note that {@code factories} is a <i>Hashtable</i> (not a HashMap), * and hashtables don't allow null as a key. @@ -238,7 +238,7 @@ public abstract class LogFactory { // In order to avoid confusion where multiple instances of JCL are // being used via different class loaders within the same app, we // ensure each logged message has a prefix of form - // [LogFactory from classloader OID] + // [LogFactory from class loader OID] // // Note that this prefix should be kept consistent with that // in LogFactoryImpl. However here we don't need to output info @@ -268,7 +268,7 @@ public abstract class LogFactory { * can return the previously created object (together with all its * cached Log objects). * - * @param classLoader should be the current context classloader. Note that + * @param classLoader should be the current context class loader. Note that * this can be null under some circumstances; this is ok. * @param factory should be the factory to cache. This should never be null. */ @@ -308,7 +308,7 @@ public abstract class LogFactory { logFactoryClass = classLoader.loadClass(factoryClassName); if (LogFactory.class.isAssignableFrom(logFactoryClass)) { if (isDiagnosticsEnabled()) { - logDiagnostic("Loaded class " + logFactoryClass.getName() + " from classloader " + objectId(classLoader)); + logDiagnostic("Loaded class " + logFactoryClass.getName() + " from class loader " + objectId(classLoader)); } } else // // This indicates a problem with the ClassLoader tree. @@ -322,8 +322,8 @@ public abstract class LogFactory { // ClassLoader hierarchy. // if (isDiagnosticsEnabled()) { - logDiagnostic("Factory class " + logFactoryClass.getName() + " loaded from classloader " + objectId(logFactoryClass.getClassLoader()) - + " does not extend '" + LogFactory.class.getName() + "' as loaded by this classloader."); + logDiagnostic("Factory class " + logFactoryClass.getName() + " loaded from class loader " + objectId(logFactoryClass.getClassLoader()) + + " does not extend '" + LogFactory.class.getName() + "' as loaded by this class loader."); logHierarchy("[BAD CL TREE] ", classLoader); } @@ -333,7 +333,7 @@ public abstract class LogFactory { if (classLoader == thisClassLoaderRef.get()) { // Nothing more to try, onwards. if (isDiagnosticsEnabled()) { - logDiagnostic("Unable to locate any class called '" + factoryClassName + "' via classloader " + objectId(classLoader)); + logDiagnostic("Unable to locate any class called '" + factoryClassName + "' via class loader " + objectId(classLoader)); } throw ex; } @@ -342,7 +342,7 @@ public abstract class LogFactory { if (classLoader == thisClassLoaderRef.get()) { // Nothing more to try, onwards. if (isDiagnosticsEnabled()) { - logDiagnostic("Class '" + factoryClassName + "' cannot be loaded" + " via classloader " + objectId(classLoader) + logDiagnostic("Class '" + factoryClassName + "' cannot be loaded" + " via class loader " + objectId(classLoader) + " - it depends on some other class that cannot be found."); } throw e; @@ -389,12 +389,12 @@ public abstract class LogFactory { throw new ClassCastException(msg.toString()); } - // Ignore exception, continue. Presumably the classloader was the + // Ignore exception, continue. Presumably the class loader was the // TCCL; the code below will try to load the class via thisClassLoaderRef. // This will handle the case where the original calling class is in // a shared classpath but the TCCL has a copy of LogFactory and the // specified LogFactory implementation; we will fall back to using the - // LogFactory implementation from the same classloader as this class. + // LogFactory implementation from the same class loader as this class. // // Issue: this doesn't handle the reverse case, where this LogFactory // is in the webapp, and the specified LogFactory implementation is @@ -407,17 +407,17 @@ public abstract class LogFactory { /* * At this point, either classLoader == null, OR classLoader was unable to load factoryClass. * - * In either case, we call Class.forName, which is equivalent to LogFactory.class.getClassLoader().load(name), that is, we ignore the classloader - * parameter the caller passed, and fall back to trying the classloader associated with this class. See the Javadoc for the newFactory method for + * In either case, we call Class.forName, which is equivalent to LogFactory.class.getClassLoader().load(name), that is, we ignore the class loader + * parameter the caller passed, and fall back to trying the class loader associated with this class. See the Javadoc for the newFactory method for * more info on the consequences of this. * - * Notes: * LogFactory.class.getClassLoader() may return 'null' if LogFactory is loaded by the bootstrap classloader. + * Notes: * LogFactory.class.getClassLoader() may return 'null' if LogFactory is loaded by the bootstrap class loader. */ // Warning: must typecast here & allow exception // to be generated/caught & recast properly. if (isDiagnosticsEnabled()) { logDiagnostic( - "Unable to load factory class via classloader " + objectId(classLoader) + " - trying the classloader associated with this LogFactory."); + "Unable to load factory class via class loader " + objectId(classLoader) + " - trying the class loader associated with this LogFactory."); } logFactoryClass = Class.forName(factoryClassName); return logFactoryClass.newInstance(); @@ -436,7 +436,7 @@ public abstract class LogFactory { /** * Create the hashtable which will be used to store a map of - * (context-classloader -> logfactory-object). Version 1.2+ of Java + * (context class loader -> logfactory-object). Version 1.2+ of Java * supports "weak references", allowing a custom Hashtable class * to be used which uses only weak references to its keys. Using weak * references can fix memory leaks on webapp unload in some cases (though @@ -504,8 +504,8 @@ public abstract class LogFactory { * * @throws LogConfigurationException if a suitable class loader * cannot be identified. - * @return the thread's context classloader or {@code null} if the java security - * policy forbids access to the context classloader from one of the classes + * @return the thread's context class loader or {@code null} if the java security + * policy forbids access to the context class loader from one of the classes * in the current call stack. * @since 1.1 */ @@ -535,16 +535,16 @@ public abstract class LogFactory { /** * Check cached factories (keyed by contextClassLoader) * - * @param contextClassLoader is the context classloader associated + * @param contextClassLoader is the context class loader associated * with the current thread. This allows separate LogFactory objects * per component within a container, provided each component has - * a distinct context classloader set. This parameter may be null + * a distinct context class loader set. This parameter may be null * in JDK1.1, and in embedded systems where jcl-using code is * placed in the bootclasspath. * - * @return the factory associated with the specified classloader if + * @return the factory associated with the specified class loader if * one has previously been created, or null if this is the first time - * we have seen this particular classloader. + * we have seen this particular class loader. */ private static LogFactory getCachedFactory(final ClassLoader contextClassLoader) { if (contextClassLoader == null) { @@ -558,7 +558,7 @@ public abstract class LogFactory { } /** - * Safely get access to the classloader for the specified class. + * Safely get access to the class loader for the specified class. * <p> * Theoretically, calling getClassLoader can throw a security exception, * and so should be done under an AccessController in order to provide @@ -572,16 +572,16 @@ public abstract class LogFactory { * Even when using an AccessController, however, this method can still * throw SecurityException. Commons Logging basically relies on the * ability to access class loaders. A policy that forbids all - * classloader access will also prevent commons-logging from working: + * class loader 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 * just disable all commons-logging? Not high priority though - as stated - * above, security policies that prevent classloader access aren't common. + * above, security policies that prevent class loader access aren't common. * </p> * <p> * Note that returning an object fetched via an AccessController would * technically be a security flaw anyway; untrusted code that has access - * to a trusted JCL library could use it to fetch the classloader for + * to a trusted JCL library could use it to fetch the class loader for * a class even when forbidden to do so directly. * </p> * @@ -595,7 +595,7 @@ public abstract class LogFactory { return clazz.getClassLoader(); } catch (final SecurityException ex) { if (isDiagnosticsEnabled()) { - logDiagnostic("Unable to get classloader for class '" + clazz + "' due to security restrictions - " + ex.getMessage()); + logDiagnostic("Unable to get class loader for class '" + clazz + "' due to security restrictions - " + ex.getMessage()); } throw ex; } @@ -604,7 +604,7 @@ public abstract class LogFactory { /** * Locate a user-provided configuration file. * <p> - * The classpath of the specified classLoader (usually the context classloader) + * The classpath of the specified classLoader (usually the context class loader) * is searched for properties files of the specified name. If none is found, * null is returned. If more than one is found, then the file with the greatest * value for its PRIORITY property is returned. If multiple files have the @@ -691,21 +691,21 @@ public abstract class LogFactory { /** - * Returns the current context classloader. + * Returns the current context class loader. * <p> * In versions prior to 1.1, this method did not use an AccessController. * In version 1.1, an AccessController wrapper was incorrectly added to * this method, causing a minor security flaw. * <p> * In version 1.1.1 this change was reverted; this method no longer uses - * an AccessController. User code wishing to obtain the context classloader + * an AccessController. User code wishing to obtain the context class loader * must invoke this method via AccessController.doPrivileged if it needs * support for that. * - * @return the context classloader associated with the current thread, + * @return the context class loader associated with the current thread, * or null if security doesn't allow it. * @throws LogConfigurationException if there was some weird error while - * attempting to get the context classloader. + * attempting to get the context class loader. */ protected static ClassLoader getContextClassLoader() throws LogConfigurationException { return directGetContextClassLoader(); @@ -720,10 +720,10 @@ public abstract class LogFactory { * the entire call stack must have the privilege before the call is * allowed. * - * @return the context classloader associated with the current thread, + * @return the context class loader associated with the current thread, * or null if security doesn't allow it. * @throws LogConfigurationException if there was some weird error while - * attempting to get the context classloader. + * attempting to get the context class loader. */ private static ClassLoader getContextClassLoaderInternal() throws LogConfigurationException { return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) LogFactory::directGetContextClassLoader); @@ -745,7 +745,7 @@ public abstract class LogFactory { * this file will be set as configuration attributes on the corresponding {@code LogFactory} instance. * </p> * <p> - * <em>NOTE</em> - In a multi-threaded environment it is possible that two different instances will be returned for the same classloader environment. + * <em>NOTE</em> - In a multi-threaded environment it is possible that two different instances will be returned for the same class loader environment. * </p> * * @return a {@code LogFactory}. @@ -760,7 +760,7 @@ public abstract class LogFactory { // output will be a nuisance on JDK1.1, as the system // class loader is null in that environment. if (contextClassLoader == null && isDiagnosticsEnabled()) { - logDiagnostic("Context classloader is null."); + logDiagnostic("Context class loader is null."); } // Return any previously registered factory for this class loader @@ -771,7 +771,7 @@ public abstract class LogFactory { if (isDiagnosticsEnabled()) { logDiagnostic( - "[LOOKUP] LogFactory implementation requested for the first time for context classloader " + + "[LOOKUP] LogFactory implementation requested for the first time for context class loader " + objectId(contextClassLoader)); logHierarchy("[LOOKUP] ", contextClassLoader); } @@ -947,13 +947,13 @@ public abstract class LogFactory { if (isDiagnosticsEnabled()) { logDiagnostic( "[LOOKUP] Loading the default LogFactory implementation '" + FACTORY_DEFAULT + - "' via the same classloader that loaded this LogFactory" + - " class (ie not looking in the context classloader)."); + "' via the same class loader that loaded this LogFactory" + + " class (ie not looking in the context class loader)."); } // Note: unlike the above code which can try to load custom LogFactory // implementations via the TCCL, we don't try to load the default LogFactory - // implementation via the context classloader because: + // implementation via the context class loader because: // * that can cause problems (see comments in newFactory method) // * no-one should be customising the code of the default class // Yes, we do give up the ability for the child to ship a newer @@ -1117,13 +1117,13 @@ public abstract class LogFactory { * Determines whether the given class actually implements {@code LogFactory}. * Diagnostic information is also logged. * <p> - * <strong>Usage:</strong> to diagnose whether a classloader conflict is the cause + * <strong>Usage:</strong> to diagnose whether a class loader conflict is the cause * of incompatibility. The test used is whether the class is assignable from - * the {@code LogFactory} class loaded by the class's classloader. + * the {@code LogFactory} class loaded by the class's class loader. * @param logFactoryClass {@code Class} which may implement {@code LogFactory} * @return true if the {@code logFactoryClass} does extend * {@code LogFactory} when that class is loaded via the same - * classloader that loaded the {@code logFactoryClass}. + * class loader that loaded the {@code logFactoryClass}. */ private static boolean implementsLogFactory(final Class<?> logFactoryClass) { boolean implementsLogFactory = false; @@ -1131,14 +1131,14 @@ public abstract class LogFactory { try { final ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader(); if (logFactoryClassLoader == null) { - logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader"); + logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot class loader"); } else { 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] " + logFactoryClassName + " implements LogFactory but was loaded by an incompatible classloader."); + logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClassName + " implements LogFactory but was loaded by an incompatible class loader."); } else { logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClassName + " does not implement LogFactory."); } @@ -1162,9 +1162,9 @@ public abstract class LogFactory { + "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. + // LogFactory cannot be loaded by the class loader 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. + // Ensure that the JCL jar and the custom class are available from the same class loader. // Running with diagnostics on should give information about the class loaders used // to load the custom factory. // @@ -1236,20 +1236,20 @@ public abstract class LogFactory { } /** - * Generate useful diagnostics regarding the classloader tree for + * Generate useful diagnostics regarding the class loader tree for * the specified class. * <p> * As an example, if the specified class was loaded via a webapp's - * classloader, then you may get the following output: + * class loader, then you may get the following output: * <pre> - * Class com.acme.Foo was loaded via classloader 11111 + * Class com.acme.Foo was loaded via class loader 11111 * ClassLoader tree: 11111 -> 22222 (SYSTEM) -> 33333 -> BOOT * </pre> * <p> * This method returns immediately if isDiagnosticsEnabled() * returns false. * - * @param clazz is the class whose classloader + tree are to be + * @param clazz is the class whose class loader + tree are to be * output. */ private static void logClassLoaderEnvironment(final Class<?> clazz) { @@ -1274,12 +1274,12 @@ public abstract class LogFactory { classLoader = getClassLoader(clazz); } catch (final SecurityException ex) { // not much useful diagnostics we can print here! - logDiagnostic("[ENV] Security forbids determining the classloader for " + className); + logDiagnostic("[ENV] Security forbids determining the class loader for " + className); return; } - logDiagnostic("[ENV] Class " + className + " was loaded via classloader " + objectId(classLoader)); - logHierarchy("[ENV] Ancestry of classloader which loaded " + className + " is ", classLoader); + logDiagnostic("[ENV] Class " + className + " was loaded via class loader " + objectId(classLoader)); + logHierarchy("[ENV] Ancestry of class loader which loaded " + className + " is ", classLoader); } /** @@ -1309,7 +1309,7 @@ public abstract class LogFactory { } /** - * Logs diagnostic messages about the given classloader + * Logs diagnostic messages about the given class loader * and it's hierarchy. The prefix is prepended to the message * and is intended to make it easier to understand the logs. * @param prefix @@ -1328,7 +1328,7 @@ public abstract class LogFactory { try { systemClassLoader = ClassLoader.getSystemClassLoader(); } catch (final SecurityException ex) { - logDiagnostic(prefix + "Security forbids determining the system classloader."); + logDiagnostic(prefix + "Security forbids determining the system class loader."); return; } if (classLoader != null) { @@ -1401,24 +1401,24 @@ public abstract class LogFactory { * <b>ClassLoader conflicts</b> * </p> * <p> - * Note that there can be problems if the specified ClassLoader is not the same as the classloader that loaded this class, that is, when loading a concrete - * LogFactory subclass via a context classloader. + * Note that there can be problems if the specified ClassLoader is not the same as the class loader that loaded this class, that is, when loading a concrete + * LogFactory subclass via a context class loader. * </p> * <p> - * The problem is the same one that can occur when loading a concrete Log subclass via a context classloader. + * The problem is the same one that can occur when loading a concrete Log subclass via a context class loader. * </p> * <p> - * The problem occurs when code running in the context classloader calls class X which was loaded via a parent classloader, and class X then calls + * The problem occurs when code running in the context class loader calls class X which was loaded via a parent class loader, and class X then calls * LogFactory.getFactory (either directly or via LogFactory.getLog). Because class X was loaded via the parent, it binds to LogFactory loaded via the - * parent. When the code in this method finds some LogFactoryYYYY class in the child (context) classloader, and there also happens to be a LogFactory class - * defined in the child classloader, then LogFactoryYYYY will be bound to LogFactory@childloader. It cannot be cast to LogFactory@parentloader, that is, - * this method cannot return the object as the desired type. Note that it doesn't matter if the LogFactory class in the child classloader is identical to - * the LogFactory class in the parent classloader, they are not compatible. + * parent. When the code in this method finds some LogFactoryYYYY class in the child (context) class loader, and there also happens to be a LogFactory class + * defined in the child class loader, then LogFactoryYYYY will be bound to LogFactory@childloader. It cannot be cast to LogFactory@parentloader, that is, + * this method cannot return the object as the desired type. Note that it doesn't matter if the LogFactory class in the child class loader is identical to + * the LogFactory class in the parent class loader, they are not compatible. * </p> * <p> * The solution taken here is to simply print out an error message when this occurs then throw an exception. The deployer of the application must ensure - * they remove all occurrences of the LogFactory class from the child classloader in order to resolve the issue. Note that they do not have to move the - * custom LogFactory subclass; that is ok as long as the only LogFactory class it can find to bind to is in the parent classloader. + * they remove all occurrences of the LogFactory class from the child class loader in order to resolve the issue. Note that they do not have to move the + * custom LogFactory subclass; that is ok as long as the only LogFactory class it can find to bind to is in the parent class loader. * </p> * * @param factoryClass Fully qualified name of the {@code LogFactory} implementation class @@ -1446,7 +1446,7 @@ public abstract class LogFactory { throw ex; } if (isDiagnosticsEnabled()) { - logDiagnostic("Created object " + objectId(result) + " to manage classloader " + + logDiagnostic("Created object " + objectId(result) + " to manage class loader " + objectId(contextClassLoader)); } return (LogFactory) result; @@ -1482,7 +1482,7 @@ public abstract class LogFactory { */ public static void release(final ClassLoader classLoader) { if (isDiagnosticsEnabled()) { - logDiagnostic("Releasing factory for classloader " + objectId(classLoader)); + logDiagnostic("Releasing factory for class loader " + objectId(classLoader)); } // factories is not final and could be replaced in this block. final Hashtable<ClassLoader, LogFactory> factories = LogFactory.factories; 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 488e9ac..3545d55 100644 --- a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java +++ b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java @@ -97,9 +97,9 @@ public class LogFactoryImpl extends LogFactory { /** * The name ({@code org.apache.commons.logging.Log.allowFlawedContext}) * of the system property which can be set true/false to - * determine system behavior when a bad context-classloader is encountered. + * determine system behavior when a bad context class loader is encountered. * When set to false, a LogConfigurationException is thrown if - * LogFactoryImpl is loaded via a child classloader of the TCCL (this + * LogFactoryImpl is loaded via a child class loader of the TCCL (this * should never happen in sane systems). * * Default behavior: true (tolerates bad context class loaders) @@ -186,14 +186,14 @@ public class LogFactoryImpl extends LogFactory { * the entire call stack must have the privilege before the call is * allowed. * - * @return the context classloader associated with the current thread, + * @return the context class loader associated with the current thread, * or null if security doesn't allow it. * * @throws LogConfigurationException if there was some weird error while - * attempting to get the context classloader. + * attempting to get the context class loader. * * @throws SecurityException if the current java security policy doesn't - * allow this class to access the context classloader. + * allow this class to access the context class loader. */ private static ClassLoader getContextClassLoaderInternal() throws LogConfigurationException { @@ -234,7 +234,7 @@ public class LogFactoryImpl extends LogFactory { /** * Determines whether logging classes should be loaded using the thread-context - * classloader, or via the classloader that loaded this LogFactoryImpl class. + * class loader, or via the class loader that loaded this LogFactoryImpl class. */ private boolean useTCCL = true; @@ -341,14 +341,14 @@ public class LogFactoryImpl extends LogFactory { ClassLoader currentCL = getBaseClassLoader(); for(;;) { - // Loop through the classloader hierarchy trying to find - // a viable classloader. - logDiagnostic("Trying to load '" + logAdapterClassName + "' from classloader " + objectId(currentCL)); + // Loop through the class loader hierarchy trying to find + // a viable class loader. + logDiagnostic("Trying to load '" + logAdapterClassName + "' from class loader " + objectId(currentCL)); try { if (isDiagnosticsEnabled()) { // Show the location of the first occurrence of the .class file // in the classpath. This is the location that ClassLoader.loadClass - // will load the class from -- unless the classloader is doing + // will load the class from -- unless the class loader is doing // something weird. URL url; final String resourceName = logAdapterClassName.replace('.', '/') + ".class"; @@ -369,14 +369,14 @@ public class LogFactoryImpl extends LogFactory { try { 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 + // The current class loader was unable to find the log adapter + // in this or any ancestor class loader. There's no point in // trying higher up in the hierarchy in this case.. String msg = originalClassNotFoundException.getMessage(); - logDiagnostic("The log adapter '" + logAdapterClassName + "' is not available via classloader " + + logDiagnostic("The log adapter '" + logAdapterClassName + "' is not available via class loader " + objectId(currentCL) + ": " + trim(msg)); try { - // Try the class classloader. + // Try the class class loader. // This may work in cases where the TCCL // does not contain the code executed or JCL. // This behavior indicates that the application @@ -388,7 +388,7 @@ public class LogFactoryImpl extends LogFactory { // no point continuing: this adapter isn't available msg = secondaryClassNotFoundException.getMessage(); logDiagnostic("The log adapter '" + logAdapterClassName + - "' is not available via the LogFactoryImpl class classloader: " + trim(msg)); + "' is not available via the LogFactoryImpl class class loader: " + trim(msg)); break; } } @@ -421,11 +421,11 @@ public class LogFactoryImpl extends LogFactory { // We were able to load the adapter but it had references to // other classes that could not be found. This simply means that // the underlying logger library is not present in this or any - // ancestor classloader. There's no point in trying higher up + // ancestor class loader. There's no point in trying higher up // in the hierarchy in this case.. final String msg = e.getMessage(); logDiagnostic("The log adapter '" + logAdapterClassName + - "' is missing dependencies when loaded via classloader " + objectId(currentCL) + + "' is missing dependencies when loaded via class loader " + objectId(currentCL) + ": " + trim(msg)); break; } catch (final ExceptionInInitializerError e) { @@ -437,7 +437,7 @@ public class LogFactoryImpl extends LogFactory { // library could not be found. final String msg = e.getMessage(); logDiagnostic("The log adapter '" + logAdapterClassName + - "' is unable to initialize itself when loaded via classloader " + objectId(currentCL) + + "' is unable to initialize itself when loaded via class loader " + objectId(currentCL) + ": " + trim(msg)); break; } catch (final LogConfigurationException e) { @@ -456,7 +456,7 @@ public class LogFactoryImpl extends LogFactory { break; } - // try the parent classloader + // try the parent class loader // currentCL = currentCL.getParent(); currentCL = getParentClassLoader(currentCL); } @@ -473,11 +473,11 @@ public class LogFactoryImpl extends LogFactory { } catch (final Throwable t) { handleThrowable(t); // may re-throw t this.logMethod = null; - logDiagnostic("[INFO] '" + logAdapterClassName + "' from classloader " + objectId(currentCL) + + logDiagnostic("[INFO] '" + logAdapterClassName + "' from class loader " + objectId(currentCL) + " does not declare optional method " + "setLogFactory(LogFactory)"); } - logDiagnostic("Log adapter '" + logAdapterClassName + "' from classloader " + + logDiagnostic("Log adapter '" + logAdapterClassName + "' from class loader " + objectId(logAdapterClass.getClassLoader()) + " has been selected for use."); } @@ -543,18 +543,18 @@ public class LogFactoryImpl extends LogFactory { // expect method createLogFromClass to loop over the possible source // class loaders. The effect is: // for each discoverable log adapter - // for each possible classloader + // for each possible class loader // see if it works // // It appears reasonable at first glance to do the opposite: - // for each possible classloader + // for each possible class loader // for each discoverable log adapter // see if it works // // The latter certainly has advantages for user-installable logging // libraries such as log4j; in a webapp for example this code should // first check whether the user has provided any of the possible - // logging libraries before looking in the parent classloader. + // logging libraries before looking in the parent class loader. // Unfortunately, however, Jdk14Logger will always work in jvm>=1.4, // and SimpleLog will always work in any JVM. So the loop would never // ever look for logging libraries in the parent classpath. Yet many @@ -666,19 +666,19 @@ public class LogFactoryImpl extends LogFactory { } /** - * Return the classloader from which we should try to load the logging + * Return the class loader from which we should try to load the logging * adapter classes. * <p> - * This method usually returns the context classloader. However if it - * is discovered that the classloader which loaded this class is a child - * of the context classloader <i>and</i> the allowFlawedContext option - * has been set then the classloader which loaded this class is returned + * This method usually returns the context class loader. However if it + * is discovered that the class loader which loaded this class is a child + * of the context class loader <i>and</i> the allowFlawedContext option + * has been set then the class loader which loaded this class is returned * instead. * <p> - * The only time when the classloader which loaded this class is a + * The only time when the class loader 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 class loaders but - * failed to correctly set the context classloader. This is a bug in + * class loader) is when an app has created custom class loaders but + * failed to correctly set the context class loader. This is a bug in * the calling application; however we provide the option for JCL to * simply generate a warning rather than fail outright. * @@ -701,13 +701,13 @@ public class LogFactoryImpl extends LogFactory { // UnifiedLoaderRepository) this can still work, so if user hasn't // forbidden it, just return the contextClassLoader. if (!allowFlawedContext) { - throw new LogConfigurationException("Bad classloader hierarchy; LogFactoryImpl was loaded via" + - " a classloader that is not related to the current context" + - " classloader."); + throw new LogConfigurationException("Bad class loader hierarchy; LogFactoryImpl was loaded via" + + " a class loader that is not related to the current context" + + " class loader."); } if (isDiagnosticsEnabled()) { - logDiagnostic("[WARNING] the context classloader is not part of a" + - " parent-child relationship with the classloader that" + + logDiagnostic("[WARNING] the context class loader is not part of a" + + " parent-child relationship with the class loader that" + " loaded LogFactoryImpl."); } // If contextClassLoader were null, getLowestClassLoader() would @@ -720,20 +720,20 @@ 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 class loaders but fail to set the context classloader so + // custom class loaders but fail to set the context class loader so // we handle those flawed systems anyway. if (!allowFlawedContext) { throw new LogConfigurationException( - "Bad classloader hierarchy; LogFactoryImpl was loaded via" + - " a classloader that is not related to the current context" + - " classloader."); + "Bad class loader hierarchy; LogFactoryImpl was loaded via" + + " a class loader that is not related to the current context" + + " class loader."); } if (isDiagnosticsEnabled()) { logDiagnostic( - "Warning: the context classloader is an ancestor of the" + - " classloader that loaded LogFactoryImpl; it should be" + + "Warning: the context class loader is an ancestor of the" + + " class loader that loaded LogFactoryImpl; it should be" + " the same or a descendant. The application using" + - " commons-logging should ensure the context classloader" + + " commons-logging should ensure the context class loader" + " is used correctly."); } } @@ -896,8 +896,8 @@ public class LogFactoryImpl extends LogFactory { * 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) - * @param c2 is a classloader (including the null classloader) + * @param c1 is a class loader (including the null class loader) + * @param c2 is a class loader (including the null class loader) * * @return c1 if it has c2 as an ancestor, c2 if it has c1 as an ancestor, * and null if neither is an ancestor of the other. @@ -939,7 +939,7 @@ public class LogFactoryImpl extends LogFactory { } /** - * Fetch the parent classloader of a specified classloader. + * Fetch the parent class loader of a specified class loader. * <p> * If a SecurityException occurs, null is returned. * <p> @@ -949,7 +949,7 @@ public class LogFactoryImpl extends LogFactory { try { return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> cl.getParent()); } catch (final SecurityException ex) { - logDiagnostic("[SECURITY] Unable to obtain parent classloader"); + logDiagnostic("[SECURITY] Unable to obtain parent class loader"); return null; } @@ -962,7 +962,7 @@ public class LogFactoryImpl extends LogFactory { * * @param logAdapterClassName is the class name of the Log implementation * that could not be instantiated. Cannot be {@code null}. - * @param discoveryFlaw is the Throwable created by the classloader + * @param discoveryFlaw is the Throwable created by the class loader * * @throws LogConfigurationException ALWAYS */ @@ -1015,13 +1015,13 @@ public class LogFactoryImpl extends LogFactory { * <li>the specific class just doesn't implement the Log interface * (user screwed up), or * <li> the specified class has bound to a Log class loaded by some other - * classloader; Log@classloaderX cannot be cast to Log@classloaderY. + * class loader; Log@ClassLoaderX cannot be cast to Log@ClassLoaderY. * </ol> * <p> * Here we try to figure out which case has occurred so we can give the * user some reasonable feedback. * - * @param badClassLoader is the classloader we loaded the problem class from, + * @param badClassLoader is the class loader we loaded the problem class from, * ie it is equivalent to badClass.getClassLoader(). * * @param badClass is a Class object with the desired name, but which @@ -1045,13 +1045,13 @@ public class LogFactoryImpl extends LogFactory { if (implementsLog) { // the class does implement an interface called Log, but - // it is in the wrong classloader + // it is in the wrong class loader if (isDiagnosticsEnabled()) { try { final ClassLoader logInterfaceClassLoader = getClassLoader(Log.class); - logDiagnostic("Class '" + badClass.getName() + "' was found in classloader " + + logDiagnostic("Class '" + badClass.getName() + "' was found in class loader " + objectId(badClassLoader) + ". It is bound to a Log interface which is not" + - " the one loaded from classloader " + objectId(logInterfaceClassLoader)); + " the one loaded from class loader " + objectId(logInterfaceClassLoader)); } catch (final Throwable t) { handleThrowable(t); // may re-throw t logDiagnostic("Error while trying to output diagnostics about" + " bad class '" + badClass + "'"); @@ -1144,7 +1144,7 @@ public class LogFactoryImpl extends LogFactory { /** * Calculate and cache a string that uniquely identifies this instance, - * including which classloader the object was loaded from. + * including which class loader the object was loaded from. * <p> * This string will later be prefixed to each "internal logging" message * emitted, so that users can clearly see any unexpected behavior. @@ -1155,7 +1155,7 @@ public class LogFactoryImpl extends LogFactory { * its own unique prefix for log messages. */ private void initDiagnostics() { - // It would be nice to include an identifier of the context classloader + // It would be nice to include an identifier of the context class loader // that this LogFactoryImpl object is responsible for. However that // isn't possible as that information isn't available. It is possible // to figure this out by looking at the logging from LogFactory to 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 b0fc41d..674130b 100644 --- a/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java +++ b/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java @@ -42,7 +42,7 @@ import org.apache.commons.logging.LogFactory; * To use this class, configure the webapp deployment descriptor to call * this class on webapp undeploy; the contextDestroyed method will tell * every accessible LogFactory class that the entry in its map for the - * current webapp's context classloader should be cleared. + * current webapp's context class loader should be cleared. * * @since 1.1 */ @@ -78,18 +78,18 @@ public class ServletContextCleaner implements ServletContextListener { // holding any data associated with the tccl being released. // // When there are multiple LogFactory classes in the classpath and - // child-first classloading is used in any classloader, then multiple + // child-first classloading is used in any class loader, then multiple // LogFactory instances may hold info about this TCCL; whenever the - // webapp makes a call into a class loaded via an ancestor classloader + // webapp makes a call into a class loaded via an ancestor class loader // and that class calls LogFactory the tccl gets registered in // the LogFactory instance that is visible from the ancestor - // classloader. However the concrete logging library it points + // class loader. However the concrete logging library it points // 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 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 + // Walking up the class loader ancestry ladder releasing // the current tccl at each level tree, though, will definitely // clear any problem references. ClassLoader loader = tccl; 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 067d6e2..8376333 100644 --- a/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java +++ b/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java @@ -65,18 +65,18 @@ import java.util.Set; * 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 class loaders; when - * the component loads a LogFactory instance via the component classloader + * the component loads a LogFactory instance via the component class loader * a reference to it gets stored in the static LogFactory.factories member, - * keyed by the component's classloader so different components don't + * keyed by the component's class loader so different components don't * stomp on each other. When the component is later unloaded, the container - * sets the component's classloader to null with the intent that all the + * sets the component's class loader to null with the intent that all the * component's classes get garbage-collected. However there's still a - * reference to the component's classloader from a key in the "global" + * reference to the component's class loader from a key in the "global" * {@code LogFactory}'s factories member! If {@code LogFactory.release()} * 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 + * bundles commons-logging by default. However, holding the class loader + * references weakly ensures that the class loader will be garbage collected * without the container performing this step. * <p> * <strong>Limitations:</strong> @@ -85,22 +85,22 @@ import java.util.Set; * are used for its keys, it is necessary to use strong references for its values. * <p> * If the abstract class {@code LogFactory} is - * loaded by the container classloader but a subclass of + * loaded by the container class loader but a subclass of * {@code LogFactory} [LogFactory1] is loaded by the component's - * classloader and an instance stored in the static map associated with the + * class loader and an instance stored in the static map associated with the * base LogFactory class, then there is a strong reference from the LogFactory * class to the LogFactory1 instance (as normal) and a strong reference from - * the LogFactory1 instance to the component classloader via + * the LogFactory1 instance to the component class loader via * {@code getClass().getClassLoader()}. This chain of references will prevent - * collection of the child classloader. + * collection of the child class loader. * <p> * Such a situation occurs when the commons-logging.jar is - * loaded by a parent classloader (e.g. a server level classloader in a + * loaded by a parent class loader (e.g. a server level class loader in a * servlet container) and a custom {@code LogFactory} implementation is - * loaded by a child classloader (e.g. a web app classloader). + * loaded by a child class loader (e.g. a web app class loader). * <p> * To avoid this scenario, ensure - * that any custom LogFactory subclass is loaded by the same classloader as + * that any custom LogFactory subclass is loaded by the same class loader as * the base {@code LogFactory}. Creating custom LogFactory subclasses is, * however, rare. The standard LogFactoryImpl class should be sufficient * for most or all users. diff --git a/src/test/java/org/apache/commons/logging/AltHashtableTestCase.java b/src/test/java/org/apache/commons/logging/AltHashtableTestCase.java index 21c40ab..965fc03 100644 --- a/src/test/java/org/apache/commons/logging/AltHashtableTestCase.java +++ b/src/test/java/org/apache/commons/logging/AltHashtableTestCase.java @@ -23,7 +23,7 @@ import junit.framework.TestCase; /** * Test the ability to force the LogFactory class to use some * arbitrary Hashtable implementation to store its mapping from - * context-classloader -> LogFactory object. + * context class loader -> LogFactory object. */ public class AltHashtableTestCase extends TestCase { @@ -61,7 +61,7 @@ public class AltHashtableTestCase extends TestCase { } /** - * Verify that when LogFactory sees a context-classloader for the + * Verify that when LogFactory sees a context class loader for the * first time that it creates a new entry in the LogFactory.factories * hashmap. In particular, this checks that this process works ok when * a system property has been used to specify an alternative Hashtable @@ -86,7 +86,7 @@ public class AltHashtableTestCase extends TestCase { // Here, the reference to the LogFactory class should cause the // class to be loaded and initialized. It will see the property // set and use the AltHashtable class. If other tests in this - // class have already been run within the same classloader then + // class have already been run within the same class loader then // LogFactory will already have been initialized, but that // doesn't change the effectiveness of this test. assertTrue(LogFactory.factories instanceof AltHashtable); diff --git a/src/test/java/org/apache/commons/logging/LoadTestCase.java b/src/test/java/org/apache/commons/logging/LoadTestCase.java index 3d2a40c..3f043ae 100644 --- a/src/test/java/org/apache/commons/logging/LoadTestCase.java +++ b/src/test/java/org/apache/commons/logging/LoadTestCase.java @@ -26,13 +26,13 @@ import junit.framework.TestCase; public class LoadTestCase extends TestCase { /** - * A custom classloader which "duplicates" logging classes available - * in the parent classloader into itself. + * A custom class loader which "duplicates" logging classes available + * in the parent class loader into itself. * <p> * When asked to load a class that is in one of the LOG_PCKG packages, * it loads the class itself (child-first). This class doesn't need * to be set up with a classpath, as it simply uses the same classpath - * as the classloader that loaded it. + * as the class loader that loaded it. */ static class AppClassLoader extends ClassLoader { @@ -79,7 +79,7 @@ public class LoadTestCase extends TestCase { @Override public Class loadClass(final String name) throws ClassNotFoundException { - // isolates all logging classes, application in the same classloader too. + // isolates all logging classes, application in the same class loader too. // filters exceptions to simplify handling in test for (final String element : LOG_PCKG) { if (name.startsWith(element) && name.indexOf("Exception") == -1) { @@ -103,8 +103,8 @@ public class LoadTestCase extends TestCase { } /** - * Load class UserClass via a temporary classloader which is a child of - * the classloader used to load this test class. + * Load class UserClass via a temporary class loader which is a child of + * the class loader used to load this test class. */ private Class reload() throws Exception { Class testObjCls = null; @@ -129,7 +129,7 @@ public class LoadTestCase extends TestCase { /** * Call the static setAllowFlawedContext method on the specified class - * (expected to be a UserClass loaded via a custom classloader), passing + * (expected to be a UserClass loaded via a custom class loader), passing * it the specified state parameter. */ private void setAllowFlawedContext(final Class c, final String state) throws Exception { @@ -151,7 +151,7 @@ public class LoadTestCase extends TestCase { } /** - * Test what happens when we play various classloader tricks like those + * Test what happens when we play various class loader tricks like those * that happen in web and j2ee containers. * <p> * Note that this test assumes that commons-logging.jar and log4j.jar @@ -166,19 +166,19 @@ public class LoadTestCase extends TestCase { // 1. Thread.currentThread().setContextClassLoader(appLoader); // 2. Thread.currentThread().setContextClassLoader(null); - // Context classloader is same as class calling into log + // Context class loader is same as class calling into log Class cls = reload(); Thread.currentThread().setContextClassLoader(cls.getClassLoader()); execute(cls); - // Context classloader is the "bootclassloader". This is technically + // Context class loader is the "bootclass loader". This is technically // bad, but LogFactoryImpl.ALLOW_FLAWED_CONTEXT defaults to true so // this test should pass. cls = reload(); Thread.currentThread().setContextClassLoader(null); execute(cls); - // Context classloader is the "bootclassloader". This is same as above + // Context class loader is the "bootclass loader". This is same as above // except that ALLOW_FLAWED_CONTEXT is set to false; an error should // now be reported. cls = reload(); @@ -186,27 +186,27 @@ public class LoadTestCase extends TestCase { try { setAllowFlawedContext(cls, "false"); execute(cls); - fail("Logging config succeeded when context classloader was null!"); + fail("Logging config succeeded when context class loader was null!"); } catch (final InvocationTargetException ex) { final Throwable targetException = ex.getTargetException(); - // LogConfigurationException is expected; the boot classloader doesn't *have* JCL available + // LogConfigurationException is expected; the boot class loader doesn't *have* JCL available if (!(targetException instanceof LogConfigurationException)) { throw ex; } } - // Context classloader is the system classloader. + // Context class loader is the system class loader. // // This is expected to cause problems, as LogFactoryImpl will attempt - // to use the system classloader to load the Log4JLogger class, which + // to use the system class loader to load the Log4JLogger class, which // will then be unable to cast that object to the Log interface loaded - // via the child classloader. However as ALLOW_FLAWED_CONTEXT defaults + // via the child class loader. However as ALLOW_FLAWED_CONTEXT defaults // to true this test should pass. cls = reload(); Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); execute(cls); - // Context classloader is the system classloader. This is the same + // Context class loader is the system class loader. This is the same // as above except that ALLOW_FLAWED_CONTEXT is set to false; an error // should now be reported. cls = reload(); @@ -214,8 +214,8 @@ public class LoadTestCase extends TestCase { try { setAllowFlawedContext(cls, "false"); execute(cls); - fail("Error: somehow downcast a Logger loaded via system classloader" - + " to the Log interface loaded via a custom classloader"); + fail("Error: somehow downcast a Logger loaded via system class loader" + + " to the Log interface loaded via a custom class loader"); } catch (final InvocationTargetException ex) { final Throwable targetException = ex.getTargetException(); // LogConfigurationException is expected diff --git a/src/test/java/org/apache/commons/logging/NullClassLoaderTestCase.java b/src/test/java/org/apache/commons/logging/NullClassLoaderTestCase.java index 681dff2..12411a4 100644 --- a/src/test/java/org/apache/commons/logging/NullClassLoaderTestCase.java +++ b/src/test/java/org/apache/commons/logging/NullClassLoaderTestCase.java @@ -21,7 +21,7 @@ import junit.framework.TestCase; /** * Test cases for situations where getClassLoader or getContextClassLoader * return null. This can happen when using JDK 1.1. It can also happen when - * JCL is deployed via the bootclassloader - something that could be done when + * JCL is deployed via the bootclass loader - something that could be done when * using java in embedded systems. */ public class NullClassLoaderTestCase extends TestCase { @@ -35,7 +35,7 @@ public class NullClassLoaderTestCase extends TestCase { */ public void testSameLogObject() throws Exception { // unfortunately, there just isn't any way to emulate JCL being - // accessible via the null classloader in "standard" systems, so + // accessible via the null class loader in "standard" systems, so // we can't include this test in our standard unit tests. } } diff --git a/src/test/java/org/apache/commons/logging/PathableClassLoader.java b/src/test/java/org/apache/commons/logging/PathableClassLoader.java index a58d38d..07f89f9 100644 --- a/src/test/java/org/apache/commons/logging/PathableClassLoader.java +++ b/src/test/java/org/apache/commons/logging/PathableClassLoader.java @@ -33,7 +33,7 @@ import junit.framework.Assert; * A ClassLoader which sees only specified classes, and which can be * set to do parent-first or child-first path lookup. * <p> - * Note that this classloader is not "industrial strength"; users + * Note that this class loader is not "industrial strength"; users * looking for such a class may wish to look at the Tomcat sourcecode * instead. In particular, this class may not be threadsafe. * <p> @@ -54,16 +54,16 @@ public class PathableClassLoader extends URLClassLoader { /** * A map of package-prefix to ClassLoader. Any class which is in - * this map is looked up via the specified classloader instead of - * the classpath associated with this classloader or its parents. + * this map is looked up via the specified class loader instead of + * the classpath associated with this class loader or its parents. * <p> * This is necessary in order for the rest of the world to communicate - * with classes loaded via a custom classloader. As an example, junit - * tests which are loaded via a custom classloader needs to see + * with classes loaded via a custom class loader. As an example, junit + * tests which are loaded via a custom class loader needs to see * the same junit classes as the code invoking the test, otherwise * they can't pass result objects back. * <p> - * Normally, only a classloader created with a null parent needs to + * Normally, only a class loader created with a null parent needs to * have any lookasides defined. */ private HashMap lookasides; @@ -81,7 +81,7 @@ public class PathableClassLoader extends URLClassLoader { * totally clean; nothing but the standard java library will be * present. * <p> - * When using a null parent classloader with a junit test, it *is* + * When using a null parent class loader with a junit test, it *is* * necessary for the junit library to also be visible. In this case, it * is recommended that the following code be used: * <pre> @@ -91,7 +91,7 @@ public class PathableClassLoader extends URLClassLoader { * </pre> * Note that this works regardless of whether junit is on the system * classpath, or whether it has been loaded by some test framework that - * creates its own classloader to run unit tests in (eg maven2's + * creates its own class loader to run unit tests in (eg maven2's * Surefire plugin). */ public PathableClassLoader(final ClassLoader parent) { @@ -108,9 +108,9 @@ public class PathableClassLoader extends URLClassLoader { * be found. Typically this is the name of a jar file, or a directory * containing class files. * <p> - * If there is no system property, but the classloader that loaded + * If there is no system property, but the class loader that loaded * this class is a URLClassLoader then the set of URLs that the - * classloader uses for its classpath is scanned; any jar in the + * class loader uses for its classpath is scanned; any jar in the * URL set whose name starts with the specified string is added to * the classpath managed by this instance. * <p> @@ -225,14 +225,14 @@ public class PathableClassLoader extends URLClassLoader { final ClassLoader parent = getParent(); if (parent == null) { // Alas, there is no method to get matching resources - // from a null (BOOT) parent classloader. Calling + // from a null (BOOT) parent class loader. Calling // ClassLoader.getSystemClassLoader isn't right. Maybe // calling Class.class.getResources(name) would do? // // However for the purposes of unit tests, we can // simply assume that no relevant resources are // loadable from the parent; unit tests will never be - // putting any of their resources in a "boot" classloader + // putting any of their resources in a "boot" class loader // path! return localUrls; } @@ -245,15 +245,15 @@ public class PathableClassLoader extends URLClassLoader { } /** - * If the classloader that loaded this class has this logical lib in its + * If the class loader that loaded this class has this logical lib in its * path, then return the matching URL otherwise return null. * <p> - * This only works when the classloader loading this class is an instance + * This only works when the class loader loading this class is an instance * of URLClassLoader and thus has a getURLs method that returns the classpath * it uses when loading classes. However in practice, the vast majority of the - * time this type is the classloader used. + * time this type is the class loader used. * <p> - * The classpath of the classloader for this instance is scanned, and any + * The classpath of the class loader for this instance is scanned, and any * jarfile in the path whose name starts with the logicalLib string is * considered a match. For example, passing "foo" will match a url * of {@code file:///some/where/foo-2.7.jar}. @@ -301,7 +301,7 @@ public class PathableClassLoader extends URLClassLoader { * <p> * For each explicitly mapped package prefix, if the name matches the * prefix associated with that entry then attempt to load the class via - * that entries' classloader. + * that entries' class loader. */ @Override protected Class loadClass(final String name, final boolean resolve) @@ -341,7 +341,7 @@ public class PathableClassLoader extends URLClassLoader { } /** - * Specify whether this classloader should ask the parent classloader + * Specify whether this class loader should ask the parent class loader * to resolve a class first, before trying to resolve it via its own * classpath. * <p> @@ -380,13 +380,13 @@ public class PathableClassLoader extends URLClassLoader { } /** - * Specify a classloader to use for specific java packages. + * Specify a class loader to use for specific java packages. * <p> - * The specified classloader is normally a loader that is NOT - * an ancestor of this classloader. In particular, this loader + * The specified class loader is normally a loader that is NOT + * an ancestor of this class loader. In particular, this loader * may have the bootloader as its parent, but be configured to * see specific other classes (eg the junit library loaded - * via the system classloader). + * via the system class loader). * <p> * The differences between using this method, and using * addLogicalLib are: @@ -394,11 +394,11 @@ public class PathableClassLoader extends URLClassLoader { * <li>If code calls getClassLoader on a class loaded via * "lookaside", then traces up its inheritance chain, it * will see the "real" class loaders. When the class is remapped - * into this classloader via addLogicalLib, the classloader + * into this class loader via addLogicalLib, the class loader * 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) + * the same "lookaside" class loader (eg the system class loader) * then map one of those subsets from here. Of course they could * be loaded into two different "lookaside" class loaders and * then a prefix used to map from here to one of those class loaders. @@ -421,7 +421,7 @@ public class PathableClassLoader extends URLClassLoader { * </pre> * <p> * Of course, this assumes that the classes of interest are already - * in the classpath of the system classloader. + * in the classpath of the system class loader. */ public void useSystemLoader(final String prefix) { useExplicitLoader(prefix, ClassLoader.getSystemClassLoader()); diff --git a/src/test/java/org/apache/commons/logging/PathableTestSuite.java b/src/test/java/org/apache/commons/logging/PathableTestSuite.java index fd414a6..ade114d 100644 --- a/src/test/java/org/apache/commons/logging/PathableTestSuite.java +++ b/src/test/java/org/apache/commons/logging/PathableTestSuite.java @@ -23,10 +23,10 @@ import junit.framework.TestResult; import junit.framework.TestSuite; /** - * Custom TestSuite class that can be used to control the context classloader + * Custom TestSuite class that can be used to control the context class loader * in operation when a test runs. * <p> - * For tests that need to control exactly what the classloader hierarchy is + * For tests that need to control exactly what the class loader hierarchy is * like when the test is run, something like the following is recommended: * <pre> * class SomeTestCase extends TestCase { @@ -57,18 +57,18 @@ import junit.framework.TestSuite; * is expected that using the two classes together is common practice. * <p> * This class will run each test methods within the specified TestCase using - * the specified context classloader and system classloader. If different + * the specified context class loader and system class loader. If different * tests within the same class require different context class loaders, - * then the context classloader passed to the constructor should be the + * then the context class loader 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 + * of this "lowest" class loader can call * <pre> * // NB: pseudo-code only * setContextClassLoader(getContextClassLoader().getParent()); * </pre> - * This class ensures that any context classloader changes applied by a test + * This class ensures that any context class loader changes applied by a test * is undone after the test is run, so tests don't need to worry about - * restoring the context classloader on exit. This class also ensures that + * restoring the context class loader on exit. This class also ensures that * the system properties are restored to their original settings after each * test, so tests that manipulate those don't need to worry about resetting them. * <p> @@ -87,14 +87,14 @@ import junit.framework.TestSuite; * <p> * <h2>Limitations</h2> * <p> - * This class cannot control the system classloader (ie what method + * This class cannot control the system class loader (ie what method * ClassLoader.getSystemClassLoader returns) because Java provides no - * mechanism for setting the system classloader. In this case, the only + * mechanism for setting the system class loader. In this case, the only * option is to invoke the unit test in a separate JVM with the appropriate * settings. * <p> * The effect of using this approach in a system that uses junit's - * "reloading classloader" behavior is unknown. This junit feature is + * "reloading class loader" behavior is unknown. This junit feature is * intended for junit GUI apps where a test may be run multiple times * within the same JVM - and in particular, when the .class file may * be modified between runs of the test. How junit achieves this is @@ -105,7 +105,7 @@ import junit.framework.TestSuite; public class PathableTestSuite extends TestSuite { /** - * The classloader that should be set as the context classloader + * The class loader that should be set as the context class loader * before each test in the suite is run. */ private final ClassLoader contextLoader; @@ -130,7 +130,7 @@ public class PathableTestSuite extends TestSuite { * Note that a Test may itself be a TestSuite object (ie a collection * of tests). * <p> - * The context classloader and system properties are saved before each + * The context class loader and system properties are saved before each * test, and restored after the test completes to better isolate tests. */ @Override diff --git a/src/test/java/org/apache/commons/logging/UserClass.java b/src/test/java/org/apache/commons/logging/UserClass.java index 8401146..db1d3b1 100644 --- a/src/test/java/org/apache/commons/logging/UserClass.java +++ b/src/test/java/org/apache/commons/logging/UserClass.java @@ -22,9 +22,9 @@ public class UserClass { /** * Sets the ALLOW_FLAWED_CONTEXT feature on the LogFactoryImpl object - * associated with this class' classloader. + * associated with this class' class loader. * <p> - * Don't forget to set the context classloader to whatever it will be + * Don't forget to set the context class loader to whatever it will be * when an instance of this class is actually created <i>before</i> calling * this method! */ 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 70d33ba..e7ce08d 100644 --- a/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java @@ -61,7 +61,7 @@ public class FirstPriorityConfigTestCase extends TestCase { final String thisClassPath = thisClass.getName().replace('.', '/') + ".class"; final URL baseUrl = dummy.findResource(thisClassPath); - // Now set up the desired classloader hierarchy. We'll put JCL + // Now set up the desired class loader hierarchy. We'll put JCL // in the container path, the test in a webapp path, and // both config files into the webapp path too. final PathableClassLoader containerLoader = new PathableClassLoader(null); @@ -111,10 +111,10 @@ public class FirstPriorityConfigTestCase extends TestCase { final ClassLoader lfClassLoader = instance.getClass().getClassLoader(); final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - // context classloader should be thisClassLoader + // context class loader should be thisClassLoader assertEquals(thisClassLoader, contextClassLoader); - // lfClassLoader should be parent of this classloader + // lfClassLoader should be parent of this class loader assertEquals(lfClassLoader, thisClassLoader.getParent()); assertEquals(PathableClassLoader.class.getName(), lfClassLoader.getClass().getName()); 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 9a6f9d3..c35ece8 100644 --- a/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java @@ -68,7 +68,7 @@ public class PriorityConfigTestCase extends TestCase { final String thisClassPath = thisClass.getName().replace('.', '/') + ".class"; final URL baseUrl = dummy.findResource(thisClassPath); - // Now set up the desired classloader hierarchy. We'll put a config + // Now set up the desired class loader hierarchy. We'll put a config // file of priority=10 in the container path, and ones of both // "no priority" and priority=20 in the webapp path. // diff --git a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java index 23756a1..8fdb590 100644 --- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java +++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java @@ -37,7 +37,7 @@ public class CustomConfigAPITestCase extends CustomConfigTestCase { final PathableClassLoader parent = new PathableClassLoader(null); parent.useExplicitLoader("junit.", Test.class.getClassLoader()); - // the TestHandler class must be accessible from the System classloader + // the TestHandler class must be accessible from the System class loader // in order for java.util.logging.LogManager.readConfiguration to // be able to instantiate it. And this test case must see the same // class in order to be able to access its data. Yes this is ugly diff --git a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java index 74dee51..85420a5 100644 --- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java +++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java @@ -39,7 +39,7 @@ public class CustomConfigFullTestCase extends CustomConfigTestCase { final PathableClassLoader parent = new PathableClassLoader(null); parent.useExplicitLoader("junit.", Test.class.getClassLoader()); - // the TestHandler class must be accessible from the System classloader + // the TestHandler class must be accessible from the System class loader // in order for java.util.logging.LogManager.readConfiguration to // be able to instantiate it. And this test case must see the same // class in order to be able to access its data. Yes this is ugly 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 7cc4c2e..8457aa5 100644 --- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java +++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java @@ -48,15 +48,15 @@ public class CustomConfigTestCase extends DefaultConfigTestCase { /** - * Make a class available in the system classloader even when its classfile is - * not present in the classpath configured for that classloader. This only + * Make a class available in the system class loader even when its classfile is + * not present in the classpath configured for that class loader. This only * works for classes for which all dependencies are already loaded in - * that classloader. + * that class loader. */ protected static void loadTestHandler(final String className, final ClassLoader targetCL) { try { targetCL.loadClass(className); - // fail("Class already in target classloader"); + // fail("Class already in target class loader"); return; } catch (final ClassNotFoundException ex) { // ok, go ahead and load it @@ -87,7 +87,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase { /** * Given the name of a class that is somewhere in the classpath of the provided - * classloader, return the contents of the corresponding .class file. + * class loader, return the contents of the corresponding .class file. */ protected static byte[] readClass(final String name, final ClassLoader srcCL) throws Exception { final String resName = name.replace('.', '/') + ".class"; @@ -115,7 +115,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase { final PathableClassLoader cl = new PathableClassLoader(null); cl.useExplicitLoader("junit.", Test.class.getClassLoader()); - // the TestHandler class must be accessible from the System classloader + // the TestHandler class must be accessible from the System class loader // in order for java.util.logging.LogManager.readConfiguration to // be able to instantiate it. And this test case must see the same // class in order to be able to access its data. Yes this is ugly diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java index 2220a35..2f348ab 100644 --- a/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java +++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/AppClasspathStandardTestCase.java @@ -26,7 +26,7 @@ import junit.framework.Test; import junit.framework.TestCase; /** - * Tests for Log4J logging when there is only one classloader and everything + * Tests for Log4J logging when there is only one class loader and everything * is in it, as would be the situation for a standalone application. */ 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 e5a367a..25dd39a 100644 --- a/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java +++ b/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java @@ -45,12 +45,12 @@ public class ChildFirstTestCase extends TestCase { /** - * Sets up a custom classloader hierarchy for this test case. + * Sets up a custom class loader hierarchy for this test case. * The hierarchy is: * <ul> * <li> contextloader: child-first. * <li> childloader: child-first, used to load test case. - * <li> parentloader: child-first, parent is the bootclassloader. + * <li> parentloader: child-first, parent is the bootclass loader. * </ul> */ public static Test suite() throws Exception { @@ -64,7 +64,7 @@ public class ChildFirstTestCase extends TestCase { // Make the junit classes visible as a special case, as junit // won't be able to call this class at all without this. The - // junit classes must be visible from the classloader that loaded + // junit classes must be visible from the class loader that loaded // this class, so use that as the source for future access to classes // from the junit package. parent.useExplicitLoader("junit.", thisClassLoader); @@ -73,20 +73,20 @@ public class ChildFirstTestCase extends TestCase { // Make the commons-logging.jar classes visible via the parent parent.addLogicalLib("commons-logging"); - // Create a child classloader to load the test case through + // Create a child class loader to load the test case through final PathableClassLoader child = new PathableClassLoader(parent); child.setParentFirst(false); - // Obviously, the child classloader needs to have the test classes + // Obviously, the child class loader needs to have the test classes // in its path! child.addLogicalLib("testclasses"); child.addLogicalLib("commons-logging-adapters"); - // Create a third classloader to be the context classloader. + // Create a third class loader to be the context class loader. final PathableClassLoader context = new PathableClassLoader(child); context.setParentFirst(false); - // reload this class via the child classloader + // reload this class via the child class loader final Class testClass = child.loadClass(thisClass.getName()); // and return our custom TestSuite class @@ -122,56 +122,56 @@ public class ChildFirstTestCase extends TestCase { } /** - * Test that the classloader hierarchy is as expected, and that + * Test that the class loader hierarchy is as expected, and that * calling loadClass() on various class loaders works as expected. * Note that for this test case, parent-first classloading is * in effect. */ public void testPaths() throws Exception { - // the context classloader is not expected to be null + // the context class loader is not expected to be null final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); - assertNotNull("Context classloader is null", contextLoader); - assertEquals("Context classloader has unexpected type", + assertNotNull("Context class loader is null", contextLoader); + assertEquals("Context class loader has unexpected type", PathableClassLoader.class.getName(), contextLoader.getClass().getName()); - // the classloader that loaded this class is obviously not null + // the class loader that loaded this class is obviously not null final ClassLoader thisLoader = this.getClass().getClassLoader(); assertNotNull("thisLoader is null", thisLoader); assertEquals("thisLoader has unexpected type", PathableClassLoader.class.getName(), thisLoader.getClass().getName()); - // the suite method specified that the context classloader's parent + // the suite method specified that the context class loader's parent // is the loader that loaded this test case. - assertSame("Context classloader is not child of thisLoader", + assertSame("Context class loader is not child of thisLoader", thisLoader, contextLoader.getParent()); // thisLoader's parent should be available final ClassLoader parentLoader = thisLoader.getParent(); - assertNotNull("Parent classloader is null", parentLoader); - assertEquals("Parent classloader has unexpected type", + assertNotNull("Parent class loader is null", parentLoader); + assertEquals("Parent class loader has unexpected type", PathableClassLoader.class.getName(), parentLoader.getClass().getName()); // parent should have a parent of null - assertNull("Parent classloader has non-null parent", parentLoader.getParent()); + assertNull("Parent class loader has non-null parent", parentLoader.getParent()); // getSystemClassloader is not a PathableClassLoader; it's of a - // built-in type. This also verifies that system classloader is none of + // built-in type. This also verifies that system class loader is none of // (context, child, parent). final ClassLoader systemLoader = ClassLoader.getSystemClassLoader(); - assertNotNull("System classloader is null", systemLoader); - assertFalse("System classloader has unexpected type", + assertNotNull("System class loader is null", systemLoader); + assertFalse("System class loader has unexpected type", PathableClassLoader.class.getName().equals( systemLoader.getClass().getName())); - // junit classes should be visible; their classloader is not + // junit classes should be visible; their class loader is not // 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(); - assertFalse("Junit not loaded by ancestor classloader", + assertFalse("Junit not loaded by ancestor class loader", ancestorCLs.contains(junitTest.getClassLoader())); // jcl api classes should be visible only via the parent @@ -199,9 +199,9 @@ public class ChildFirstTestCase extends TestCase { // ok } - // String class classloader is null + // String class class loader is null final Class stringClass = contextLoader.loadClass("java.lang.String"); - assertNull("String class classloader is not null!", + assertNull("String class class loader is not null!", stringClass.getClassLoader()); } @@ -218,11 +218,11 @@ public class ChildFirstTestCase extends TestCase { resource = childLoader.getResource("nosuchfile"); assertNull("Non-null URL returned for invalid resource name", resource); - // getResource where it is accessible only to parent classloader + // getResource where it is accessible only to parent class loader resource = childLoader.getResource("org/apache/commons/logging/Log.class"); assertNotNull("Unable to locate Log.class resource", resource); - // getResource where it is accessible only to child classloader + // getResource where it is accessible only to child class loader resource = childLoader.getResource("org/apache/commons/logging/PathableTestSuite.class"); assertNotNull("Unable to locate PathableTestSuite.class resource", resource); @@ -242,12 +242,12 @@ public class ChildFirstTestCase extends TestCase { public void testResourceAsStream() throws Exception { java.io.InputStream is; - // verify the classloader hierarchy + // verify the class loader hierarchy final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); final ClassLoader childLoader = contextLoader.getParent(); final ClassLoader parentLoader = childLoader.getParent(); final ClassLoader bootLoader = parentLoader.getParent(); - assertNull("Unexpected classloader hierarchy", bootLoader); + assertNull("Unexpected class loader hierarchy", bootLoader); // getResourceAsStream where no instances exist is = childLoader.getResourceAsStream("nosuchfile"); @@ -271,12 +271,12 @@ public class ChildFirstTestCase extends TestCase { Enumeration resources; URL[] urls; - // verify the classloader hierarchy + // verify the class loader hierarchy final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); final ClassLoader childLoader = contextLoader.getParent(); final ClassLoader parentLoader = childLoader.getParent(); final ClassLoader bootLoader = parentLoader.getParent(); - assertNull("Unexpected classloader hierarchy", bootLoader); + assertNull("Unexpected class loader hierarchy", bootLoader); // getResources where no instances exist resources = childLoader.getResources("nosuchfile"); diff --git a/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java b/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java index 5c61fb3..ed75cdd 100644 --- a/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java +++ b/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java @@ -32,7 +32,7 @@ import junit.framework.TestCase; public class GeneralTestCase extends TestCase { /** - * Verify that the context classloader is a custom one, then reset it to + * Verify that the context class loader is a custom one, then reset it to * a non-custom one. */ private static void checkAndSetContext() { @@ -57,7 +57,7 @@ public class GeneralTestCase extends TestCase { } /** - * Sets up a custom classloader hierarchy for this test case. + * Sets up a custom class loader hierarchy for this test case. */ public static Test suite() throws Exception { final Class thisClass = GeneralTestCase.class; @@ -67,7 +67,7 @@ public class GeneralTestCase extends TestCase { loader.useExplicitLoader("junit.", thisClassLoader); loader.addLogicalLib("testclasses"); - // reload this class via the child classloader + // reload this class via the child class loader final Class testClass = loader.loadClass(thisClass.getName()); // and return our custom TestSuite class @@ -75,7 +75,7 @@ public class GeneralTestCase extends TestCase { } /** - * Verify that when a test method modifies the context classloader it is + * Verify that when a test method modifies the context class loader it is * reset before the next test is run. * <p> * This method works in conjunction with testResetContext2. There is no 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 836e361..a7a8983 100644 --- a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java +++ b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java @@ -46,12 +46,12 @@ import junit.framework.TestCase; public class ParentFirstTestCase extends TestCase { /** - * Sets up a custom classloader hierarchy for this test case. + * Sets up a custom class loader hierarchy for this test case. * The hierarchy is: * <ul> * <li> contextloader: parent-first. * <li> childloader: parent-first, used to load test case. - * <li> parentloader: parent-first, parent is the bootclassloader. + * <li> parentloader: parent-first, parent is the boot class loader. * </ul> */ public static Test suite() throws Exception { @@ -64,7 +64,7 @@ public class ParentFirstTestCase extends TestCase { // Make the junit classes visible as a special case, as junit // won't be able to call this class at all without this. The - // junit classes must be visible from the classloader that loaded + // junit classes must be visible from the class loader that loaded // this class, so use that as the source for future access to classes // from the junit package. parent.useExplicitLoader("junit.", thisClassLoader); @@ -73,18 +73,18 @@ public class ParentFirstTestCase extends TestCase { // make the commons-logging.jar classes visible via the parent parent.addLogicalLib("commons-logging"); - // create a child classloader to load the test case through + // create a child class loader to load the test case through final PathableClassLoader child = new PathableClassLoader(parent); - // obviously, the child classloader needs to have the test classes + // obviously, the child class loader needs to have the test classes // in its path! child.addLogicalLib("testclasses"); child.addLogicalLib("commons-logging-adapters"); - // create a third classloader to be the context classloader. + // create a third class loader to be the context class loader. final PathableClassLoader context = new PathableClassLoader(child); - // reload this class via the child classloader + // reload this class via the child class loader final Class testClass = child.loadClass(thisClass.getName()); // and return our custom TestSuite class @@ -120,55 +120,55 @@ public class ParentFirstTestCase extends TestCase { } /** - * Test that the classloader hierarchy is as expected, and that + * Test that the class loader hierarchy is as expected, and that * calling loadClass() on various class loaders works as expected. * Note that for this test case, parent-first classloading is * in effect. */ public void testPaths() throws Exception { - // the context classloader is not expected to be null + // the context class loader is not expected to be null final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); - assertNotNull("Context classloader is null", contextLoader); - assertEquals("Context classloader has unexpected type", + assertNotNull("Context class loader is null", contextLoader); + assertEquals("Context class loader has unexpected type", PathableClassLoader.class.getName(), contextLoader.getClass().getName()); - // the classloader that loaded this class is obviously not null + // the class loader that loaded this class is obviously not null final ClassLoader thisLoader = this.getClass().getClassLoader(); assertNotNull("thisLoader is null", thisLoader); assertEquals("thisLoader has unexpected type", PathableClassLoader.class.getName(), thisLoader.getClass().getName()); - // the suite method specified that the context classloader's parent + // the suite method specified that the context class loader's parent // is the loader that loaded this test case. - assertSame("Context classloader is not child of thisLoader", + assertSame("Context class loader is not child of thisLoader", thisLoader, contextLoader.getParent()); // thisLoader's parent should be available final ClassLoader parentLoader = thisLoader.getParent(); - assertNotNull("Parent classloader is null", parentLoader); - assertEquals("Parent classloader has unexpected type", + assertNotNull("Parent class loader is null", parentLoader); + assertEquals("Parent class loader has unexpected type", PathableClassLoader.class.getName(), parentLoader.getClass().getName()); // parent should have a parent of null - assertNull("Parent classloader has non-null parent", parentLoader.getParent()); + assertNull("Parent class loader has non-null parent", parentLoader.getParent()); // getSystemClassloader is not a PathableClassLoader; it's of a - // built-in type. This also verifies that system classloader is none of + // built-in type. This also verifies that system class loader is none of // (context, child, parent). final ClassLoader systemLoader = ClassLoader.getSystemClassLoader(); - assertNotNull("System classloader is null", systemLoader); - assertNotEquals("System classloader has unexpected type", PathableClassLoader.class.getName(), + assertNotNull("System class loader is null", systemLoader); + assertNotEquals("System class loader has unexpected type", PathableClassLoader.class.getName(), systemLoader.getClass().getName()); - // junit classes should be visible; their classloader is not + // junit classes should be visible; their class loader is not // 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(); - assertFalse("Junit not loaded by ancestor classloader", + assertFalse("Junit not loaded by ancestor class loader", ancestorCLs.contains(junitTest.getClassLoader())); // jcl api classes should be visible only via the parent @@ -196,9 +196,9 @@ public class ParentFirstTestCase extends TestCase { // ok } - // String class classloader is null + // String class class loader is null final Class stringClass = contextLoader.loadClass("java.lang.String"); - assertNull("String class classloader is not null!", + assertNull("String class class loader is not null!", stringClass.getClassLoader()); } @@ -215,11 +215,11 @@ public class ParentFirstTestCase extends TestCase { resource = childLoader.getResource("nosuchfile"); assertNull("Non-null URL returned for invalid resource name", resource); - // getResource where it is accessible only to parent classloader + // getResource where it is accessible only to parent class loader resource = childLoader.getResource("org/apache/commons/logging/Log.class"); assertNotNull("Unable to locate Log.class resource", resource); - // getResource where it is accessible only to child classloader + // getResource where it is accessible only to child class loader resource = childLoader.getResource("org/apache/commons/logging/PathableTestSuite.class"); assertNotNull("Unable to locate PathableTestSuite.class resource", resource); @@ -239,12 +239,12 @@ public class ParentFirstTestCase extends TestCase { public void testResourceAsStream() throws Exception { java.io.InputStream is; - // verify the classloader hierarchy + // verify the class loader hierarchy final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); final ClassLoader childLoader = contextLoader.getParent(); final ClassLoader parentLoader = childLoader.getParent(); final ClassLoader bootLoader = parentLoader.getParent(); - assertNull("Unexpected classloader hierarchy", bootLoader); + assertNull("Unexpected class loader hierarchy", bootLoader); // getResourceAsStream where no instances exist is = childLoader.getResourceAsStream("nosuchfile"); @@ -268,12 +268,12 @@ public class ParentFirstTestCase extends TestCase { Enumeration resources; URL[] urls; - // verify the classloader hierarchy + // verify the class loader hierarchy final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); final ClassLoader childLoader = contextLoader.getParent(); final ClassLoader parentLoader = childLoader.getParent(); final ClassLoader bootLoader = parentLoader.getParent(); - assertNull("Unexpected classloader hierarchy", bootLoader); + assertNull("Unexpected class loader hierarchy", bootLoader); // getResources where no instances exist resources = childLoader.getResources("nosuchfile"); diff --git a/src/test/java/org/apache/commons/logging/security/SecurityAllowedTestCase.java b/src/test/java/org/apache/commons/logging/security/SecurityAllowedTestCase.java index 1152df7..a71a42a 100644 --- a/src/test/java/org/apache/commons/logging/security/SecurityAllowedTestCase.java +++ b/src/test/java/org/apache/commons/logging/security/SecurityAllowedTestCase.java @@ -37,9 +37,9 @@ import junit.framework.TestCase; * <p> * This class has only one unit test, as we are (in part) checking behavior in * the static block of the LogFactory class. As that class cannot be unloaded after - * being loaded into a classloader, the only workaround is to use the + * being loaded into a class loader, the only workaround is to use the * PathableClassLoader approach to ensure each test is run in its own - * classloader, and use a separate test class for each test. + * class loader, and use a separate test class for each test. */ public class SecurityAllowedTestCase extends TestCase { diff --git a/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java b/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java index 07a5be8..055b980 100644 --- a/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java +++ b/src/test/java/org/apache/commons/logging/security/SecurityForbiddenTestCase.java @@ -42,9 +42,9 @@ import junit.framework.TestCase; * <p> * This class has only one unit test, as we are (in part) checking behavior in * the static block of the LogFactory class. As that class cannot be unloaded after - * being loaded into a classloader, the only workaround is to use the + * being loaded into a class loader, the only workaround is to use the * PathableClassLoader approach to ensure each test is run in its own - * classloader, and use a separate test class for each test. + * class loader, and use a separate test class for each test. */ public class SecurityForbiddenTestCase extends TestCase { @@ -77,7 +77,7 @@ public class SecurityForbiddenTestCase extends TestCase { private ClassLoader otherClassLoader; /** - * Loads a class with the given classloader. + * Loads a class with the given class loader. */ private Object loadClass(final String name, final ClassLoader classLoader) { try { @@ -167,8 +167,8 @@ public class SecurityForbiddenTestCase extends TestCase { /** * Test what happens when JCL is run with absolutely no security - * privileges at all and a class loaded with a different classloader - * than the context classloader of the current thread tries to log something. + * privileges at all and a class loaded with a different class loader + * than the context class loader of the current thread tries to log something. */ public void testContextClassLoader() { // Ignore on Java 21 @@ -183,7 +183,7 @@ public class SecurityForbiddenTestCase extends TestCase { System.setSecurityManager(mySecurityManager); try { - // load a dummy class with another classloader + // load a dummy class with another class loader // to force a SecurityException when the LogFactory calls // Thread.getCurrentThread().getContextClassLoader() loadClass("org.apache.commons.logging.security.DummyClass", otherClassLoader); diff --git a/src/test/java/org/apache/commons/logging/serviceloader/internal/ThrowingLogFactory.java b/src/test/java/org/apache/commons/logging/serviceloader/internal/ThrowingLogFactory.java index 650d031..982bfbc 100644 --- a/src/test/java/org/apache/commons/logging/serviceloader/internal/ThrowingLogFactory.java +++ b/src/test/java/org/apache/commons/logging/serviceloader/internal/ThrowingLogFactory.java @@ -17,7 +17,7 @@ package org.apache.commons.logging.serviceloader.internal; /** - * A common ServiceLoader error is finding a class that implements LogFactory from a different classloader. + * A common ServiceLoader error is finding a class that implements LogFactory from a different class loader. * This class should emulate that behavior. */ public class ThrowingLogFactory { diff --git a/src/test/java/org/apache/commons/logging/servlet/BasicServletTestCase.java b/src/test/java/org/apache/commons/logging/servlet/BasicServletTestCase.java index bf1a8c2..9a87fe9 100644 --- a/src/test/java/org/apache/commons/logging/servlet/BasicServletTestCase.java +++ b/src/test/java/org/apache/commons/logging/servlet/BasicServletTestCase.java @@ -41,7 +41,7 @@ public class BasicServletTestCase extends TestCase { // // Having the test loaded via a loader above the tccl emulates the situation // where a web.xml file specifies ServletContextCleaner as a listener, and - // that class is deployed via a shared classloader. + // that class is deployed via a shared class loader. final PathableClassLoader parent = new PathableClassLoader(null); parent.useExplicitLoader("junit.", Test.class.getClassLoader()); 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 7d94d46..4ac197c 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 @@ -31,7 +31,7 @@ import junit.framework.TestCase; /** - * Verify that by default LogFactoryImpl is loaded from the tccl classloader. + * Verify that by default LogFactoryImpl is loaded from the tccl class loader. */ public class TcclDisabledTestCase extends TestCase { @@ -61,10 +61,10 @@ public class TcclDisabledTestCase extends TestCase { final String thisClassPath = thisClass.getName().replace('.', '/') + ".class"; final URL baseUrl = dummy.findResource(thisClassPath); - // Now set up the desired classloader hierarchy. Everything goes into + // Now set up the desired class loader hierarchy. Everything goes into // the parent classpath, but we exclude the custom Log class. // - // We then create a tccl classloader that can see the custom + // We then create a tccl class loader that can see the custom // Log class. Therefore if that class can be found, then the // TCCL must have been used to load it. final PathableClassLoader emptyLoader = new PathableClassLoader(null); @@ -73,7 +73,7 @@ public class TcclDisabledTestCase extends TestCase { parentLoader.useExplicitLoader("junit.", Test.class.getClassLoader()); parentLoader.addLogicalLib("commons-logging"); parentLoader.addLogicalLib("testclasses"); - // hack to ensure that the test classloader can't see + // hack to ensure that the test class loader can't see // the custom MyLog parentLoader.useExplicitLoader(MY_LOG_PKG + ".", emptyLoader); @@ -113,12 +113,12 @@ public class TcclDisabledTestCase extends TestCase { final ClassLoader tcclLoader = Thread.currentThread().getContextClassLoader(); // the tccl loader should NOT be the same as the loader that loaded this test class. - assertNotSame("tccl not same as test classloader", thisClassLoader, tcclLoader); + assertNotSame("tccl not same as test class loader", thisClassLoader, tcclLoader); // MyLog should not be loadable via parent loader try { final Class clazz = thisClassLoader.loadClass(MY_LOG_IMPL); - fail("Unexpectedly able to load MyLog via test class classloader"); + fail("Unexpectedly able to load MyLog via test class class loader"); assertNotNull(clazz); // silence warnings about unused var } catch (final ClassNotFoundException ex) { // ok, expected @@ -129,7 +129,7 @@ public class TcclDisabledTestCase extends TestCase { final Class clazz = tcclLoader.loadClass(MY_LOG_IMPL); assertNotNull(clazz); } catch (final ClassNotFoundException ex) { - fail("Unexpectedly unable to load MyLog via tccl classloader"); + fail("Unexpectedly unable to load MyLog via tccl class loader"); } } 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 c4a9d6b..17f7628 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 @@ -61,10 +61,10 @@ public class TcclEnabledTestCase extends TestCase { final String thisClassPath = thisClass.getName().replace('.', '/') + ".class"; final URL baseUrl = dummy.findResource(thisClassPath); - // Now set up the desired classloader hierarchy. Everything goes into + // Now set up the desired class loader hierarchy. Everything goes into // the parent classpath, but we exclude the custom Log class. // - // We then create a tccl classloader that can see the custom + // We then create a tccl class loader that can see the custom // Log class. Therefore if that class can be found, then the // TCCL must have been used to load it. final PathableClassLoader emptyLoader = new PathableClassLoader(null); @@ -73,7 +73,7 @@ public class TcclEnabledTestCase extends TestCase { parentLoader.useExplicitLoader("junit.", Test.class.getClassLoader()); parentLoader.addLogicalLib("commons-logging"); parentLoader.addLogicalLib("testclasses"); - // hack to ensure that the test classloader can't see + // hack to ensure that the test class loader can't see // the custom MyLogFactoryImpl parentLoader.useExplicitLoader(MY_LOG_PKG + ".", emptyLoader); @@ -113,12 +113,12 @@ public class TcclEnabledTestCase extends TestCase { final ClassLoader tcclLoader = Thread.currentThread().getContextClassLoader(); // the tccl loader should NOT be the same as the loader that loaded this test class. - assertNotSame("tccl not same as test classloader", thisClassLoader, tcclLoader); + assertNotSame("tccl not same as test class loader", thisClassLoader, tcclLoader); // MyLog should not be loadable via parent loader try { final Class clazz = thisClassLoader.loadClass(MY_LOG_IMPL); - fail("Unexpectedly able to load MyLog via test class classloader"); + fail("Unexpectedly able to load MyLog via test class class loader"); assertNotNull(clazz); // silence warnings about unused var } catch (final ClassNotFoundException ex) { // ok, expected @@ -129,7 +129,7 @@ public class TcclEnabledTestCase extends TestCase { final Class clazz = tcclLoader.loadClass(MY_LOG_IMPL); assertNotNull(clazz); } catch (final ClassNotFoundException ex) { - fail("Unexpectedly unable to load MyLog via tccl classloader"); + fail("Unexpectedly unable to load MyLog via tccl class loader"); } } 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 2e5038b..2ca5037 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 @@ -30,7 +30,7 @@ import junit.framework.TestCase; /** * Verify that a commons-logging.properties file can prevent a custom - * LogFactoryImpl being loaded from the tccl classloader. + * LogFactoryImpl being loaded from the tccl class loader. */ public class TcclDisabledTestCase extends TestCase { @@ -61,11 +61,11 @@ public class TcclDisabledTestCase extends TestCase { final String thisClassPath = thisClass.getName().replace('.', '/') + ".class"; final URL baseUrl = dummy.findResource(thisClassPath); - // Now set up the desired classloader hierarchy. Everything goes into + // Now set up the desired class loader hierarchy. Everything goes into // the parent classpath, but we exclude the custom LogFactoryImpl // class. // - // We then create a tccl classloader that can see the custom + // We then create a tccl class loader that can see the custom // LogFactory class. Therefore if that class can be found, then the // TCCL must have been used to load it. final PathableClassLoader emptyLoader = new PathableClassLoader(null); @@ -74,7 +74,7 @@ public class TcclDisabledTestCase extends TestCase { parentLoader.useExplicitLoader("junit.", Test.class.getClassLoader()); parentLoader.addLogicalLib("commons-logging"); parentLoader.addLogicalLib("testclasses"); - // hack to ensure that the test classloader can't see + // hack to ensure that the test class loader can't see // the custom MyLogFactoryImpl parentLoader.useExplicitLoader( MY_LOG_FACTORY_PKG + ".", emptyLoader); @@ -115,12 +115,12 @@ public class TcclDisabledTestCase extends TestCase { final ClassLoader tcclLoader = Thread.currentThread().getContextClassLoader(); // the tccl loader should NOT be the same as the loader that loaded this test class. - assertNotSame("tccl not same as test classloader", thisClassLoader, tcclLoader); + assertNotSame("tccl not same as test class loader", thisClassLoader, tcclLoader); // MyLogFactoryImpl should not be loadable via parent loader try { final Class clazz = thisClassLoader.loadClass(MY_LOG_FACTORY_IMPL); - fail("Unexpectedly able to load MyLogFactoryImpl via test class classloader"); + fail("Unexpectedly able to load MyLogFactoryImpl via test class class loader"); assertNotNull(clazz); // silence warning about unused var } catch (final ClassNotFoundException ex) { // ok, expected @@ -131,7 +131,7 @@ public class TcclDisabledTestCase extends TestCase { final Class clazz = tcclLoader.loadClass(MY_LOG_FACTORY_IMPL); assertNotNull(clazz); } catch (final ClassNotFoundException ex) { - fail("Unexpectedly unable to load MyLogFactoryImpl via tccl classloader"); + fail("Unexpectedly unable to load MyLogFactoryImpl via tccl class loader"); } } 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 999f74b..7d29d1c 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 @@ -30,7 +30,7 @@ import junit.framework.TestCase; /** * Verify that by default a custom LogFactoryImpl is loaded from the - * tccl classloader. + * tccl class loader. */ public class TcclEnabledTestCase extends TestCase { @@ -55,11 +55,11 @@ public class TcclEnabledTestCase extends TestCase { final String thisClassPath = thisClass.getName().replace('.', '/') + ".class"; final URL baseUrl = dummy.findResource(thisClassPath); - // Now set up the desired classloader hierarchy. Everything goes into + // Now set up the desired class loader hierarchy. Everything goes into // the parent classpath, but we exclude the custom LogFactoryImpl // class. // - // We then create a tccl classloader that can see the custom + // We then create a tccl class loader that can see the custom // LogFactory class. Therefore if that class can be found, then the // TCCL must have been used to load it. final PathableClassLoader emptyLoader = new PathableClassLoader(null); @@ -68,7 +68,7 @@ public class TcclEnabledTestCase extends TestCase { parentLoader.useExplicitLoader("junit.", Test.class.getClassLoader()); parentLoader.addLogicalLib("commons-logging"); parentLoader.addLogicalLib("testclasses"); - // hack to ensure that the test classloader can't see + // hack to ensure that the test class loader can't see // the cust MyLogFactoryImpl parentLoader.useExplicitLoader( "org.apache.commons.logging.tccl.custom.", emptyLoader); @@ -109,13 +109,13 @@ public class TcclEnabledTestCase extends TestCase { final ClassLoader tcclLoader = Thread.currentThread().getContextClassLoader(); // the tccl loader should NOT be the same as the loader that loaded this test class. - assertNotSame("tccl not same as test classloader", thisClassLoader, tcclLoader); + assertNotSame("tccl not same as test class loader", thisClassLoader, tcclLoader); // MyLogFactoryImpl should not be loadable via parent loader try { final Class clazz = thisClassLoader.loadClass( "org.apache.commons.logging.tccl.custom.MyLogFactoryImpl"); - fail("Unexpectedly able to load MyLogFactoryImpl via test class classloader"); + fail("Unexpectedly able to load MyLogFactoryImpl via test class class loader"); assertNotNull(clazz); // silence warning about unused var } catch (final ClassNotFoundException ex) { // ok, expected @@ -127,7 +127,7 @@ public class TcclEnabledTestCase extends TestCase { "org.apache.commons.logging.tccl.custom.MyLogFactoryImpl"); assertNotNull(clazz); } catch (final ClassNotFoundException ex) { - fail("Unexpectedly unable to load MyLogFactoryImpl via tccl classloader"); + fail("Unexpectedly unable to load MyLogFactoryImpl via tccl class loader"); } }