diff --git a/src/main/java/org/apache/commons/logging/LogConfigurationException.java b/src/main/java/org/apache/commons/logging/LogConfigurationException.java
index bc81dc9..93529a8 100644
--- a/src/main/java/org/apache/commons/logging/LogConfigurationException.java
+++ b/src/main/java/org/apache/commons/logging/LogConfigurationException.java
@@ -40,7 +40,7 @@ public class LogConfigurationException extends RuntimeException {
*
* @param message The detail message
*/
- public LogConfigurationException(String message) {
+ public LogConfigurationException(final String message) {
super(message);
}
@@ -50,7 +50,7 @@ public class LogConfigurationException extends RuntimeException {
*
* @param cause The underlying cause
*/
- public LogConfigurationException(Throwable cause) {
+ public LogConfigurationException(final Throwable cause) {
this(cause == null ? null : cause.toString(), cause);
}
@@ -60,7 +60,7 @@ public class LogConfigurationException extends RuntimeException {
* @param message The detail message
* @param cause The underlying cause
*/
- public LogConfigurationException(String message, Throwable cause) {
+ public LogConfigurationException(final String message, final Throwable cause) {
super(message + " (Caused by " + cause + ")");
this.cause = cause; // Two-argument version requires JDK 1.4 or later
}
diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java
index 1aa28bc..54ab126 100644
--- a/src/main/java/org/apache/commons/logging/LogFactory.java
+++ b/src/main/java/org/apache/commons/logging/LogFactory.java
@@ -318,7 +318,7 @@ public abstract class LogFactory {
String storeImplementationClass;
try {
storeImplementationClass = getSystemProperty(HASHTABLE_IMPLEMENTATION_PROPERTY, null);
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
// Permissions don't allow this to be accessed. Default to the "modern"
// weak hashtable implementation if it is available.
storeImplementationClass = null;
@@ -328,9 +328,9 @@ public abstract class LogFactory {
storeImplementationClass = WEAK_HASHTABLE_CLASSNAME;
}
try {
- Class implementationClass = Class.forName(storeImplementationClass);
+ final Class implementationClass = Class.forName(storeImplementationClass);
result = (Hashtable) implementationClass.newInstance();
- } catch (Throwable t) {
+ } catch (final Throwable t) {
handleThrowable(t); // may re-throw t
// ignore
@@ -355,7 +355,7 @@ public abstract class LogFactory {
// --------------------------------------------------------- Static Methods
/** Utility method to safely trim a string. */
- private static String trim(String src) {
+ private static String trim(final String src) {
if (src == null) {
return null;
}
@@ -374,7 +374,7 @@ public abstract class LogFactory {
*
* @param t the Throwable to check
*/
- protected static void handleThrowable(Throwable t) {
+ protected static void handleThrowable(final Throwable t) {
if (t instanceof ThreadDeath) {
throw (ThreadDeath) t;
}
@@ -416,7 +416,7 @@ public abstract class LogFactory {
*/
public static LogFactory getFactory() throws LogConfigurationException {
// Identify the class loader we will be using
- ClassLoader contextClassLoader = getContextClassLoaderInternal();
+ final ClassLoader contextClassLoader = getContextClassLoaderInternal();
if (contextClassLoader == null) {
// This is an odd enough situation to report about. This
@@ -450,13 +450,13 @@ public abstract class LogFactory {
// As the properties file (if it exists) will be used one way or
// another in the end we may as well look for it first.
- Properties props = getConfigurationFile(contextClassLoader, FACTORY_PROPERTIES);
+ final Properties props = getConfigurationFile(contextClassLoader, FACTORY_PROPERTIES);
// Determine whether we will be using the thread context class loader to
// load logging classes or not by checking the loaded properties file (if any).
ClassLoader baseClassLoader = contextClassLoader;
if (props != null) {
- String useTCCLStr = props.getProperty(TCCL_KEY);
+ final String useTCCLStr = props.getProperty(TCCL_KEY);
if (useTCCLStr != null) {
// The Boolean.valueOf(useTCCLStr).booleanValue() formulation
// is required for Java 1.2 compatibility.
@@ -481,7 +481,7 @@ public abstract class LogFactory {
}
try {
- String factoryClass = getSystemProperty(FACTORY_PROPERTY, null);
+ final String factoryClass = getSystemProperty(FACTORY_PROPERTY, null);
if (factoryClass != null) {
if (isDiagnosticsEnabled()) {
logDiagnostic("[LOOKUP] Creating an instance of LogFactory class '" + factoryClass +
@@ -493,14 +493,14 @@ public abstract class LogFactory {
logDiagnostic("[LOOKUP] No system property [" + FACTORY_PROPERTY + "] defined.");
}
}
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
if (isDiagnosticsEnabled()) {
logDiagnostic("[LOOKUP] A security exception occurred while trying to create an" +
" instance of the custom factory class" + ": [" + trim(e.getMessage()) +
"]. Trying alternative implementations...");
}
// ignore
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
// This is not consistent with the behavior when a bad LogFactory class is
// specified in a services file.
//
@@ -535,7 +535,7 @@ public abstract class LogFactory {
BufferedReader rd;
try {
rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- } catch (java.io.UnsupportedEncodingException e) {
+ } catch (final java.io.UnsupportedEncodingException e) {
rd = new BufferedReader(new InputStreamReader(is));
}
@@ -561,7 +561,7 @@ public abstract class LogFactory {
logDiagnostic("[LOOKUP] No resource file with name '" + SERVICE_ID + "' found.");
}
}
- } catch (Exception ex) {
+ } catch (final Exception ex) {
// note: if the specified LogFactory class wasn't compatible with LogFactory
// for some reason, a ClassCastException will be caught here, and attempts will
// continue to find a compatible class.
@@ -585,7 +585,7 @@ public abstract class LogFactory {
"[LOOKUP] Looking in properties file for entry with key '" + FACTORY_PROPERTY +
"' to define the LogFactory subclass to use...");
}
- String factoryClass = props.getProperty(FACTORY_PROPERTY);
+ final String factoryClass = props.getProperty(FACTORY_PROPERTY);
if (factoryClass != null) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
@@ -635,10 +635,10 @@ public abstract class LogFactory {
cacheFactory(contextClassLoader, factory);
if (props != null) {
- Enumeration names = props.propertyNames();
+ final Enumeration names = props.propertyNames();
while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
- String value = props.getProperty(name);
+ final String name = (String) names.nextElement();
+ final String value = props.getProperty(name);
factory.setAttribute(name, value);
}
}
@@ -655,7 +655,7 @@ public abstract class LogFactory {
* @throws LogConfigurationException if a suitable Log
* instance cannot be returned
*/
- public static Log getLog(Class clazz) throws LogConfigurationException {
+ public static Log getLog(final Class clazz) throws LogConfigurationException {
return getFactory().getInstance(clazz);
}
@@ -669,7 +669,7 @@ public abstract class LogFactory {
* @throws LogConfigurationException if a suitable Log
* instance cannot be returned
*/
- public static Log getLog(String name) throws LogConfigurationException {
+ public static Log getLog(final String name) throws LogConfigurationException {
return getFactory().getInstance(name);
}
@@ -681,7 +681,7 @@ public abstract class LogFactory {
*
* @param classLoader ClassLoader for which to release the LogFactory
*/
- public static void release(ClassLoader classLoader) {
+ public static void release(final ClassLoader classLoader) {
if (isDiagnosticsEnabled()) {
logDiagnostic("Releasing factory for classloader " + objectId(classLoader));
}
@@ -720,7 +720,7 @@ public abstract class LogFactory {
synchronized (factories) {
final Enumeration elements = factories.elements();
while (elements.hasMoreElements()) {
- LogFactory element = (LogFactory) elements.nextElement();
+ final LogFactory element = (LogFactory) elements.nextElement();
element.release();
}
factories.clear();
@@ -761,10 +761,10 @@ public abstract class LogFactory {
*
* @since 1.1
*/
- protected static ClassLoader getClassLoader(Class clazz) {
+ protected static ClassLoader getClassLoader(final Class clazz) {
try {
return clazz.getClassLoader();
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to get classloader for class '" + clazz +
"' due to security restrictions - " + ex.getMessage());
@@ -842,7 +842,7 @@ public abstract class LogFactory {
try {
classLoader = Thread.currentThread().getContextClassLoader();
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
/**
* getContextClassLoader() throws SecurityException when
* the context class loader isn't an ancestor of the
@@ -873,7 +873,7 @@ public abstract class LogFactory {
* one has previously been created, or null if this is the first time
* we have seen this particular classloader.
*/
- private static LogFactory getCachedFactory(ClassLoader contextClassLoader) {
+ private static LogFactory getCachedFactory(final ClassLoader contextClassLoader) {
if (contextClassLoader == null) {
// We have to handle this specially, as factories is a Hashtable
// and those don't accept null as a key value.
@@ -894,7 +894,7 @@ public abstract class LogFactory {
* this can be null under some circumstances; this is ok.
* @param factory should be the factory to cache. This should never be null.
*/
- private static void cacheFactory(ClassLoader classLoader, LogFactory factory) {
+ private static void cacheFactory(final ClassLoader classLoader, final LogFactory factory) {
// Ideally we would assert(factory != null) here. However reporting
// errors from within a logging implementation is a little tricky!
@@ -958,7 +958,7 @@ public abstract class LogFactory {
// Note that any unchecked exceptions thrown by the createFactory
// method will propagate out of this method; in particular a
// ClassCastException can be thrown.
- Object result = AccessController.doPrivileged(
+ final Object result = AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
return createFactory(factoryClass, classLoader);
@@ -966,7 +966,7 @@ public abstract class LogFactory {
});
if (result instanceof LogConfigurationException) {
- LogConfigurationException ex = (LogConfigurationException) result;
+ final LogConfigurationException ex = (LogConfigurationException) result;
if (isDiagnosticsEnabled()) {
logDiagnostic("An error occurred while loading the factory class:" + ex.getMessage());
}
@@ -1010,7 +1010,7 @@ public abstract class LogFactory {
* @return either a LogFactory object or a LogConfigurationException object.
* @since 1.1
*/
- protected static Object createFactory(String factoryClass, ClassLoader classLoader) {
+ protected static Object createFactory(final String factoryClass, final ClassLoader classLoader) {
// This will be used to diagnose bad configurations
// and allow a useful message to be sent to the user
Class logFactoryClass = null;
@@ -1050,7 +1050,7 @@ public abstract class LogFactory {
return (LogFactory) logFactoryClass.newInstance();
- } catch (ClassNotFoundException ex) {
+ } catch (final ClassNotFoundException ex) {
if (classLoader == thisClassLoader) {
// Nothing more to try, onwards.
if (isDiagnosticsEnabled()) {
@@ -1060,7 +1060,7 @@ public abstract class LogFactory {
throw ex;
}
// ignore exception, continue
- } catch (NoClassDefFoundError e) {
+ } catch (final NoClassDefFoundError e) {
if (classLoader == thisClassLoader) {
// Nothing more to try, onwards.
if (isDiagnosticsEnabled()) {
@@ -1071,7 +1071,7 @@ public abstract class LogFactory {
throw e;
}
// ignore exception, continue
- } catch (ClassCastException e) {
+ } catch (final ClassCastException e) {
if (classLoader == thisClassLoader) {
// There's no point in falling through to the code below that
// tries again with thisClassLoader, because we've just tried
@@ -1149,7 +1149,7 @@ public abstract class LogFactory {
}
logFactoryClass = Class.forName(factoryClass);
return (LogFactory) logFactoryClass.newInstance();
- } catch (Exception e) {
+ } catch (final Exception e) {
// Check to see if we've got a bad configuration
if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to create LogFactory instance.");
@@ -1175,16 +1175,16 @@ public abstract class LogFactory {
* LogFactory when that class is loaded via the same
* classloader that loaded the logFactoryClass.
*/
- private static boolean implementsLogFactory(Class logFactoryClass) {
+ private static boolean implementsLogFactory(final Class logFactoryClass) {
boolean implementsLogFactory = false;
if (logFactoryClass != null) {
try {
- ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader();
+ final ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader();
if (logFactoryClassLoader == null) {
logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader");
} else {
logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader);
- Class factoryFromCustomLoader
+ final Class factoryFromCustomLoader
= Class.forName("org.apache.commons.logging.LogFactory", false, logFactoryClassLoader);
implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass);
if (implementsLogFactory) {
@@ -1195,7 +1195,7 @@ public abstract class LogFactory {
" does not implement LogFactory.");
}
}
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
//
// The application is running within a hostile security environment.
// This will make it very hard to diagnose issues with JCL.
@@ -1203,7 +1203,7 @@ public abstract class LogFactory {
//
logDiagnostic("[CUSTOM LOG FACTORY] SecurityException thrown whilst trying to determine whether " +
"the compatibility was caused by a classloader conflict: " + e.getMessage());
- } catch (LinkageError e) {
+ } catch (final LinkageError e) {
//
// This should be an unusual circumstance.
// LinkageError's usually indicate that a dependent class has incompatibly changed.
@@ -1212,7 +1212,7 @@ public abstract class LogFactory {
//
logDiagnostic("[CUSTOM LOG FACTORY] LinkageError thrown whilst trying to determine whether " +
"the compatibility was caused by a classloader conflict: " + e.getMessage());
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
//
// LogFactory cannot be loaded by the classloader which loaded the custom factory implementation.
// The custom implementation is not viable until this is corrected.
@@ -1260,7 +1260,7 @@ public abstract class LogFactory {
* If resources could not be listed for some reason, null is returned.
*/
private static Enumeration getResources(final ClassLoader loader, final String name) {
- PrivilegedAction action =
+ final PrivilegedAction action =
new PrivilegedAction() {
public Object run() {
try {
@@ -1269,13 +1269,13 @@ public abstract class LogFactory {
} else {
return ClassLoader.getSystemResources(name);
}
- } catch (IOException e) {
+ } catch (final IOException e) {
if (isDiagnosticsEnabled()) {
logDiagnostic("Exception while trying to find configuration file " +
name + ":" + e.getMessage());
}
return null;
- } catch (NoSuchMethodError e) {
+ } catch (final NoSuchMethodError e) {
// we must be running on a 1.1 JVM which doesn't support
// ClassLoader.getSystemResources; just return null in
// this case.
@@ -1283,7 +1283,7 @@ public abstract class LogFactory {
}
}
};
- Object result = AccessController.doPrivileged(action);
+ final Object result = AccessController.doPrivileged(action);
return (Enumeration) result;
}
@@ -1296,7 +1296,7 @@ public abstract class LogFactory {
* {@code Null} is returned if the URL cannot be opened.
*/
private static Properties getProperties(final URL url) {
- PrivilegedAction action =
+ final PrivilegedAction action =
new PrivilegedAction() {
public Object run() {
InputStream stream = null;
@@ -1304,17 +1304,17 @@ public abstract class LogFactory {
// We must ensure that useCaches is set to false, as the
// default behavior of java is to cache file handles, and
// this "locks" files, preventing hot-redeploy on windows.
- URLConnection connection = url.openConnection();
+ final URLConnection connection = url.openConnection();
connection.setUseCaches(false);
stream = connection.getInputStream();
if (stream != null) {
- Properties props = new Properties();
+ final Properties props = new Properties();
props.load(stream);
stream.close();
stream = null;
return props;
}
- } catch (IOException e) {
+ } catch (final IOException e) {
if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to read URL " + url);
}
@@ -1322,7 +1322,7 @@ public abstract class LogFactory {
if (stream != null) {
try {
stream.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
// ignore exception; this should not happen
if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to close stream for URL " + url);
@@ -1356,26 +1356,26 @@ public abstract class LogFactory {
* webapps. Webapps can also use explicit priorities to override a configuration
* file in the shared classpath if needed.
*/
- private static final Properties getConfigurationFile(ClassLoader classLoader, String fileName) {
+ private static final Properties getConfigurationFile(final ClassLoader classLoader, final String fileName) {
Properties props = null;
double priority = 0.0;
URL propsUrl = null;
try {
- Enumeration urls = getResources(classLoader, fileName);
+ final Enumeration urls = getResources(classLoader, fileName);
if (urls == null) {
return null;
}
while (urls.hasMoreElements()) {
- URL url = (URL) urls.nextElement();
+ final URL url = (URL) urls.nextElement();
- Properties newProps = getProperties(url);
+ final Properties newProps = getProperties(url);
if (newProps != null) {
if (props == null) {
propsUrl = url;
props = newProps;
- String priorityStr = props.getProperty(PRIORITY_KEY);
+ final String priorityStr = props.getProperty(PRIORITY_KEY);
priority = 0.0;
if (priorityStr != null) {
priority = Double.parseDouble(priorityStr);
@@ -1386,7 +1386,7 @@ public abstract class LogFactory {
" with priority " + priority);
}
} else {
- String newPriorityStr = newProps.getProperty(PRIORITY_KEY);
+ final String newPriorityStr = newProps.getProperty(PRIORITY_KEY);
double newPriority = 0.0;
if (newPriorityStr != null) {
newPriority = Double.parseDouble(newPriorityStr);
@@ -1415,7 +1415,7 @@ public abstract class LogFactory {
}
}
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
if (isDiagnosticsEnabled()) {
logDiagnostic("SecurityException thrown while trying to find/read config files.");
}
@@ -1464,7 +1464,7 @@ public abstract class LogFactory {
if (dest == null) {
return null;
}
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
// We must be running in some very secure environment.
// We just have to assume output is not wanted..
return null;
@@ -1477,9 +1477,9 @@ public abstract class LogFactory {
} else {
try {
// open the file in append mode
- FileOutputStream fos = new FileOutputStream(dest, true);
+ final FileOutputStream fos = new FileOutputStream(dest, true);
return new PrintStream(fos);
- } catch (IOException ex) {
+ } catch (final IOException ex) {
// We should report this to the user - but how?
return null;
}
@@ -1517,7 +1517,7 @@ public abstract class LogFactory {
*
* @param msg is the diagnostic message to be output.
*/
- private static final void logDiagnostic(String msg) {
+ private static final void logDiagnostic(final String msg) {
if (diagnosticsStream != null) {
diagnosticsStream.print(diagnosticPrefix);
diagnosticsStream.println(msg);
@@ -1531,7 +1531,7 @@ public abstract class LogFactory {
* @param msg is the diagnostic message to be output.
* @since 1.1
*/
- protected static final void logRawDiagnostic(String msg) {
+ protected static final void logRawDiagnostic(final String msg) {
if (diagnosticsStream != null) {
diagnosticsStream.println(msg);
diagnosticsStream.flush();
@@ -1555,7 +1555,7 @@ public abstract class LogFactory {
* @param clazz is the class whose classloader + tree are to be
* output.
*/
- private static void logClassLoaderEnvironment(Class clazz) {
+ private static void logClassLoaderEnvironment(final Class clazz) {
if (!isDiagnosticsEnabled()) {
return;
}
@@ -1566,16 +1566,16 @@ public abstract class LogFactory {
// these variables then we do not want to output them to the diagnostic stream.
logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir"));
logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path"));
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths.");
}
- String className = clazz.getName();
+ final String className = clazz.getName();
ClassLoader classLoader;
try {
classLoader = getClassLoader(clazz);
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
// not much useful diagnostics we can print here!
logDiagnostic("[ENV] Security forbids determining the classloader for " + className);
return;
@@ -1592,7 +1592,7 @@ public abstract class LogFactory {
* @param prefix
* @param classLoader
*/
- private static void logHierarchy(String prefix, ClassLoader classLoader) {
+ private static void logHierarchy(final String prefix, ClassLoader classLoader) {
if (!isDiagnosticsEnabled()) {
return;
}
@@ -1604,7 +1604,7 @@ public abstract class LogFactory {
try {
systemClassLoader = ClassLoader.getSystemClassLoader();
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
logDiagnostic(prefix + "Security forbids determining the system classloader.");
return;
}
@@ -1618,7 +1618,7 @@ public abstract class LogFactory {
try {
classLoader = classLoader.getParent();
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
buf.append(" --> SECRET");
break;
}
@@ -1645,7 +1645,7 @@ public abstract class LogFactory {
* @return a string of form classname@hashcode, or "null" if param o is null.
* @since 1.1
*/
- public static String objectId(Object o) {
+ public static String objectId(final Object o) {
if (o == null) {
return "null";
} else {
@@ -1687,13 +1687,13 @@ public abstract class LogFactory {
// output diagnostics from this class are static.
String classLoaderName;
try {
- ClassLoader classLoader = thisClassLoader;
+ final ClassLoader classLoader = thisClassLoader;
if (thisClassLoader == null) {
classLoaderName = "BOOTLOADER";
} else {
classLoaderName = objectId(classLoader);
}
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
classLoaderName = "UNKNOWN";
}
diagnosticPrefix = "[LogFactory from " + classLoaderName + "] ";
diff --git a/src/main/java/org/apache/commons/logging/LogSource.java b/src/main/java/org/apache/commons/logging/LogSource.java
index eb4fff4..66ce281 100644
--- a/src/main/java/org/apache/commons/logging/LogSource.java
+++ b/src/main/java/org/apache/commons/logging/LogSource.java
@@ -74,7 +74,7 @@ public class LogSource {
// Is Log4J Available?
try {
log4jIsAvailable = null != Class.forName("org.apache.log4j.Logger");
- } catch (Throwable t) {
+ } catch (final Throwable t) {
log4jIsAvailable = false;
}
@@ -82,7 +82,7 @@ public class LogSource {
try {
jdk14IsAvailable = null != Class.forName("java.util.logging.Logger") &&
null != Class.forName("org.apache.commons.logging.impl.Jdk14Logger");
- } catch (Throwable t) {
+ } catch (final Throwable t) {
jdk14IsAvailable = false;
}
@@ -93,15 +93,15 @@ public class LogSource {
if (name == null) {
name = System.getProperty("org.apache.commons.logging.Log");
}
- } catch (Throwable t) {
+ } catch (final Throwable t) {
}
if (name != null) {
try {
setLogImplementation(name);
- } catch (Throwable t) {
+ } catch (final Throwable t) {
try {
setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
- } catch (Throwable u) {
+ } catch (final Throwable u) {
// ignored
}
}
@@ -114,10 +114,10 @@ public class LogSource {
} else {
setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
}
- } catch (Throwable t) {
+ } catch (final Throwable t) {
try {
setLogImplementation("org.apache.commons.logging.impl.NoOpLog");
- } catch (Throwable u) {
+ } catch (final Throwable u) {
// ignored
}
}
@@ -139,14 +139,14 @@ public class LogSource {
* and provide a constructor that takes a single {@link String} argument
* (containing the name of the log).
*/
- static public void setLogImplementation(String classname)
+ static public void setLogImplementation(final String classname)
throws LinkageError, NoSuchMethodException, SecurityException, ClassNotFoundException {
try {
- Class logclass = Class.forName(classname);
- Class[] argtypes = new Class[1];
+ final Class logclass = Class.forName(classname);
+ final Class[] argtypes = new Class[1];
argtypes[0] = "".getClass();
logImplctor = logclass.getConstructor(argtypes);
- } catch (Throwable t) {
+ } catch (final Throwable t) {
logImplctor = null;
}
}
@@ -156,15 +156,15 @@ public class LogSource {
* The given class must implement {@link Log}, and provide a constructor
* that takes a single {@link String} argument (containing the name of the log).
*/
- static public void setLogImplementation(Class logclass)
+ static public void setLogImplementation(final Class logclass)
throws LinkageError, ExceptionInInitializerError, NoSuchMethodException, SecurityException {
- Class[] argtypes = new Class[1];
+ final Class[] argtypes = new Class[1];
argtypes[0] = "".getClass();
logImplctor = logclass.getConstructor(argtypes);
}
/** Get a Log instance by class name. */
- static public Log getInstance(String name) {
+ static public Log getInstance(final String name) {
Log log = (Log) logs.get(name);
if (null == log) {
log = makeNewLogInstance(name);
@@ -174,7 +174,7 @@ public class LogSource {
}
/** Get a Log instance by class. */
- static public Log getInstance(Class clazz) {
+ static public Log getInstance(final Class clazz) {
return getInstance(clazz.getName());
}
@@ -195,12 +195,12 @@ public class LogSource {
*
* @param name the log name (or category)
*/
- static public Log makeNewLogInstance(String name) {
+ static public Log makeNewLogInstance(final String name) {
Log log;
try {
- Object[] args = { name };
+ final Object[] args = { name };
log = (Log) logImplctor.newInstance(args);
- } catch (Throwable t) {
+ } catch (final Throwable t) {
log = null;
}
if (null == log) {
diff --git a/src/main/java/org/apache/commons/logging/impl/AvalonLogger.java b/src/main/java/org/apache/commons/logging/impl/AvalonLogger.java
index 77bf13d..65f61a3 100644
--- a/src/main/java/org/apache/commons/logging/impl/AvalonLogger.java
+++ b/src/main/java/org/apache/commons/logging/impl/AvalonLogger.java
@@ -63,7 +63,7 @@ public class AvalonLogger implements Log {
*
* @param logger the Avalon logger implementation to delegate to
*/
- public AvalonLogger(Logger logger) {
+ public AvalonLogger(final Logger logger) {
this.logger = logger;
}
@@ -73,7 +73,7 @@ public class AvalonLogger implements Log {
*
* @param name the name of the avalon logger implementation to delegate to
*/
- public AvalonLogger(String name) {
+ public AvalonLogger(final String name) {
if (defaultLogger == null) {
throw new NullPointerException("default logger has to be specified if this constructor is used!");
}
@@ -95,7 +95,7 @@ public class AvalonLogger implements Log {
* @param logger the default avalon logger,
* in case there is no logger instance supplied in constructor
*/
- public static void setDefaultLogger(Logger logger) {
+ public static void setDefaultLogger(final Logger logger) {
defaultLogger = logger;
}
@@ -106,7 +106,7 @@ public class AvalonLogger implements Log {
* @param t log this cause
* @see org.apache.commons.logging.Log#debug(Object, Throwable)
*/
- public void debug(Object message, Throwable t) {
+ public void debug(final Object message, final Throwable t) {
if (getLogger().isDebugEnabled()) {
getLogger().debug(String.valueOf(message), t);
}
@@ -118,7 +118,7 @@ public class AvalonLogger implements Log {
* @param message to log.
* @see org.apache.commons.logging.Log#debug(Object)
*/
- public void debug(Object message) {
+ public void debug(final Object message) {
if (getLogger().isDebugEnabled()) {
getLogger().debug(String.valueOf(message));
}
@@ -131,7 +131,7 @@ public class AvalonLogger implements Log {
* @param t log this cause
* @see org.apache.commons.logging.Log#error(Object, Throwable)
*/
- public void error(Object message, Throwable t) {
+ public void error(final Object message, final Throwable t) {
if (getLogger().isErrorEnabled()) {
getLogger().error(String.valueOf(message), t);
}
@@ -143,7 +143,7 @@ public class AvalonLogger implements Log {
* @param message to log
* @see org.apache.commons.logging.Log#error(Object)
*/
- public void error(Object message) {
+ public void error(final Object message) {
if (getLogger().isErrorEnabled()) {
getLogger().error(String.valueOf(message));
}
@@ -156,7 +156,7 @@ public class AvalonLogger implements Log {
* @param t log this cause.
* @see org.apache.commons.logging.Log#fatal(Object, Throwable)
*/
- public void fatal(Object message, Throwable t) {
+ public void fatal(final Object message, final Throwable t) {
if (getLogger().isFatalErrorEnabled()) {
getLogger().fatalError(String.valueOf(message), t);
}
@@ -168,7 +168,7 @@ public class AvalonLogger implements Log {
* @param message to log
* @see org.apache.commons.logging.Log#fatal(Object)
*/
- public void fatal(Object message) {
+ public void fatal(final Object message) {
if (getLogger().isFatalErrorEnabled()) {
getLogger().fatalError(String.valueOf(message));
}
@@ -181,7 +181,7 @@ public class AvalonLogger implements Log {
* @param t log this cause
* @see org.apache.commons.logging.Log#info(Object, Throwable)
*/
- public void info(Object message, Throwable t) {
+ public void info(final Object message, final Throwable t) {
if (getLogger().isInfoEnabled()) {
getLogger().info(String.valueOf(message), t);
}
@@ -193,7 +193,7 @@ public class AvalonLogger implements Log {
* @param message to log
* @see org.apache.commons.logging.Log#info(Object)
*/
- public void info(Object message) {
+ public void info(final Object message) {
if (getLogger().isInfoEnabled()) {
getLogger().info(String.valueOf(message));
}
@@ -254,7 +254,7 @@ public class AvalonLogger implements Log {
* @param t log this cause.
* @see org.apache.commons.logging.Log#trace(Object, Throwable)
*/
- public void trace(Object message, Throwable t) {
+ public void trace(final Object message, final Throwable t) {
if (getLogger().isDebugEnabled()) {
getLogger().debug(String.valueOf(message), t);
}
@@ -266,7 +266,7 @@ public class AvalonLogger implements Log {
* @param message to log
* @see org.apache.commons.logging.Log#trace(Object)
*/
- public void trace(Object message) {
+ public void trace(final Object message) {
if (getLogger().isDebugEnabled()) {
getLogger().debug(String.valueOf(message));
}
@@ -279,7 +279,7 @@ public class AvalonLogger implements Log {
* @param t log this cause
* @see org.apache.commons.logging.Log#warn(Object, Throwable)
*/
- public void warn(Object message, Throwable t) {
+ public void warn(final Object message, final Throwable t) {
if (getLogger().isWarnEnabled()) {
getLogger().warn(String.valueOf(message), t);
}
@@ -291,7 +291,7 @@ public class AvalonLogger implements Log {
* @param message to log
* @see org.apache.commons.logging.Log#warn(Object)
*/
- public void warn(Object message) {
+ public void warn(final Object message) {
if (getLogger().isWarnEnabled()) {
getLogger().warn(String.valueOf(message));
}
diff --git a/src/main/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java b/src/main/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java
index c7b73de..5635d1c 100644
--- a/src/main/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java
+++ b/src/main/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java
@@ -66,16 +66,16 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
*
* @param name Name of the logger to be constructed
*/
- public Jdk13LumberjackLogger(String name) {
+ public Jdk13LumberjackLogger(final String name) {
this.name = name;
logger = getLogger();
}
// --------------------------------------------------------- Public Methods
- private void log( Level level, String msg, Throwable ex ) {
+ private void log( final Level level, final String msg, final Throwable ex ) {
if( getLogger().isLoggable(level) ) {
- LogRecord record = new LogRecord(level, msg);
+ final LogRecord record = new LogRecord(level, msg);
if( !classAndMethodFound ) {
getClassAndMethod();
}
@@ -94,13 +94,13 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
*/
private void getClassAndMethod() {
try {
- Throwable throwable = new Throwable();
+ final Throwable throwable = new Throwable();
throwable.fillInStackTrace();
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter( stringWriter );
+ final StringWriter stringWriter = new StringWriter();
+ final PrintWriter printWriter = new PrintWriter( stringWriter );
throwable.printStackTrace( printWriter );
- String traceString = stringWriter.getBuffer().toString();
- StringTokenizer tokenizer =
+ final String traceString = stringWriter.getBuffer().toString();
+ final StringTokenizer tokenizer =
new StringTokenizer( traceString, "\n" );
tokenizer.nextToken();
String line = tokenizer.nextToken();
@@ -110,13 +110,13 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
while ( line.indexOf( this.getClass().getName() ) >= 0 ) {
line = tokenizer.nextToken();
}
- int start = line.indexOf( "at " ) + 3;
- int end = line.indexOf( '(' );
- String temp = line.substring( start, end );
- int lastPeriod = temp.lastIndexOf( '.' );
+ final int start = line.indexOf( "at " ) + 3;
+ final int end = line.indexOf( '(' );
+ final String temp = line.substring( start, end );
+ final int lastPeriod = temp.lastIndexOf( '.' );
sourceClassName = temp.substring( 0, lastPeriod );
sourceMethodName = temp.substring( lastPeriod + 1 );
- } catch ( Exception ex ) {
+ } catch ( final Exception ex ) {
// ignore - leave class and methodname unknown
}
classAndMethodFound = true;
@@ -128,7 +128,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#debug(Object)
*/
- public void debug(Object message) {
+ public void debug(final Object message) {
log(Level.FINE, String.valueOf(message), null);
}
@@ -139,7 +139,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#debug(Object, Throwable)
*/
- public void debug(Object message, Throwable exception) {
+ public void debug(final Object message, final Throwable exception) {
log(Level.FINE, String.valueOf(message), exception);
}
@@ -149,7 +149,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#error(Object)
*/
- public void error(Object message) {
+ public void error(final Object message) {
log(Level.SEVERE, String.valueOf(message), null);
}
@@ -160,7 +160,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#error(Object, Throwable)
*/
- public void error(Object message, Throwable exception) {
+ public void error(final Object message, final Throwable exception) {
log(Level.SEVERE, String.valueOf(message), exception);
}
@@ -170,7 +170,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#fatal(Object)
*/
- public void fatal(Object message) {
+ public void fatal(final Object message) {
log(Level.SEVERE, String.valueOf(message), null);
}
@@ -181,7 +181,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#fatal(Object, Throwable)
*/
- public void fatal(Object message, Throwable exception) {
+ public void fatal(final Object message, final Throwable exception) {
log(Level.SEVERE, String.valueOf(message), exception);
}
@@ -201,7 +201,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#info(Object)
*/
- public void info(Object message) {
+ public void info(final Object message) {
log(Level.INFO, String.valueOf(message), null);
}
@@ -212,7 +212,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#info(Object, Throwable)
*/
- public void info(Object message, Throwable exception) {
+ public void info(final Object message, final Throwable exception) {
log(Level.INFO, String.valueOf(message), exception);
}
@@ -264,7 +264,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#trace(Object)
*/
- public void trace(Object message) {
+ public void trace(final Object message) {
log(Level.FINEST, String.valueOf(message), null);
}
@@ -275,7 +275,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#trace(Object, Throwable)
*/
- public void trace(Object message, Throwable exception) {
+ public void trace(final Object message, final Throwable exception) {
log(Level.FINEST, String.valueOf(message), exception);
}
@@ -285,7 +285,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#warn(Object)
*/
- public void warn(Object message) {
+ public void warn(final Object message) {
log(Level.WARNING, String.valueOf(message), null);
}
@@ -296,7 +296,7 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#warn(Object, Throwable)
*/
- public void warn(Object message, Throwable exception) {
+ public void warn(final Object message, final Throwable exception) {
log(Level.WARNING, String.valueOf(message), exception);
}
}
diff --git a/src/main/java/org/apache/commons/logging/impl/Jdk14Logger.java b/src/main/java/org/apache/commons/logging/impl/Jdk14Logger.java
index 8b0791a..a596030 100644
--- a/src/main/java/org/apache/commons/logging/impl/Jdk14Logger.java
+++ b/src/main/java/org/apache/commons/logging/impl/Jdk14Logger.java
@@ -50,7 +50,7 @@ public class Jdk14Logger implements Log, Serializable {
*
* @param name Name of the logger to be constructed
*/
- public Jdk14Logger(String name) {
+ public Jdk14Logger(final String name) {
this.name = name;
logger = getLogger();
}
@@ -69,18 +69,18 @@ public class Jdk14Logger implements Log, Serializable {
// --------------------------------------------------------- Protected Methods
- protected void log( Level level, String msg, Throwable ex ) {
- Logger logger = getLogger();
+ protected void log( final Level level, final String msg, final Throwable ex ) {
+ final Logger logger = getLogger();
if (logger.isLoggable(level)) {
// Hack (?) to get the stack trace.
- Throwable dummyException = new Throwable();
- StackTraceElement locations[] = dummyException.getStackTrace();
+ final Throwable dummyException = new Throwable();
+ final StackTraceElement locations[] = dummyException.getStackTrace();
// LOGGING-132: use the provided logger name instead of the class name
- String cname = name;
+ final String cname = name;
String method = "unknown";
// Caller will be the third element
if( locations != null && locations.length > 2 ) {
- StackTraceElement caller = locations[2];
+ final StackTraceElement caller = locations[2];
method = caller.getMethodName();
}
if( ex == null ) {
@@ -99,7 +99,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#debug(Object)
*/
- public void debug(Object message) {
+ public void debug(final Object message) {
log(Level.FINE, String.valueOf(message), null);
}
@@ -110,7 +110,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#debug(Object, Throwable)
*/
- public void debug(Object message, Throwable exception) {
+ public void debug(final Object message, final Throwable exception) {
log(Level.FINE, String.valueOf(message), exception);
}
@@ -120,7 +120,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#error(Object)
*/
- public void error(Object message) {
+ public void error(final Object message) {
log(Level.SEVERE, String.valueOf(message), null);
}
@@ -131,7 +131,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#error(Object, Throwable)
*/
- public void error(Object message, Throwable exception) {
+ public void error(final Object message, final Throwable exception) {
log(Level.SEVERE, String.valueOf(message), exception);
}
@@ -141,7 +141,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#fatal(Object)
*/
- public void fatal(Object message) {
+ public void fatal(final Object message) {
log(Level.SEVERE, String.valueOf(message), null);
}
@@ -152,7 +152,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#fatal(Object, Throwable)
*/
- public void fatal(Object message, Throwable exception) {
+ public void fatal(final Object message, final Throwable exception) {
log(Level.SEVERE, String.valueOf(message), exception);
}
@@ -172,7 +172,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#info(Object)
*/
- public void info(Object message) {
+ public void info(final Object message) {
log(Level.INFO, String.valueOf(message), null);
}
@@ -183,7 +183,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#info(Object, Throwable)
*/
- public void info(Object message, Throwable exception) {
+ public void info(final Object message, final Throwable exception) {
log(Level.INFO, String.valueOf(message), exception);
}
@@ -235,7 +235,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#trace(Object)
*/
- public void trace(Object message) {
+ public void trace(final Object message) {
log(Level.FINEST, String.valueOf(message), null);
}
@@ -246,7 +246,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#trace(Object, Throwable)
*/
- public void trace(Object message, Throwable exception) {
+ public void trace(final Object message, final Throwable exception) {
log(Level.FINEST, String.valueOf(message), exception);
}
@@ -256,7 +256,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#warn(Object)
*/
- public void warn(Object message) {
+ public void warn(final Object message) {
log(Level.WARNING, String.valueOf(message), null);
}
@@ -267,7 +267,7 @@ public class Jdk14Logger implements Log, Serializable {
* @param exception log this cause
* @see org.apache.commons.logging.Log#warn(Object, Throwable)
*/
- public void warn(Object message, Throwable exception) {
+ public void warn(final Object message, final Throwable exception) {
log(Level.WARNING, String.valueOf(message), exception);
}
}
diff --git a/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java b/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java
index ae46536..77897c0 100644
--- a/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java
+++ b/src/main/java/org/apache/commons/logging/impl/Log4JLogger.java
@@ -87,7 +87,7 @@ public class Log4JLogger implements Log, Serializable {
Priority _traceLevel;
try {
_traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
- } catch(Exception ex) {
+ } catch(final Exception ex) {
// ok, trace not available
_traceLevel = Level.DEBUG;
}
@@ -103,7 +103,7 @@ public class Log4JLogger implements Log, Serializable {
/**
* Base constructor.
*/
- public Log4JLogger(String name) {
+ public Log4JLogger(final String name) {
this.name = name;
this.logger = getLogger();
}
@@ -111,7 +111,7 @@ public class Log4JLogger implements Log, Serializable {
/**
* For use with a log4j factory.
*/
- public Log4JLogger(Logger logger) {
+ public Log4JLogger(final Logger logger) {
if (logger == null) {
throw new IllegalArgumentException(
"Warning - null logger in constructor; possible log4j misconfiguration.");
@@ -128,7 +128,7 @@ public class Log4JLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#trace(Object)
*/
- public void trace(Object message) {
+ public void trace(final Object message) {
getLogger().log(FQCN, traceLevel, message, null);
}
@@ -141,7 +141,7 @@ public class Log4JLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#trace(Object, Throwable)
*/
- public void trace(Object message, Throwable t) {
+ public void trace(final Object message, final Throwable t) {
getLogger().log(FQCN, traceLevel, message, t);
}
@@ -151,7 +151,7 @@ public class Log4JLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#debug(Object)
*/
- public void debug(Object message) {
+ public void debug(final Object message) {
getLogger().log(FQCN, Level.DEBUG, message, null);
}
@@ -162,7 +162,7 @@ public class Log4JLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#debug(Object, Throwable)
*/
- public void debug(Object message, Throwable t) {
+ public void debug(final Object message, final Throwable t) {
getLogger().log(FQCN, Level.DEBUG, message, t);
}
@@ -172,7 +172,7 @@ public class Log4JLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#info(Object)
*/
- public void info(Object message) {
+ public void info(final Object message) {
getLogger().log(FQCN, Level.INFO, message, null);
}
@@ -183,7 +183,7 @@ public class Log4JLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#info(Object, Throwable)
*/
- public void info(Object message, Throwable t) {
+ public void info(final Object message, final Throwable t) {
getLogger().log(FQCN, Level.INFO, message, t);
}
@@ -193,7 +193,7 @@ public class Log4JLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#warn(Object)
*/
- public void warn(Object message) {
+ public void warn(final Object message) {
getLogger().log(FQCN, Level.WARN, message, null);
}
@@ -204,7 +204,7 @@ public class Log4JLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#warn(Object, Throwable)
*/
- public void warn(Object message, Throwable t) {
+ public void warn(final Object message, final Throwable t) {
getLogger().log(FQCN, Level.WARN, message, t);
}
@@ -214,7 +214,7 @@ public class Log4JLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#error(Object)
*/
- public void error(Object message) {
+ public void error(final Object message) {
getLogger().log(FQCN, Level.ERROR, message, null);
}
@@ -225,7 +225,7 @@ public class Log4JLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#error(Object, Throwable)
*/
- public void error(Object message, Throwable t) {
+ public void error(final Object message, final Throwable t) {
getLogger().log(FQCN, Level.ERROR, message, t);
}
@@ -235,7 +235,7 @@ public class Log4JLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#fatal(Object)
*/
- public void fatal(Object message) {
+ public void fatal(final Object message) {
getLogger().log(FQCN, Level.FATAL, message, null);
}
@@ -246,7 +246,7 @@ public class Log4JLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#fatal(Object, Throwable)
*/
- public void fatal(Object message, Throwable t) {
+ public void fatal(final Object message, final Throwable t) {
getLogger().log(FQCN, Level.FATAL, message, t);
}
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 ed77202..3582d03 100644
--- a/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
+++ b/src/main/java/org/apache/commons/logging/impl/LogFactoryImpl.java
@@ -242,7 +242,7 @@ public class LogFactoryImpl extends LogFactory {
*
* @param name Name of the attribute to return
*/
- public Object getAttribute(String name) {
+ public Object getAttribute(final String name) {
return attributes.get(name);
}
@@ -264,7 +264,7 @@ public class LogFactoryImpl extends LogFactory {
* @throws LogConfigurationException if a suitable Log
* instance cannot be returned
*/
- public Log getInstance(Class clazz) throws LogConfigurationException {
+ public Log getInstance(final Class clazz) throws LogConfigurationException {
return getInstance(clazz.getName());
}
@@ -285,7 +285,7 @@ public class LogFactoryImpl extends LogFactory {
* @throws LogConfigurationException if a suitable Log
* instance cannot be returned
*/
- public Log getInstance(String name) throws LogConfigurationException {
+ public Log getInstance(final String name) throws LogConfigurationException {
Log instance = (Log) instances.get(name);
if (instance == null) {
instance = newInstance(name);
@@ -314,7 +314,7 @@ public class LogFactoryImpl extends LogFactory {
*
* @param name Name of the attribute to remove
*/
- public void removeAttribute(String name) {
+ public void removeAttribute(final String name) {
attributes.remove(name);
}
@@ -342,7 +342,7 @@ public class LogFactoryImpl extends LogFactory {
* @param value Value of the attribute to set, or null
* to remove any setting for this attribute
*/
- public void setAttribute(String name, Object value) {
+ public void setAttribute(final String name, final Object value) {
if (logConstructor != null) {
logDiagnostic("setAttribute: call too late; configuration already performed.");
}
@@ -387,7 +387,7 @@ public class LogFactoryImpl extends LogFactory {
* See LogFactory.getClassLoader.
* @since 1.1
*/
- protected static ClassLoader getClassLoader(Class clazz) {
+ protected static ClassLoader getClassLoader(final Class clazz) {
return LogFactory.getClassLoader(clazz);
}
@@ -415,8 +415,8 @@ public class LogFactoryImpl extends LogFactory {
// the context it is intended to manage.
// Note that this prefix should be kept consistent with that
// in LogFactory.
- Class clazz = this.getClass();
- ClassLoader classLoader = getClassLoader(clazz);
+ final Class clazz = this.getClass();
+ final ClassLoader classLoader = getClassLoader(clazz);
String classLoaderName;
try {
if (classLoader == null) {
@@ -424,7 +424,7 @@ public class LogFactoryImpl extends LogFactory {
} else {
classLoaderName = objectId(classLoader);
}
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
classLoaderName = "UNKNOWN";
}
diagnosticPrefix = "[LogFactoryImpl@" + System.identityHashCode(this) + " from " + classLoaderName + "] ";
@@ -437,7 +437,7 @@ public class LogFactoryImpl extends LogFactory {
* @param msg diagnostic message
* @since 1.1
*/
- protected void logDiagnostic(String msg) {
+ protected void logDiagnostic(final String msg) {
if (isDiagnosticsEnabled()) {
logRawDiagnostic(diagnosticPrefix + msg);
}
@@ -533,37 +533,37 @@ public class LogFactoryImpl extends LogFactory {
* @throws LogConfigurationException if a new instance cannot
* be created
*/
- protected Log newInstance(String name) throws LogConfigurationException {
+ protected Log newInstance(final String name) throws LogConfigurationException {
Log instance;
try {
if (logConstructor == null) {
instance = discoverLogImplementation(name);
}
else {
- Object params[] = { name };
+ final Object params[] = { name };
instance = (Log) logConstructor.newInstance(params);
}
if (logMethod != null) {
- Object params[] = { this };
+ final Object params[] = { this };
logMethod.invoke(instance, params);
}
return instance;
- } catch (LogConfigurationException lce) {
+ } catch (final LogConfigurationException lce) {
// this type of exception means there was a problem in discovery
// and we've already output diagnostics about the issue, etc.;
// just pass it on
throw lce;
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
// A problem occurred invoking the Constructor or Method
// previously discovered
- Throwable c = e.getTargetException();
+ final Throwable c = e.getTargetException();
throw new LogConfigurationException(c == null ? e : c);
- } catch (Throwable t) {
+ } catch (final Throwable t) {
handleThrowable(t); // may re-throw t
// A problem occurred invoking the Constructor or Method
// previously discovered
@@ -635,7 +635,7 @@ public class LogFactoryImpl extends LogFactory {
return cl.getParent();
}
});
- } catch (SecurityException ex) {
+ } catch (final SecurityException ex) {
logDiagnostic("[SECURITY] Unable to obtain parent classloader");
return null;
}
@@ -647,12 +647,12 @@ public class LogFactoryImpl extends LogFactory {
* present and available for use. Note that this does not
* affect the future behavior of this class.
*/
- private boolean isLogLibraryAvailable(String name, String classname) {
+ private boolean isLogLibraryAvailable(final String name, final String classname) {
if (isDiagnosticsEnabled()) {
logDiagnostic("Checking for '" + name + "'.");
}
try {
- Log log = createLogFromClass(
+ final Log log = createLogFromClass(
classname,
this.getClass().getName(), // dummy category
false);
@@ -668,7 +668,7 @@ public class LogFactoryImpl extends LogFactory {
}
return true;
}
- } catch (LogConfigurationException e) {
+ } catch (final LogConfigurationException e) {
if (isDiagnosticsEnabled()) {
logDiagnostic("Logging system '" + name + "' is available but not useable.");
}
@@ -687,12 +687,12 @@ public class LogFactoryImpl extends LogFactory {
*
* @return the value associated with the property, or null.
*/
- private String getConfigurationValue(String property) {
+ private String getConfigurationValue(final String property) {
if (isDiagnosticsEnabled()) {
logDiagnostic("[ENV] Trying to get configuration for item " + property);
}
- Object valueObj = getAttribute(property);
+ final Object valueObj = getAttribute(property);
if (valueObj != null) {
if (isDiagnosticsEnabled()) {
logDiagnostic("[ENV] Found LogFactory attribute [" + valueObj + "] for " + property);
@@ -709,7 +709,7 @@ public class LogFactoryImpl extends LogFactory {
// property that the caller cannot, then output it in readable form as a
// diagnostic message. However it's only ever JCL-specific properties
// involved here, so the harm is truly trivial.
- String value = getSystemProperty(property, null);
+ final String value = getSystemProperty(property, null);
if (value != null) {
if (isDiagnosticsEnabled()) {
logDiagnostic("[ENV] Found system property [" + value + "] for " + property);
@@ -720,7 +720,7 @@ public class LogFactoryImpl extends LogFactory {
if (isDiagnosticsEnabled()) {
logDiagnostic("[ENV] No system property found for property " + property);
}
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
if (isDiagnosticsEnabled()) {
logDiagnostic("[ENV] Security prevented reading system property " + property);
}
@@ -737,8 +737,8 @@ public class LogFactoryImpl extends LogFactory {
* Get the setting for the user-configurable behavior specified by key.
* If nothing has explicitly been set, then return dflt.
*/
- private boolean getBooleanConfiguration(String key, boolean dflt) {
- String val = getConfigurationValue(key);
+ private boolean getBooleanConfiguration(final String key, final boolean dflt) {
+ final String val = getConfigurationValue(key);
if (val == null) {
return dflt;
}
@@ -767,7 +767,7 @@ public class LogFactoryImpl extends LogFactory {
* @throws LogConfigurationException if an error in discovery occurs,
* or if no adapter at all can be instantiated
*/
- private Log discoverLogImplementation(String logCategory)
+ private Log discoverLogImplementation(final String logCategory)
throws LogConfigurationException {
if (isDiagnosticsEnabled()) {
logDiagnostic("Discovering a Log implementation...");
@@ -778,7 +778,7 @@ public class LogFactoryImpl extends LogFactory {
Log result = null;
// See if the user specified the Log implementation to use
- String specifiedLogClassName = findUserSpecifiedLogClassName();
+ final String specifiedLogClassName = findUserSpecifiedLogClassName();
if (specifiedLogClassName != null) {
if (isDiagnosticsEnabled()) {
@@ -790,7 +790,7 @@ public class LogFactoryImpl extends LogFactory {
logCategory,
true);
if (result == null) {
- StringBuffer messageBuffer = new StringBuffer("User-specified log class '");
+ final StringBuffer messageBuffer = new StringBuffer("User-specified log class '");
messageBuffer.append(specifiedLogClassName);
messageBuffer.append("' cannot be found or is not useable.");
@@ -904,7 +904,7 @@ public class LogFactoryImpl extends LogFactory {
}
try {
specifiedClass = getSystemProperty(LOG_PROPERTY, null);
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
if (isDiagnosticsEnabled()) {
logDiagnostic("No access allowed to system property '" +
LOG_PROPERTY + "' - " + e.getMessage());
@@ -919,7 +919,7 @@ public class LogFactoryImpl extends LogFactory {
}
try {
specifiedClass = getSystemProperty(LOG_PROPERTY_OLD, null);
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
if (isDiagnosticsEnabled()) {
logDiagnostic("No access allowed to system property '" +
LOG_PROPERTY_OLD + "' - " + e.getMessage());
@@ -951,16 +951,16 @@ public class LogFactoryImpl extends LogFactory {
* configuration and the handleFlawedDiscovery method decided this
* problem was fatal.
*/
- private Log createLogFromClass(String logAdapterClassName,
- String logCategory,
- boolean affectState)
+ private Log createLogFromClass(final String logAdapterClassName,
+ final String logCategory,
+ final boolean affectState)
throws LogConfigurationException {
if (isDiagnosticsEnabled()) {
logDiagnostic("Attempting to instantiate '" + logAdapterClassName + "'");
}
- Object[] params = { logCategory };
+ final Object[] params = { logCategory };
Log logAdapter = null;
Constructor constructor = null;
@@ -978,7 +978,7 @@ public class LogFactoryImpl extends LogFactory {
// will load the class from -- unless the classloader is doing
// something weird.
URL url;
- String resourceName = logAdapterClassName.replace('.', '/') + ".class";
+ final String resourceName = logAdapterClassName.replace('.', '/') + ".class";
if (currentCL != null) {
url = currentCL.getResource(resourceName );
} else {
@@ -995,7 +995,7 @@ public class LogFactoryImpl extends LogFactory {
Class c;
try {
c = Class.forName(logAdapterClassName, true, currentCL);
- } catch (ClassNotFoundException originalClassNotFoundException) {
+ } 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
// trying higher up in the hierarchy in this case..
@@ -1011,7 +1011,7 @@ public class LogFactoryImpl extends LogFactory {
// Java 1.2 classloading guidelines but JCL can
// and so should handle this case.
c = Class.forName(logAdapterClassName);
- } catch (ClassNotFoundException secondaryClassNotFoundException) {
+ } catch (final ClassNotFoundException secondaryClassNotFoundException) {
// no point continuing: this adapter isn't available
msg = secondaryClassNotFoundException.getMessage();
logDiagnostic("The log adapter '" + logAdapterClassName +
@@ -1021,7 +1021,7 @@ public class LogFactoryImpl extends LogFactory {
}
constructor = c.getConstructor(logConstructorSignature);
- Object o = constructor.newInstance(params);
+ final Object o = constructor.newInstance(params);
// Note that we do this test after trying to create an instance
// [rather than testing Log.class.isAssignableFrom(c)] so that
@@ -1044,34 +1044,34 @@ public class LogFactoryImpl extends LogFactory {
// LogConfigurationException if it regards this problem as
// fatal, and just return if not.
handleFlawedHierarchy(currentCL, c);
- } catch (NoClassDefFoundError e) {
+ } catch (final NoClassDefFoundError e) {
// We were able to load the adapter but it had references to
// other classes that could not be found. This simply means that
// the underlying logger library is not present in this or any
// ancestor classloader. There's no point in trying higher up
// in the hierarchy in this case..
- String msg = e.getMessage();
+ final String msg = e.getMessage();
logDiagnostic("The log adapter '" + logAdapterClassName +
"' is missing dependencies when loaded via classloader " + objectId(currentCL) +
": " + msg.trim());
break;
- } catch (ExceptionInInitializerError e) {
+ } catch (final ExceptionInInitializerError e) {
// A static initializer block or the initializer code associated
// with a static variable on the log adapter class has thrown
// an exception.
//
// We treat this as meaning the adapter's underlying logging
// library could not be found.
- String msg = e.getMessage();
+ final String msg = e.getMessage();
logDiagnostic("The log adapter '" + logAdapterClassName +
"' is unable to initialize itself when loaded via classloader " + objectId(currentCL) +
": " + msg.trim());
break;
- } catch (LogConfigurationException e) {
+ } catch (final LogConfigurationException e) {
// call to handleFlawedHierarchy above must have thrown
// a LogConfigurationException, so just throw it on
throw e;
- } catch (Throwable t) {
+ } catch (final Throwable t) {
handleThrowable(t); // may re-throw t
// handleFlawedDiscovery will determine whether this is a fatal
// problem or not. If it is fatal, then a LogConfigurationException
@@ -1097,7 +1097,7 @@ public class LogFactoryImpl extends LogFactory {
try {
this.logMethod = logAdapterClass.getMethod("setLogFactory", logMethodSignature);
logDiagnostic("Found method setLogFactory(LogFactory) in '" + logAdapterClassName + "'");
- } catch (Throwable t) {
+ } catch (final Throwable t) {
handleThrowable(t); // may re-throw t
this.logMethod = null;
logDiagnostic("[INFO] '" + logAdapterClassName + "' from classloader " + objectId(currentCL) +
@@ -1130,15 +1130,15 @@ public class LogFactoryImpl extends LogFactory {
*
*/
private ClassLoader getBaseClassLoader() throws LogConfigurationException {
- ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.class);
+ final ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.class);
if (!useTCCL) {
return thisClassLoader;
}
- ClassLoader contextClassLoader = getContextClassLoaderInternal();
+ final ClassLoader contextClassLoader = getContextClassLoaderInternal();
- ClassLoader baseClassLoader = getLowestClassLoader(
+ final ClassLoader baseClassLoader = getLowestClassLoader(
contextClassLoader, thisClassLoader);
if (baseClassLoader == null) {
@@ -1200,7 +1200,7 @@ public class LogFactoryImpl extends LogFactory {
* @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.
*/
- private ClassLoader getLowestClassLoader(ClassLoader c1, ClassLoader c2) {
+ private ClassLoader getLowestClassLoader(final ClassLoader c1, final ClassLoader c2) {
// TODO: use AccessController when dealing with classloaders here
if (c1 == null) {
@@ -1251,9 +1251,9 @@ public class LogFactoryImpl extends LogFactory {
*
* @throws LogConfigurationException ALWAYS
*/
- private void handleFlawedDiscovery(String logAdapterClassName,
- ClassLoader classLoader, // USED?
- Throwable discoveryFlaw) {
+ private void handleFlawedDiscovery(final String logAdapterClassName,
+ final ClassLoader classLoader, // USED?
+ final Throwable discoveryFlaw) {
if (isDiagnosticsEnabled()) {
logDiagnostic("Could not instantiate Log '" +
@@ -1265,16 +1265,16 @@ public class LogFactoryImpl extends LogFactory {
// Ok, the lib is there but while trying to create a real underlying
// logger something failed in the underlying lib; display info about
// that if possible.
- InvocationTargetException ite = (InvocationTargetException)discoveryFlaw;
- Throwable cause = ite.getTargetException();
+ final InvocationTargetException ite = (InvocationTargetException)discoveryFlaw;
+ final Throwable cause = ite.getTargetException();
if (cause != null) {
logDiagnostic("... InvocationTargetException: " +
cause.getClass().getName() + ": " +
cause.getLocalizedMessage());
if (cause instanceof ExceptionInInitializerError) {
- ExceptionInInitializerError eiie = (ExceptionInInitializerError)cause;
- Throwable cause2 = eiie.getException();
+ final ExceptionInInitializerError eiie = (ExceptionInInitializerError)cause;
+ final Throwable cause2 = eiie.getException();
if (cause2 != null) {
final StringWriter sw = new StringWriter();
cause2.printStackTrace(new PrintWriter(sw, true));
@@ -1316,12 +1316,12 @@ public class LogFactoryImpl extends LogFactory {
* @throws LogConfigurationException when the situation
* should not be recovered from.
*/
- private void handleFlawedHierarchy(ClassLoader badClassLoader, Class badClass)
+ private void handleFlawedHierarchy(final ClassLoader badClassLoader, final Class badClass)
throws LogConfigurationException {
boolean implementsLog = false;
- String logInterfaceName = Log.class.getName();
- Class interfaces[] = badClass.getInterfaces();
+ final String logInterfaceName = Log.class.getName();
+ final Class interfaces[] = badClass.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
if (logInterfaceName.equals(interfaces[i].getName())) {
implementsLog = true;
@@ -1334,18 +1334,18 @@ public class LogFactoryImpl extends LogFactory {
// it is in the wrong classloader
if (isDiagnosticsEnabled()) {
try {
- ClassLoader logInterfaceClassLoader = getClassLoader(Log.class);
+ final ClassLoader logInterfaceClassLoader = getClassLoader(Log.class);
logDiagnostic("Class '" + badClass.getName() + "' was found in classloader " +
objectId(badClassLoader) + ". It is bound to a Log interface which is not" +
" the one loaded from classloader " + objectId(logInterfaceClassLoader));
- } catch (Throwable t) {
+ } catch (final Throwable t) {
handleThrowable(t); // may re-throw t
logDiagnostic("Error while trying to output diagnostics about" + " bad class '" + badClass + "'");
}
}
if (!allowFlawedHierarchy) {
- StringBuffer msg = new StringBuffer();
+ final StringBuffer msg = new StringBuffer();
msg.append("Terminating logging for this context ");
msg.append("due to bad log hierarchy. ");
msg.append("You have more than one version of '");
@@ -1358,7 +1358,7 @@ public class LogFactoryImpl extends LogFactory {
}
if (isDiagnosticsEnabled()) {
- StringBuffer msg = new StringBuffer();
+ final StringBuffer msg = new StringBuffer();
msg.append("Warning: bad log hierarchy. ");
msg.append("You have more than one version of '");
msg.append(Log.class.getName());
@@ -1368,7 +1368,7 @@ public class LogFactoryImpl extends LogFactory {
} else {
// this is just a bad adapter class
if (!allowFlawedDiscovery) {
- StringBuffer msg = new StringBuffer();
+ final StringBuffer msg = new StringBuffer();
msg.append("Terminating logging for this context. ");
msg.append("Log class '");
msg.append(badClass.getName());
@@ -1381,7 +1381,7 @@ public class LogFactoryImpl extends LogFactory {
}
if (isDiagnosticsEnabled()) {
- StringBuffer msg = new StringBuffer();
+ final StringBuffer msg = new StringBuffer();
msg.append("[WARNING] Log class '");
msg.append(badClass.getName());
msg.append("' does not implement the Log interface.");
diff --git a/src/main/java/org/apache/commons/logging/impl/LogKitLogger.java b/src/main/java/org/apache/commons/logging/impl/LogKitLogger.java
index b0c13b4..aa5c13a 100644
--- a/src/main/java/org/apache/commons/logging/impl/LogKitLogger.java
+++ b/src/main/java/org/apache/commons/logging/impl/LogKitLogger.java
@@ -54,7 +54,7 @@ public class LogKitLogger implements Log, Serializable {
*
* @param name log name
*/
- public LogKitLogger(String name) {
+ public LogKitLogger(final String name) {
this.name = name;
this.logger = getLogger();
}
@@ -85,7 +85,7 @@ public class LogKitLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#trace(Object)
*/
- public void trace(Object message) {
+ public void trace(final Object message) {
debug(message);
}
@@ -96,7 +96,7 @@ public class LogKitLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#trace(Object, Throwable)
*/
- public void trace(Object message, Throwable t) {
+ public void trace(final Object message, final Throwable t) {
debug(message, t);
}
@@ -106,7 +106,7 @@ public class LogKitLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#debug(Object)
*/
- public void debug(Object message) {
+ public void debug(final Object message) {
if (message != null) {
getLogger().debug(String.valueOf(message));
}
@@ -119,7 +119,7 @@ public class LogKitLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#debug(Object, Throwable)
*/
- public void debug(Object message, Throwable t) {
+ public void debug(final Object message, final Throwable t) {
if (message != null) {
getLogger().debug(String.valueOf(message), t);
}
@@ -131,7 +131,7 @@ public class LogKitLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#info(Object)
*/
- public void info(Object message) {
+ public void info(final Object message) {
if (message != null) {
getLogger().info(String.valueOf(message));
}
@@ -144,7 +144,7 @@ public class LogKitLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#info(Object, Throwable)
*/
- public void info(Object message, Throwable t) {
+ public void info(final Object message, final Throwable t) {
if (message != null) {
getLogger().info(String.valueOf(message), t);
}
@@ -156,7 +156,7 @@ public class LogKitLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#warn(Object)
*/
- public void warn(Object message) {
+ public void warn(final Object message) {
if (message != null) {
getLogger().warn(String.valueOf(message));
}
@@ -169,7 +169,7 @@ public class LogKitLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#warn(Object, Throwable)
*/
- public void warn(Object message, Throwable t) {
+ public void warn(final Object message, final Throwable t) {
if (message != null) {
getLogger().warn(String.valueOf(message), t);
}
@@ -181,7 +181,7 @@ public class LogKitLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#error(Object)
*/
- public void error(Object message) {
+ public void error(final Object message) {
if (message != null) {
getLogger().error(String.valueOf(message));
}
@@ -194,7 +194,7 @@ public class LogKitLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#error(Object, Throwable)
*/
- public void error(Object message, Throwable t) {
+ public void error(final Object message, final Throwable t) {
if (message != null) {
getLogger().error(String.valueOf(message), t);
}
@@ -206,7 +206,7 @@ public class LogKitLogger implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#fatal(Object)
*/
- public void fatal(Object message) {
+ public void fatal(final Object message) {
if (message != null) {
getLogger().fatalError(String.valueOf(message));
}
@@ -219,7 +219,7 @@ public class LogKitLogger implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#fatal(Object, Throwable)
*/
- public void fatal(Object message, Throwable t) {
+ public void fatal(final Object message, final Throwable t) {
if (message != null) {
getLogger().fatalError(String.valueOf(message), t);
}
diff --git a/src/main/java/org/apache/commons/logging/impl/NoOpLog.java b/src/main/java/org/apache/commons/logging/impl/NoOpLog.java
index bdafc87..33c739e 100644
--- a/src/main/java/org/apache/commons/logging/impl/NoOpLog.java
+++ b/src/main/java/org/apache/commons/logging/impl/NoOpLog.java
@@ -34,31 +34,31 @@ public class NoOpLog implements Log, Serializable {
/** Convenience constructor */
public NoOpLog() { }
/** Base constructor */
- public NoOpLog(String name) { }
+ public NoOpLog(final String name) { }
/** Do nothing */
- public void trace(Object message) { }
+ public void trace(final Object message) { }
/** Do nothing */
- public void trace(Object message, Throwable t) { }
+ public void trace(final Object message, final Throwable t) { }
/** Do nothing */
- public void debug(Object message) { }
+ public void debug(final Object message) { }
/** Do nothing */
- public void debug(Object message, Throwable t) { }
+ public void debug(final Object message, final Throwable t) { }
/** Do nothing */
- public void info(Object message) { }
+ public void info(final Object message) { }
/** Do nothing */
- public void info(Object message, Throwable t) { }
+ public void info(final Object message, final Throwable t) { }
/** Do nothing */
- public void warn(Object message) { }
+ public void warn(final Object message) { }
/** Do nothing */
- public void warn(Object message, Throwable t) { }
+ public void warn(final Object message, final Throwable t) { }
/** Do nothing */
- public void error(Object message) { }
+ public void error(final Object message) { }
/** Do nothing */
- public void error(Object message, Throwable t) { }
+ public void error(final Object message, final Throwable t) { }
/** Do nothing */
- public void fatal(Object message) { }
+ public void fatal(final Object message) { }
/** Do nothing */
- public void fatal(Object message, Throwable t) { }
+ public void fatal(final Object message, final Throwable t) { }
/**
* Debug is never enabled.
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 b6f5d3b..6a19dba 100644
--- a/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java
+++ b/src/main/java/org/apache/commons/logging/impl/ServletContextCleaner.java
@@ -56,10 +56,10 @@ public class ServletContextCleaner implements ServletContextListener {
* class to release any logging information related to the current
* contextClassloader.
*/
- public void contextDestroyed(ServletContextEvent sce) {
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ public void contextDestroyed(final ServletContextEvent sce) {
+ final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- Object[] params = new Object[1];
+ final Object[] params = new Object[1];
params[0] = tccl;
// Walk up the tree of classloaders, finding all the available
@@ -98,23 +98,23 @@ public class ServletContextCleaner implements ServletContextListener {
// via this loader, but is accessible via some ancestor then that class
// will be returned.
try {
- Class logFactoryClass = loader.loadClass("org.apache.commons.logging.LogFactory");
- Method releaseMethod = logFactoryClass.getMethod("release", RELEASE_SIGNATURE);
+ final Class logFactoryClass = loader.loadClass("org.apache.commons.logging.LogFactory");
+ final Method releaseMethod = logFactoryClass.getMethod("release", RELEASE_SIGNATURE);
releaseMethod.invoke(null, params);
loader = logFactoryClass.getClassLoader().getParent();
- } catch(ClassNotFoundException ex) {
+ } catch(final ClassNotFoundException ex) {
// Neither the current classloader nor any of its ancestors could find
// the LogFactory class, so we can stop now.
loader = null;
- } catch(NoSuchMethodException ex) {
+ } catch(final NoSuchMethodException ex) {
// This is not expected; every version of JCL has this method
System.err.println("LogFactory instance found which does not support release method!");
loader = null;
- } catch(IllegalAccessException ex) {
+ } catch(final IllegalAccessException ex) {
// This is not expected; every ancestor class should be accessible
System.err.println("LogFactory instance found which is not accessable!");
loader = null;
- } catch(InvocationTargetException ex) {
+ } catch(final InvocationTargetException ex) {
// This is not expected
System.err.println("LogFactory instance release method failed!");
loader = null;
@@ -130,7 +130,7 @@ public class ServletContextCleaner implements ServletContextListener {
/**
* Invoked when a webapp is deployed. Nothing needs to be done here.
*/
- public void contextInitialized(ServletContextEvent sce) {
+ public void contextInitialized(final ServletContextEvent sce) {
// do nothing
}
}
diff --git a/src/main/java/org/apache/commons/logging/impl/SimpleLog.java b/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
index 53f0643..e22fc13 100644
--- a/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
+++ b/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
@@ -133,23 +133,23 @@ public class SimpleLog implements Log, Serializable {
// ------------------------------------------------------------ Initializer
- private static String getStringProperty(String name) {
+ private static String getStringProperty(final String name) {
String prop = null;
try {
prop = System.getProperty(name);
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
// Ignore
}
return prop == null ? simpleLogProps.getProperty(name) : prop;
}
- private static String getStringProperty(String name, String dephault) {
- String prop = getStringProperty(name);
+ private static String getStringProperty(final String name, final String dephault) {
+ final String prop = getStringProperty(name);
return prop == null ? dephault : prop;
}
- private static boolean getBooleanProperty(String name, boolean dephault) {
- String prop = getStringProperty(name);
+ private static boolean getBooleanProperty(final String name, final boolean dephault) {
+ final String prop = getStringProperty(name);
return prop == null ? dephault : "true".equalsIgnoreCase(prop);
}
@@ -158,16 +158,16 @@ public class SimpleLog implements Log, Serializable {
// Override with system properties.
static {
// Add props from the resource simplelog.properties
- InputStream in = getResourceAsStream("simplelog.properties");
+ final InputStream in = getResourceAsStream("simplelog.properties");
if (null != in) {
try {
simpleLogProps.load(in);
- } catch (IOException e) {
+ } catch (final IOException e) {
// ignored
} finally {
try {
in.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
// ignored
}
}
@@ -182,7 +182,7 @@ public class SimpleLog implements Log, Serializable {
dateTimeFormat);
try {
dateFormatter = new SimpleDateFormat(dateTimeFormat);
- } catch(IllegalArgumentException e) {
+ } catch(final IllegalArgumentException e) {
// If the format pattern is invalid - use the default format
dateTimeFormat = DEFAULT_DATE_TIME_FORMAT;
dateFormatter = new SimpleDateFormat(dateTimeFormat);
@@ -253,7 +253,7 @@ public class SimpleLog implements Log, Serializable {
*
* @param currentLogLevel new logging level
*/
- public void setLevel(int currentLogLevel) {
+ public void setLevel(final int currentLogLevel) {
this.currentLogLevel = currentLogLevel;
}
@@ -276,7 +276,7 @@ public class SimpleLog implements Log, Serializable {
* @param message The message itself (typically a String)
* @param t The exception whose stack trace should be logged
*/
- protected void log(int type, Object message, Throwable t) {
+ protected void log(final int type, final Object message, final Throwable t) {
// Use a string buffer for better performance
final StringBuffer buf = new StringBuffer();
@@ -341,7 +341,7 @@ public class SimpleLog implements Log, Serializable {
* @param buffer A StringBuffer containing the accumulated
* text to be logged
*/
- protected void write(StringBuffer buffer) {
+ protected void write(final StringBuffer buffer) {
System.err.println(buffer.toString());
}
@@ -350,7 +350,7 @@ public class SimpleLog implements Log, Serializable {
*
* @param logLevel is this level enabled?
*/
- protected boolean isLevelEnabled(int logLevel) {
+ protected boolean isLevelEnabled(final int logLevel) {
// log level are numerically ordered so can use simple numeric
// comparison
return logLevel >= currentLogLevel;
@@ -365,7 +365,7 @@ public class SimpleLog implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#debug(Object)
*/
- public final void debug(Object message) {
+ public final void debug(final Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
log(SimpleLog.LOG_LEVEL_DEBUG, message, null);
}
@@ -379,7 +379,7 @@ public class SimpleLog implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#debug(Object, Throwable)
*/
- public final void debug(Object message, Throwable t) {
+ public final void debug(final Object message, final Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) {
log(SimpleLog.LOG_LEVEL_DEBUG, message, t);
}
@@ -391,7 +391,7 @@ public class SimpleLog implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#trace(Object)
*/
- public final void trace(Object message) {
+ public final void trace(final Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) {
log(SimpleLog.LOG_LEVEL_TRACE, message, null);
}
@@ -404,7 +404,7 @@ public class SimpleLog implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#trace(Object, Throwable)
*/
- public final void trace(Object message, Throwable t) {
+ public final void trace(final Object message, final Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) {
log(SimpleLog.LOG_LEVEL_TRACE, message, t);
}
@@ -416,7 +416,7 @@ public class SimpleLog implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#info(Object)
*/
- public final void info(Object message) {
+ public final void info(final Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
log(SimpleLog.LOG_LEVEL_INFO,message,null);
}
@@ -429,7 +429,7 @@ public class SimpleLog implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#info(Object, Throwable)
*/
- public final void info(Object message, Throwable t) {
+ public final void info(final Object message, final Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) {
log(SimpleLog.LOG_LEVEL_INFO, message, t);
}
@@ -441,7 +441,7 @@ public class SimpleLog implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#warn(Object)
*/
- public final void warn(Object message) {
+ public final void warn(final Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
log(SimpleLog.LOG_LEVEL_WARN, message, null);
}
@@ -454,7 +454,7 @@ public class SimpleLog implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#warn(Object, Throwable)
*/
- public final void warn(Object message, Throwable t) {
+ public final void warn(final Object message, final Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) {
log(SimpleLog.LOG_LEVEL_WARN, message, t);
}
@@ -466,7 +466,7 @@ public class SimpleLog implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#error(Object)
*/
- public final void error(Object message) {
+ public final void error(final Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
log(SimpleLog.LOG_LEVEL_ERROR, message, null);
}
@@ -479,7 +479,7 @@ public class SimpleLog implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#error(Object, Throwable)
*/
- public final void error(Object message, Throwable t) {
+ public final void error(final Object message, final Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) {
log(SimpleLog.LOG_LEVEL_ERROR, message, t);
}
@@ -491,7 +491,7 @@ public class SimpleLog implements Log, Serializable {
* @param message to log
* @see org.apache.commons.logging.Log#fatal(Object)
*/
- public final void fatal(Object message) {
+ public final void fatal(final Object message) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
log(SimpleLog.LOG_LEVEL_FATAL, message, null);
}
@@ -504,7 +504,7 @@ public class SimpleLog implements Log, Serializable {
* @param t log this cause
* @see org.apache.commons.logging.Log#fatal(Object, Throwable)
*/
- public final void fatal(Object message, Throwable t) {
+ public final void fatal(final Object message, final Throwable t) {
if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) {
log(SimpleLog.LOG_LEVEL_FATAL, message, t);
}
@@ -596,9 +596,9 @@ public class SimpleLog implements Log, Serializable {
// Get the thread context class loader (if there is one)
try {
classLoader = (ClassLoader)method.invoke(Thread.currentThread(), (Class[]) null);
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
// ignore
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
/**
* InvocationTargetException is thrown by 'invoke' when
* the method being invoked (getContextClassLoader) throws
@@ -624,7 +624,7 @@ public class SimpleLog implements Log, Serializable {
("Unexpected InvocationTargetException", e.getTargetException());
}
}
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
// Assume we are running on JDK 1.1
// ignore
}
@@ -641,7 +641,7 @@ public class SimpleLog implements Log, Serializable {
return (InputStream)AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
- ClassLoader threadCL = getContextClassLoader();
+ final ClassLoader threadCL = getContextClassLoader();
if (threadCL != null) {
return threadCL.getResourceAsStream(name);
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 8accbd5..e5ba364 100644
--- a/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java
+++ b/src/main/java/org/apache/commons/logging/impl/WeakHashtable.java
@@ -139,9 +139,9 @@ public final class WeakHashtable extends Hashtable {
/**
*@see Hashtable
*/
- public boolean containsKey(Object key) {
+ public boolean containsKey(final Object key) {
// purge should not be required
- Referenced referenced = new Referenced(key);
+ final Referenced referenced = new Referenced(key);
return super.containsKey(referenced);
}
@@ -158,15 +158,15 @@ public final class WeakHashtable extends Hashtable {
*/
public Set entrySet() {
purge();
- Set referencedEntries = super.entrySet();
- Set unreferencedEntries = new HashSet();
- for (Iterator it=referencedEntries.iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- Referenced referencedKey = (Referenced) entry.getKey();
- Object key = referencedKey.getValue();
- Object value = entry.getValue();
+ final Set referencedEntries = super.entrySet();
+ final Set unreferencedEntries = new HashSet();
+ for (final Iterator it=referencedEntries.iterator(); it.hasNext();) {
+ final Map.Entry entry = (Map.Entry) it.next();
+ final Referenced referencedKey = (Referenced) entry.getKey();
+ final Object key = referencedKey.getValue();
+ final Object value = entry.getValue();
if (key != null) {
- Entry dereferencedEntry = new Entry(key, value);
+ final Entry dereferencedEntry = new Entry(key, value);
unreferencedEntries.add(dereferencedEntry);
}
}
@@ -176,9 +176,9 @@ public final class WeakHashtable extends Hashtable {
/**
*@see Hashtable
*/
- public Object get(Object key) {
+ public Object get(final Object key) {
// for performance reasons, no purge
- Referenced referenceKey = new Referenced(key);
+ final Referenced referenceKey = new Referenced(key);
return super.get(referenceKey);
}
@@ -193,7 +193,7 @@ public final class WeakHashtable extends Hashtable {
return enumer.hasMoreElements();
}
public Object nextElement() {
- Referenced nextReference = (Referenced) enumer.nextElement();
+ final Referenced nextReference = (Referenced) enumer.nextElement();
return nextReference.getValue();
}
};
@@ -204,11 +204,11 @@ public final class WeakHashtable extends Hashtable {
*/
public Set keySet() {
purge();
- Set referencedKeys = super.keySet();
- Set unreferencedKeys = new HashSet();
- for (Iterator it=referencedKeys.iterator(); it.hasNext();) {
- Referenced referenceKey = (Referenced) it.next();
- Object keyValue = referenceKey.getValue();
+ final Set referencedKeys = super.keySet();
+ final Set unreferencedKeys = new HashSet();
+ for (final Iterator it=referencedKeys.iterator(); it.hasNext();) {
+ final Referenced referenceKey = (Referenced) it.next();
+ final Object keyValue = referenceKey.getValue();
if (keyValue != null) {
unreferencedKeys.add(keyValue);
}
@@ -219,7 +219,7 @@ public final class WeakHashtable extends Hashtable {
/**
*@see Hashtable
*/
- public synchronized Object put(Object key, Object value) {
+ public synchronized Object put(final Object key, final Object value) {
// check for nulls, ensuring semantics match superclass
if (key == null) {
throw new NullPointerException("Null keys are not allowed");
@@ -239,18 +239,18 @@ public final class WeakHashtable extends Hashtable {
purgeOne();
}
- Referenced keyRef = new Referenced(key, queue);
+ final Referenced keyRef = new Referenced(key, queue);
return super.put(keyRef, value);
}
/**
*@see Hashtable
*/
- public void putAll(Map t) {
+ public void putAll(final Map t) {
if (t != null) {
- Set entrySet = t.entrySet();
- for (Iterator it=entrySet.iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
+ final Set entrySet = t.entrySet();
+ for (final Iterator it=entrySet.iterator(); it.hasNext();) {
+ final Map.Entry entry = (Map.Entry) it.next();
put(entry.getKey(), entry.getValue());
}
}
@@ -267,7 +267,7 @@ public final class WeakHashtable extends Hashtable {
/**
*@see Hashtable
*/
- public synchronized Object remove(Object key) {
+ public synchronized Object remove(final Object key) {
// for performance reasons, only purge every
// MAX_CHANGES_BEFORE_PURGE times
if (changeCount++ > MAX_CHANGES_BEFORE_PURGE) {
@@ -342,7 +342,7 @@ public final class WeakHashtable extends Hashtable {
*/
private void purgeOne() {
synchronized (queue) {
- WeakKey key = (WeakKey) queue.poll();
+ final WeakKey key = (WeakKey) queue.poll();
if (key != null) {
super.remove(key.getReferenced());
}
@@ -355,15 +355,15 @@ public final class WeakHashtable extends Hashtable {
private final Object key;
private final Object value;
- private Entry(Object key, Object value) {
+ private Entry(final Object key, final Object value) {
this.key = key;
this.value = value;
}
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
boolean result = false;
if (o instanceof Map.Entry) {
- Map.Entry entry = (Map.Entry) o;
+ final Map.Entry entry = (Map.Entry) o;
result = (getKey()==null ?
entry.getKey() == null :
getKey().equals(entry.getKey())) &&
@@ -379,7 +379,7 @@ public final class WeakHashtable extends Hashtable {
(getValue()==null ? 0 : getValue().hashCode());
}
- public Object setValue(Object value) {
+ public Object setValue(final Object value) {
throw new UnsupportedOperationException("Entry.setValue is not supported.");
}
@@ -402,7 +402,7 @@ public final class WeakHashtable extends Hashtable {
*
* @throws NullPointerException if referant is null
*/
- private Referenced(Object referant) {
+ private Referenced(final Object referant) {
reference = new WeakReference(referant);
// Calc a permanent hashCode so calls to Hashtable.remove()
// work if the WeakReference has been cleared
@@ -413,7 +413,7 @@ public final class WeakHashtable extends Hashtable {
*
* @throws NullPointerException if key is null
*/
- private Referenced(Object key, ReferenceQueue queue) {
+ private Referenced(final Object key, final ReferenceQueue queue) {
reference = new WeakKey(key, queue, this);
// Calc a permanent hashCode so calls to Hashtable.remove()
// work if the WeakReference has been cleared
@@ -429,12 +429,12 @@ public final class WeakHashtable extends Hashtable {
return reference.get();
}
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
boolean result = false;
if (o instanceof Referenced) {
- Referenced otherKey = (Referenced) o;
- Object thisKeyValue = getValue();
- Object otherKeyValue = otherKey.getValue();
+ final Referenced otherKey = (Referenced) o;
+ final Object thisKeyValue = getValue();
+ final Object otherKeyValue = otherKey.getValue();
if (thisKeyValue == null) {
result = otherKeyValue == null;
@@ -468,9 +468,9 @@ public final class WeakHashtable extends Hashtable {
private final Referenced referenced;
- private WeakKey(Object key,
- ReferenceQueue queue,
- Referenced referenced) {
+ private WeakKey(final Object key,
+ final ReferenceQueue queue,
+ final Referenced referenced) {
super(key, queue);
this.referenced = referenced;
}
diff --git a/src/test/java/org/apache/commons/logging/AbstractLogTest.java b/src/test/java/org/apache/commons/logging/AbstractLogTest.java
index 706e5b0..3ae0222 100644
--- a/src/test/java/org/apache/commons/logging/AbstractLogTest.java
+++ b/src/test/java/org/apache/commons/logging/AbstractLogTest.java
@@ -33,7 +33,7 @@ public abstract class AbstractLogTest extends TestCase {
public void testLoggingWithNullParameters()
{
- Log log = this.getLogObject();
+ final Log log = this.getLogObject();
assertNotNull(log);
diff --git a/src/test/java/org/apache/commons/logging/AltHashtable.java b/src/test/java/org/apache/commons/logging/AltHashtable.java
index 94c0633..7225ec5 100644
--- a/src/test/java/org/apache/commons/logging/AltHashtable.java
+++ b/src/test/java/org/apache/commons/logging/AltHashtable.java
@@ -29,7 +29,7 @@ public class AltHashtable extends Hashtable {
public static Object lastKey;
public static Object lastValue;
- public Object put(Object key, Object value) {
+ public Object put(final Object key, final Object value) {
lastKey = key;
lastValue = value;
return super.put(key, value);
diff --git a/src/test/java/org/apache/commons/logging/AltHashtableTestCase.java b/src/test/java/org/apache/commons/logging/AltHashtableTestCase.java
index 8c8e01c..652357b 100644
--- a/src/test/java/org/apache/commons/logging/AltHashtableTestCase.java
+++ b/src/test/java/org/apache/commons/logging/AltHashtableTestCase.java
@@ -28,15 +28,15 @@ import junit.framework.TestCase;
public class AltHashtableTestCase extends TestCase {
public static Test suite() throws Exception {
- Class thisClass = AltHashtableTestCase.class;
- ClassLoader thisClassLoader = thisClass.getClassLoader();
+ final Class thisClass = AltHashtableTestCase.class;
+ final ClassLoader thisClassLoader = thisClass.getClassLoader();
- PathableClassLoader loader = new PathableClassLoader(null);
+ final PathableClassLoader loader = new PathableClassLoader(null);
loader.useExplicitLoader("junit.", thisClassLoader);
loader.addLogicalLib("testclasses");
loader.addLogicalLib("commons-logging");
- Class testClass = loader.loadClass(thisClass.getName());
+ final Class testClass = loader.loadClass(thisClass.getName());
return new PathableTestSuite(testClass, loader);
}
@@ -86,7 +86,7 @@ public class AltHashtableTestCase extends TestCase {
AltHashtable.lastValue = null;
LogFactory.getLog(AltHashtableTestCase.class);
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
assertEquals(contextLoader, AltHashtable.lastKey);
assertNotNull(AltHashtable.lastValue);
}
diff --git a/src/test/java/org/apache/commons/logging/BasicOperationsTestCase.java b/src/test/java/org/apache/commons/logging/BasicOperationsTestCase.java
index dfadab2..95d7973 100644
--- a/src/test/java/org/apache/commons/logging/BasicOperationsTestCase.java
+++ b/src/test/java/org/apache/commons/logging/BasicOperationsTestCase.java
@@ -29,17 +29,17 @@ public class BasicOperationsTestCase extends TestCase
{
public void testIsEnabledClassLog()
{
- Log log = LogFactory.getLog(BasicOperationsTestCase.class);
+ final Log log = LogFactory.getLog(BasicOperationsTestCase.class);
executeIsEnabledTest(log);
}
public void testIsEnabledNamedLog()
{
- Log log = LogFactory.getLog(BasicOperationsTestCase.class.getName());
+ final Log log = LogFactory.getLog(BasicOperationsTestCase.class.getName());
executeIsEnabledTest(log);
}
- public void executeIsEnabledTest(Log log)
+ public void executeIsEnabledTest(final Log log)
{
try
{
@@ -50,7 +50,7 @@ public class BasicOperationsTestCase extends TestCase
log.isErrorEnabled();
log.isFatalEnabled();
}
- catch (Throwable t)
+ catch (final Throwable t)
{
t.printStackTrace();
fail("Exception thrown: " + t);
@@ -59,17 +59,17 @@ public class BasicOperationsTestCase extends TestCase
public void testMessageWithoutExceptionClassLog()
{
- Log log = LogFactory.getLog(BasicOperationsTestCase.class);
+ final Log log = LogFactory.getLog(BasicOperationsTestCase.class);
executeMessageWithoutExceptionTest(log);
}
public void testMessageWithoutExceptionNamedLog()
{
- Log log = LogFactory.getLog(BasicOperationsTestCase.class.getName());
+ final Log log = LogFactory.getLog(BasicOperationsTestCase.class.getName());
executeMessageWithoutExceptionTest(log);
}
- public void executeMessageWithoutExceptionTest(Log log)
+ public void executeMessageWithoutExceptionTest(final Log log)
{
try
{
@@ -80,7 +80,7 @@ public class BasicOperationsTestCase extends TestCase
log.error("Hello, Mum");
log.fatal("Hello, Mum");
}
- catch (Throwable t)
+ catch (final Throwable t)
{
t.printStackTrace();
fail("Exception thrown: " + t);
@@ -89,17 +89,17 @@ public class BasicOperationsTestCase extends TestCase
public void testMessageWithExceptionClassLog()
{
- Log log = LogFactory.getLog(BasicOperationsTestCase.class);
+ final Log log = LogFactory.getLog(BasicOperationsTestCase.class);
executeMessageWithExceptionTest(log);
}
public void testMessageWithExceptionNamedLog()
{
- Log log = LogFactory.getLog(BasicOperationsTestCase.class.getName());
+ final Log log = LogFactory.getLog(BasicOperationsTestCase.class.getName());
executeMessageWithExceptionTest(log);
}
- public void executeMessageWithExceptionTest(Log log)
+ public void executeMessageWithExceptionTest(final Log log)
{
try
{
@@ -110,7 +110,7 @@ public class BasicOperationsTestCase extends TestCase
log.error("Hello, Mum", new ArithmeticException());
log.fatal("Hello, Mum", new ArithmeticException());
}
- catch (Throwable t)
+ catch (final Throwable t)
{
t.printStackTrace();
fail("Exception thrown: " + t);
diff --git a/src/test/java/org/apache/commons/logging/LoadTestCase.java b/src/test/java/org/apache/commons/logging/LoadTestCase.java
index 3c910fd..13ac5aa 100644
--- a/src/test/java/org/apache/commons/logging/LoadTestCase.java
+++ b/src/test/java/org/apache/commons/logging/LoadTestCase.java
@@ -41,11 +41,11 @@ public class LoadTestCase extends TestCase{
java.util.Map classes = new java.util.HashMap();
- AppClassLoader(ClassLoader parent){
+ AppClassLoader(final ClassLoader parent){
super(parent);
}
- private Class def(String name)throws ClassNotFoundException{
+ private Class def(final String name)throws ClassNotFoundException{
Class result = (Class)classes.get(name);
if(result != null){
@@ -54,23 +54,23 @@ public class LoadTestCase extends TestCase{
try{
- ClassLoader cl = this.getClass().getClassLoader();
- String classFileName = name.replace('.','/') + ".class";
- java.io.InputStream is = cl.getResourceAsStream(classFileName);
- java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
+ final ClassLoader cl = this.getClass().getClassLoader();
+ final String classFileName = name.replace('.','/') + ".class";
+ final java.io.InputStream is = cl.getResourceAsStream(classFileName);
+ final java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
while(is.available() > 0){
out.write(is.read());
}
- byte data [] = out.toByteArray();
+ final byte data [] = out.toByteArray();
result = super.defineClass(name, data, 0, data.length );
classes.put(name,result);
return result;
- }catch(java.io.IOException ioe){
+ }catch(final java.io.IOException ioe){
throw new ClassNotFoundException( name + " caused by "
+ ioe.getMessage() );
@@ -81,7 +81,7 @@ public class LoadTestCase extends TestCase{
// not very trivial to emulate we must implement "findClass",
// but it will delegete to junit class loder first
- public Class loadClass(String name)throws ClassNotFoundException{
+ public Class loadClass(final String name)throws ClassNotFoundException{
//isolates all logging classes, application in the same classloader too.
//filters exeptions to simlify handling in test
@@ -102,9 +102,9 @@ public class LoadTestCase extends TestCase{
* (expected to be a UserClass loaded via a custom classloader), passing
* it the specified state parameter.
*/
- private void setAllowFlawedContext(Class c, String state) throws Exception {
- Class[] params = {String.class};
- java.lang.reflect.Method m = c.getDeclaredMethod("setAllowFlawedContext", params);
+ private void setAllowFlawedContext(final Class c, final String state) throws Exception {
+ final Class[] params = {String.class};
+ final java.lang.reflect.Method m = c.getDeclaredMethod("setAllowFlawedContext", params);
m.invoke(null, new Object[] {state});
}
@@ -145,7 +145,7 @@ public class LoadTestCase extends TestCase{
setAllowFlawedContext(cls, "false");
execute(cls);
fail("Logging config succeeded when context classloader was null!");
- } catch(LogConfigurationException ex) {
+ } catch(final LogConfigurationException ex) {
// expected; the boot classloader doesn't *have* JCL available
}
@@ -170,7 +170,7 @@ public class LoadTestCase extends TestCase{
execute(cls);
fail("Error: somehow downcast a Logger loaded via system classloader"
+ " to the Log interface loaded via a custom classloader");
- } catch(LogConfigurationException ex) {
+ } catch(final LogConfigurationException ex) {
// expected
}
}
@@ -183,15 +183,15 @@ public class LoadTestCase extends TestCase{
Class testObjCls = null;
- AppClassLoader appLoader = new AppClassLoader(
+ final AppClassLoader appLoader = new AppClassLoader(
this.getClass().getClassLoader());
try{
testObjCls = appLoader.loadClass(UserClass.class.getName());
- }catch(ClassNotFoundException cnfe){
+ }catch(final ClassNotFoundException cnfe){
throw cnfe;
- }catch(Throwable t){
+ }catch(final Throwable t){
t.printStackTrace();
fail("AppClassLoader failed ");
}
@@ -205,7 +205,7 @@ public class LoadTestCase extends TestCase{
}
- private void execute(Class cls)throws Exception{
+ private void execute(final Class cls)throws Exception{
cls.newInstance();
diff --git a/src/test/java/org/apache/commons/logging/PathableClassLoader.java b/src/test/java/org/apache/commons/logging/PathableClassLoader.java
index 04afda8..cbb04dd 100644
--- a/src/test/java/org/apache/commons/logging/PathableClassLoader.java
+++ b/src/test/java/org/apache/commons/logging/PathableClassLoader.java
@@ -93,7 +93,7 @@ public class PathableClassLoader extends URLClassLoader {
* creates its own classloader to run unit tests in (eg maven2's
* Surefire plugin).
*/
- public PathableClassLoader(ClassLoader parent) {
+ public PathableClassLoader(final ClassLoader parent) {
super(NO_URLS, parent);
}
@@ -102,7 +102,7 @@ public class PathableClassLoader extends URLClassLoader {
* use addLogicalLib instead, then define the location for that logical
* library in the build.xml file.
*/
- public void addURL(URL url) {
+ public void addURL(final URL url) {
super.addURL(url);
}
@@ -122,7 +122,7 @@ public class PathableClassLoader extends URLClassLoader {
*
* This value defaults to true.
*/
- public void setParentFirst(boolean state) {
+ public void setParentFirst(final boolean state) {
parentFirst = state;
}
@@ -138,7 +138,7 @@ public class PathableClassLoader extends URLClassLoader {
* Of course, this assumes that the classes of interest are already
* in the classpath of the system classloader.
*/
- public void useSystemLoader(String prefix) {
+ public void useSystemLoader(final String prefix) {
useExplicitLoader(prefix, ClassLoader.getSystemClassLoader());
}
@@ -168,7 +168,7 @@ public class PathableClassLoader extends URLClassLoader {
* then a prefix used to map from here to one of those classloaders.
*
*/
- public void useExplicitLoader(String prefix, ClassLoader loader) {
+ public void useExplicitLoader(final String prefix, final ClassLoader loader) {
if (lookasides == null) {
lookasides = new HashMap();
}
@@ -178,7 +178,7 @@ public class PathableClassLoader extends URLClassLoader {
/**
* Specify a collection of logical libraries. See addLogicalLib.
*/
- public void addLogicalLib(String[] logicalLibs) {
+ public void addLogicalLib(final String[] logicalLibs) {
for(int i=0; iArrayList containing the enumerated
* elements in the enumerated order, not null
*/
- private ArrayList toList(Enumeration en) {
- ArrayList results = new ArrayList();
+ private ArrayList toList(final Enumeration en) {
+ final ArrayList results = new ArrayList();
if (en != null) {
while (en.hasMoreElements()){
- Object element = en.nextElement();
+ final Object element = en.nextElement();
results.add(element);
}
}
@@ -416,15 +416,15 @@ public class PathableClassLoader extends URLClassLoader {
* the resource is looked for in the local classpath before the parent
* loader is consulted.
*/
- public InputStream getResourceAsStream(String name) {
+ public InputStream getResourceAsStream(final String name) {
if (parentFirst) {
return super.getResourceAsStream(name);
} else {
- URL local = super.findResource(name);
+ final URL local = super.findResource(name);
if (local != null) {
try {
return local.openStream();
- } catch(IOException e) {
+ } catch(final IOException e) {
// TODO: check if this is right or whether we should
// fall back to trying parent. The javadoc doesn't say...
return null;
diff --git a/src/test/java/org/apache/commons/logging/PathableTestSuite.java b/src/test/java/org/apache/commons/logging/PathableTestSuite.java
index 4b8805c..9fe39a8 100644
--- a/src/test/java/org/apache/commons/logging/PathableTestSuite.java
+++ b/src/test/java/org/apache/commons/logging/PathableTestSuite.java
@@ -120,7 +120,7 @@ public class PathableTestSuite extends TestSuite {
* calls to Thread.currentThread.getContextClassLoader from test methods
* (or any method called by test methods).
*/
- public PathableTestSuite(Class testClass, ClassLoader contextClassLoader) {
+ public PathableTestSuite(final Class testClass, final ClassLoader contextClassLoader) {
super(testClass);
contextLoader = contextClassLoader;
}
@@ -133,9 +133,9 @@ public class PathableTestSuite extends TestSuite {
* The context classloader and system properties are saved before each
* test, and restored after the test completes to better isolate tests.
*/
- public void runTest(Test test, TestResult result) {
- ClassLoader origContext = Thread.currentThread().getContextClassLoader();
- Properties oldSysProps = (Properties) System.getProperties().clone();
+ public void runTest(final Test test, final TestResult result) {
+ final ClassLoader origContext = Thread.currentThread().getContextClassLoader();
+ final Properties oldSysProps = (Properties) System.getProperties().clone();
try {
Thread.currentThread().setContextClassLoader(contextLoader);
test.run(result);
diff --git a/src/test/java/org/apache/commons/logging/UserClass.java b/src/test/java/org/apache/commons/logging/UserClass.java
index 9013133..a5e5bb5 100644
--- a/src/test/java/org/apache/commons/logging/UserClass.java
+++ b/src/test/java/org/apache/commons/logging/UserClass.java
@@ -29,13 +29,13 @@ public class UserClass {
* when an instance of this class is actually created before calling
* this method!
*/
- public static void setAllowFlawedContext(String state) {
- LogFactory f = LogFactory.getFactory();
+ public static void setAllowFlawedContext(final String state) {
+ final LogFactory f = LogFactory.getFactory();
f.setAttribute(LogFactoryImpl.ALLOW_FLAWED_CONTEXT_PROPERTY, state);
}
public UserClass() {
- Log log = LogFactory.getLog(LoadTestCase.class);
+ final Log log = LogFactory.getLog(LoadTestCase.class);
}
}
diff --git a/src/test/java/org/apache/commons/logging/avalon/AvalonLoggerTestCase.java b/src/test/java/org/apache/commons/logging/avalon/AvalonLoggerTestCase.java
index 732d82b..dc9776c 100644
--- a/src/test/java/org/apache/commons/logging/avalon/AvalonLoggerTestCase.java
+++ b/src/test/java/org/apache/commons/logging/avalon/AvalonLoggerTestCase.java
@@ -31,14 +31,14 @@ import junit.framework.TestSuite;
public class AvalonLoggerTestCase extends AbstractLogTest {
public static Test suite() {
- TestSuite suite = new TestSuite();
+ final TestSuite suite = new TestSuite();
suite.addTestSuite(AvalonLoggerTestCase.class);
return suite;
}
public Log getLogObject() {
// Output does not seem to be used, so don't display it.
- Log log = new AvalonLogger(new NullLogger());
+ final Log log = new AvalonLogger(new NullLogger());
return log;
}
}
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 4725dcd..7e6a193 100644
--- a/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/config/FirstPriorityConfigTestCase.java
@@ -48,39 +48,39 @@ public class FirstPriorityConfigTestCase extends TestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- Class thisClass = FirstPriorityConfigTestCase.class;
+ final Class thisClass = FirstPriorityConfigTestCase.class;
// Determine the URL to this .class file, so that we can then
// append the priority dirs to it. For tidiness, load this
// class through a dummy loader though this is not absolutely
// necessary...
- PathableClassLoader dummy = new PathableClassLoader(null);
+ final PathableClassLoader dummy = new PathableClassLoader(null);
dummy.useExplicitLoader("junit.", Test.class.getClassLoader());
dummy.addLogicalLib("testclasses");
dummy.addLogicalLib("commons-logging");
- String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
- URL baseUrl = dummy.findResource(thisClassPath);
+ final String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
+ final URL baseUrl = dummy.findResource(thisClassPath);
// Now set up the desired classloader hierarchy. We'll put JCL
// in the container path, the testcase in a webapp path, and
// both config files into the webapp path too.
- PathableClassLoader containerLoader = new PathableClassLoader(null);
+ final PathableClassLoader containerLoader = new PathableClassLoader(null);
containerLoader.useExplicitLoader("junit.", Test.class.getClassLoader());
containerLoader.addLogicalLib("commons-logging");
- PathableClassLoader webappLoader = new PathableClassLoader(containerLoader);
+ final PathableClassLoader webappLoader = new PathableClassLoader(containerLoader);
webappLoader.addLogicalLib("testclasses");
- URL pri20URL = new URL(baseUrl, "priority20/");
+ final URL pri20URL = new URL(baseUrl, "priority20/");
webappLoader.addURL(pri20URL);
- URL pri10URL = new URL(baseUrl, "priority10/");
+ final URL pri10URL = new URL(baseUrl, "priority10/");
webappLoader.addURL(pri10URL);
// load the test class via webapp loader, and use the webapp loader
// as the tccl loader too.
- Class testClass = webappLoader.loadClass(thisClass.getName());
+ final Class testClass = webappLoader.loadClass(thisClass.getName());
return new PathableTestSuite(testClass, webappLoader);
}
@@ -105,11 +105,11 @@ public class FirstPriorityConfigTestCase extends TestCase {
* the desired configId value.
*/
public void testPriority() throws Exception {
- LogFactory instance = LogFactory.getFactory();
+ final LogFactory instance = LogFactory.getFactory();
- ClassLoader thisClassLoader = this.getClass().getClassLoader();
- ClassLoader lfClassLoader = instance.getClass().getClassLoader();
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader thisClassLoader = this.getClass().getClassLoader();
+ final ClassLoader lfClassLoader = instance.getClass().getClassLoader();
+ final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
// context classloader should be thisClassLoader
assertEquals(thisClassLoader, contextClassLoader);
@@ -119,7 +119,7 @@ public class FirstPriorityConfigTestCase extends TestCase {
assertEquals(PathableClassLoader.class.getName(),
lfClassLoader.getClass().getName());
- String id = (String) instance.getAttribute("configId");
+ final String id = (String) instance.getAttribute("configId");
assertEquals("Correct config file loaded", "priority20", id );
}
}
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 831e255..952ccdd 100644
--- a/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/config/PriorityConfigTestCase.java
@@ -55,19 +55,19 @@ public class PriorityConfigTestCase extends TestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- Class thisClass = PriorityConfigTestCase.class;
+ final Class thisClass = PriorityConfigTestCase.class;
// Determine the URL to this .class file, so that we can then
// append the priority dirs to it. For tidiness, load this
// class through a dummy loader though this is not absolutely
// necessary...
- PathableClassLoader dummy = new PathableClassLoader(null);
+ final PathableClassLoader dummy = new PathableClassLoader(null);
dummy.useExplicitLoader("junit.", Test.class.getClassLoader());
dummy.addLogicalLib("testclasses");
dummy.addLogicalLib("commons-logging");
- String thisClassPath = thisClass.getName().replace('.', '/') + ".class";
- URL baseUrl = dummy.findResource(thisClassPath);
+ 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
// file of priority=10 in the container path, and ones of both
@@ -76,29 +76,29 @@ public class PriorityConfigTestCase extends TestCase {
// A second properties file with priority=20 is also added,
// so we can check that the first one in the classpath is
// used.
- PathableClassLoader containerLoader = new PathableClassLoader(null);
+ final PathableClassLoader containerLoader = new PathableClassLoader(null);
containerLoader.useExplicitLoader("junit.", Test.class.getClassLoader());
containerLoader.addLogicalLib("commons-logging");
- URL pri10URL = new URL(baseUrl, "priority10/");
+ final URL pri10URL = new URL(baseUrl, "priority10/");
containerLoader.addURL(pri10URL);
- PathableClassLoader webappLoader = new PathableClassLoader(containerLoader);
+ final PathableClassLoader webappLoader = new PathableClassLoader(containerLoader);
webappLoader.setParentFirst(true);
webappLoader.addLogicalLib("testclasses");
- URL noPriorityURL = new URL(baseUrl, "nopriority/");
+ final URL noPriorityURL = new URL(baseUrl, "nopriority/");
webappLoader.addURL(noPriorityURL);
- URL pri20URL = new URL(baseUrl, "priority20/");
+ final URL pri20URL = new URL(baseUrl, "priority20/");
webappLoader.addURL(pri20URL);
- URL pri20aURL = new URL(baseUrl, "priority20a/");
+ final URL pri20aURL = new URL(baseUrl, "priority20a/");
webappLoader.addURL(pri20aURL);
// load the test class via webapp loader, and use the webapp loader
// as the tccl loader too.
- Class testClass = webappLoader.loadClass(thisClass.getName());
+ final Class testClass = webappLoader.loadClass(thisClass.getName());
return new PathableTestSuite(testClass, webappLoader);
}
@@ -123,8 +123,8 @@ public class PriorityConfigTestCase extends TestCase {
* the desired configId value.
*/
public void testPriority() throws Exception {
- LogFactory instance = LogFactory.getFactory();
- String id = (String) instance.getAttribute("configId");
+ final LogFactory instance = LogFactory.getFactory();
+ final String id = (String) instance.getAttribute("configId");
assertEquals("Correct config file loaded", "priority20", id );
}
}
diff --git a/src/test/java/org/apache/commons/logging/impl/WeakHashtableTestCase.java b/src/test/java/org/apache/commons/logging/impl/WeakHashtableTestCase.java
index 8a37068..d0ae4e6 100644
--- a/src/test/java/org/apache/commons/logging/impl/WeakHashtableTestCase.java
+++ b/src/test/java/org/apache/commons/logging/impl/WeakHashtableTestCase.java
@@ -50,7 +50,7 @@ public class WeakHashtableTestCase extends TestCase {
private Long valueTwo;
private Long valueThree;
- public WeakHashtableTestCase(String testName) {
+ public WeakHashtableTestCase(final String testName) {
super(testName);
}
@@ -105,8 +105,8 @@ public class WeakHashtableTestCase extends TestCase {
/** Tests public Enumeration elements() */
public void testElements() throws Exception {
- ArrayList elements = new ArrayList();
- for (Enumeration e = weakHashtable.elements(); e.hasMoreElements();) {
+ final ArrayList elements = new ArrayList();
+ for (final Enumeration e = weakHashtable.elements(); e.hasMoreElements();) {
elements.add(e.nextElement());
}
assertEquals(3, elements.size());
@@ -117,10 +117,10 @@ public class WeakHashtableTestCase extends TestCase {
/** Tests public Set entrySet() */
public void testEntrySet() throws Exception {
- Set entrySet = weakHashtable.entrySet();
- for (Iterator it = entrySet.iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- Object key = entry.getKey();
+ final Set entrySet = weakHashtable.entrySet();
+ for (final Iterator it = entrySet.iterator(); it.hasNext();) {
+ final Map.Entry entry = (Map.Entry) it.next();
+ final Object key = entry.getKey();
if (keyOne.equals(key)) {
assertEquals(valueOne, entry.getValue());
} else if (keyTwo.equals(key)) {
@@ -143,8 +143,8 @@ public class WeakHashtableTestCase extends TestCase {
/** Tests public Enumeration keys() */
public void testKeys() throws Exception {
- ArrayList keys = new ArrayList();
- for (Enumeration e = weakHashtable.keys(); e.hasMoreElements();) {
+ final ArrayList keys = new ArrayList();
+ for (final Enumeration e = weakHashtable.keys(); e.hasMoreElements();) {
keys.add(e.nextElement());
}
assertEquals(3, keys.size());
@@ -155,7 +155,7 @@ public class WeakHashtableTestCase extends TestCase {
/** Tests public Set keySet() */
public void testKeySet() throws Exception {
- Set keySet = weakHashtable.keySet();
+ final Set keySet = weakHashtable.keySet();
assertEquals(3, keySet.size());
assertTrue(keySet.contains(keyOne));
assertTrue(keySet.contains(keyTwo));
@@ -164,7 +164,7 @@ public class WeakHashtableTestCase extends TestCase {
/** Tests public Object put(Object key, Object value) */
public void testPut() throws Exception {
- Long anotherKey = new Long(2004);
+ final Long anotherKey = new Long(2004);
weakHashtable.put(anotherKey, new Long(1066));
assertEquals(new Long(1066), weakHashtable.get(anotherKey));
@@ -174,7 +174,7 @@ public class WeakHashtableTestCase extends TestCase {
try {
weakHashtable.put(null, new Object());
}
- catch (Exception e) {
+ catch (final Exception e) {
caught = e;
}
assertNotNull("did not throw an exception adding a null key", caught);
@@ -182,7 +182,7 @@ public class WeakHashtableTestCase extends TestCase {
try {
weakHashtable.put(new Object(), null);
}
- catch (Exception e) {
+ catch (final Exception e) {
caught = e;
}
assertNotNull("did not throw an exception adding a null value", caught);
@@ -190,12 +190,12 @@ public class WeakHashtableTestCase extends TestCase {
/** Tests public void putAll(Map t) */
public void testPutAll() throws Exception {
- Map newValues = new HashMap();
- Long newKey = new Long(1066);
- Long newValue = new Long(1415);
+ final Map newValues = new HashMap();
+ final Long newKey = new Long(1066);
+ final Long newValue = new Long(1415);
newValues.put(newKey, newValue);
- Long anotherNewKey = new Long(1645);
- Long anotherNewValue = new Long(1815);
+ final Long anotherNewKey = new Long(1645);
+ final Long anotherNewValue = new Long(1815);
newValues.put(anotherNewKey, anotherNewValue);
weakHashtable.putAll(newValues);
@@ -213,7 +213,7 @@ public class WeakHashtableTestCase extends TestCase {
/** Tests public Collection values() */
public void testValues() throws Exception {
- Collection values = weakHashtable.values();
+ final Collection values = weakHashtable.values();
assertEquals(3, values.size());
assertTrue(values.contains(valueOne));
assertTrue(values.contains(valueTwo));
@@ -229,8 +229,8 @@ public class WeakHashtableTestCase extends TestCase {
*/
public void xxxIgnoretestRelease() throws Exception {
assertNotNull(weakHashtable.get(new Long(1)));
- ReferenceQueue testQueue = new ReferenceQueue();
- WeakReference weakKeyOne = new WeakReference(keyOne, testQueue);
+ final ReferenceQueue testQueue = new ReferenceQueue();
+ final WeakReference weakKeyOne = new WeakReference(keyOne, testQueue);
// lose our references
keyOne = null;
@@ -253,7 +253,7 @@ public class WeakHashtableTestCase extends TestCase {
} else {
// create garbage:
- byte[] b = new byte[bytz];
+ final byte[] b = new byte[bytz];
bytz = bytz * 2;
}
}
@@ -270,7 +270,7 @@ public class WeakHashtableTestCase extends TestCase {
public static class StupidThread extends Thread {
- public StupidThread(String name) {
+ public StupidThread(final String name) {
super(name);
}
@@ -285,7 +285,7 @@ public class WeakHashtableTestCase extends TestCase {
}
public void testLOGGING_119() throws Exception {
- Thread [] t = new Thread[THREAD_COUNT];
+ final Thread [] t = new Thread[THREAD_COUNT];
for (int j=1; j <= OUTER_LOOP; j++) {
hashtable = new WeakHashtable();
for (int i = 0; i < t.length; i++) {
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 afa04d6..5fe968a 100644
--- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java
+++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigAPITestCase.java
@@ -30,7 +30,7 @@ import org.apache.commons.logging.PathableTestSuite;
public class CustomConfigAPITestCase extends CustomConfigTestCase {
- public CustomConfigAPITestCase(String name) {
+ public CustomConfigAPITestCase(final String name) {
super(name);
}
@@ -38,7 +38,7 @@ public class CustomConfigAPITestCase extends CustomConfigTestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- PathableClassLoader parent = new PathableClassLoader(null);
+ final PathableClassLoader parent = new PathableClassLoader(null);
parent.useExplicitLoader("junit.", Test.class.getClassLoader());
// the TestHandler class must be accessable from the System classloader
@@ -46,16 +46,16 @@ public class CustomConfigAPITestCase extends CustomConfigTestCase {
// 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
// but the whole jdk14 API is a ******* mess anyway.
- ClassLoader scl = ClassLoader.getSystemClassLoader();
+ final ClassLoader scl = ClassLoader.getSystemClassLoader();
loadTestHandler(HANDLER_NAME, scl);
parent.useExplicitLoader(HANDLER_NAME, scl);
parent.addLogicalLib("commons-logging-api");
- PathableClassLoader child = new PathableClassLoader(parent);
+ final PathableClassLoader child = new PathableClassLoader(parent);
child.addLogicalLib("testclasses");
child.addLogicalLib("commons-logging");
- Class testClass = child.loadClass(CustomConfigAPITestCase.class.getName());
+ final Class testClass = child.loadClass(CustomConfigAPITestCase.class.getName());
return new PathableTestSuite(testClass, child);
}
}
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 86a6232..710fa00 100644
--- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java
+++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigFullTestCase.java
@@ -32,7 +32,7 @@ import org.apache.commons.logging.PathableClassLoader;
public class CustomConfigFullTestCase extends CustomConfigTestCase {
- public CustomConfigFullTestCase(String name) {
+ public CustomConfigFullTestCase(final String name) {
super(name);
}
@@ -41,7 +41,7 @@ public class CustomConfigFullTestCase extends CustomConfigTestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- PathableClassLoader parent = new PathableClassLoader(null);
+ final PathableClassLoader parent = new PathableClassLoader(null);
parent.useExplicitLoader("junit.", Test.class.getClassLoader());
// the TestHandler class must be accessable from the System classloader
@@ -49,15 +49,15 @@ public class CustomConfigFullTestCase extends CustomConfigTestCase {
// 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
// but the whole jdk14 API is a ******* mess anyway.
- ClassLoader scl = ClassLoader.getSystemClassLoader();
+ final ClassLoader scl = ClassLoader.getSystemClassLoader();
loadTestHandler(HANDLER_NAME, scl);
parent.useExplicitLoader(HANDLER_NAME, scl);
parent.addLogicalLib("commons-logging");
- PathableClassLoader child = new PathableClassLoader(parent);
+ final PathableClassLoader child = new PathableClassLoader(parent);
child.addLogicalLib("testclasses");
- Class testClass = child.loadClass(CustomConfigFullTestCase.class.getName());
+ final Class testClass = child.loadClass(CustomConfigFullTestCase.class.getName());
return new PathableTestSuite(testClass, child);
}
}
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 23ec21c..193da7d 100644
--- a/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/jdk14/CustomConfigTestCase.java
@@ -56,7 +56,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
*
* @param name Name of the test case
*/
- public CustomConfigTestCase(String name) {
+ public CustomConfigTestCase(final String name) {
super(name);
}
@@ -109,15 +109,15 @@ 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.
*/
- protected static byte[] readClass(String name, ClassLoader srcCL) throws Exception {
- String resName = name.replace('.', '/') + ".class";
+ protected static byte[] readClass(final String name, final ClassLoader srcCL) throws Exception {
+ final String resName = name.replace('.', '/') + ".class";
System.err.println("Trying to load resource [" + resName + "]");
- InputStream is = srcCL.getResourceAsStream(resName);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final InputStream is = srcCL.getResourceAsStream(resName);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.err.println("Reading resource [" + resName + "]");
- byte[] buf = new byte[1000];
+ final byte[] buf = new byte[1000];
for(;;) {
- int read = is.read(buf);
+ final int read = is.read(buf);
if (read <= 0) {
break;
}
@@ -133,30 +133,30 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
* works for classes for which all dependencies are already loaded in
* that classloader.
*/
- protected static void loadTestHandler(String className, ClassLoader targetCL) {
+ protected static void loadTestHandler(final String className, final ClassLoader targetCL) {
try {
targetCL.loadClass(className);
// fail("Class already in target classloader");
return;
- } catch(ClassNotFoundException ex) {
+ } catch(final ClassNotFoundException ex) {
// ok, go ahead and load it
}
try {
- ClassLoader srcCL = CustomConfigAPITestCase.class.getClassLoader();
- byte[] classData = readClass(className, srcCL);
+ final ClassLoader srcCL = CustomConfigAPITestCase.class.getClassLoader();
+ final byte[] classData = readClass(className, srcCL);
- Class[] params = new Class[] { String.class, classData.getClass(), Integer.TYPE, Integer.TYPE };
- Method m = ClassLoader.class.getDeclaredMethod("defineClass", params);
+ final Class[] params = new Class[] { String.class, classData.getClass(), Integer.TYPE, Integer.TYPE };
+ final Method m = ClassLoader.class.getDeclaredMethod("defineClass", params);
- Object[] args = new Object[4];
+ final Object[] args = new Object[4];
args[0] = className;
args[1] = classData;
args[2] = new Integer(0);
args[3] = new Integer(classData.length);
m.setAccessible(true);
m.invoke(targetCL, args);
- } catch(Exception e) {
+ } catch(final Exception e) {
e.printStackTrace();
fail("Unable to load class " + className);
}
@@ -179,7 +179,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- PathableClassLoader cl = new PathableClassLoader(null);
+ final PathableClassLoader cl = new PathableClassLoader(null);
cl.useExplicitLoader("junit.", Test.class.getClassLoader());
// the TestHandler class must be accessable from the System classloader
@@ -187,13 +187,13 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
// 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
// but the whole jdk14 API is a ******* mess anyway.
- ClassLoader scl = ClassLoader.getSystemClassLoader();
+ final ClassLoader scl = ClassLoader.getSystemClassLoader();
loadTestHandler(HANDLER_NAME, scl);
cl.useExplicitLoader(HANDLER_NAME, scl);
cl.addLogicalLib("commons-logging");
cl.addLogicalLib("testclasses");
- Class testClass = cl.loadClass(CustomConfigTestCase.class.getName());
+ final Class testClass = cl.loadClass(CustomConfigTestCase.class.getName());
return new PathableTestSuite(testClass, cl);
}
@@ -290,11 +290,11 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
// Check the recorded messages
- protected void checkLogRecords(boolean thrown) {
- Iterator records = handler.records();
+ protected void checkLogRecords(final boolean thrown) {
+ final Iterator records = handler.records();
for (int i = 0; i < testMessages.length; i++) {
assertTrue(records.hasNext());
- LogRecord record = (LogRecord) records.next();
+ final LogRecord record = (LogRecord) records.next();
assertEquals("LogRecord level",
testLevels[i], record.getLevel());
assertEquals("LogRecord message",
@@ -327,7 +327,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
// Log the messages with exceptions
protected void logExceptionMessages() {
- Throwable t = new DummyException();
+ final Throwable t = new DummyException();
log.trace("trace", t); // Should not actually get logged
log.debug("debug", t);
log.info("info", t);
@@ -377,15 +377,15 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
// Set up logger instance
- protected void setUpLogger(String name) throws Exception {
+ protected void setUpLogger(final String name) throws Exception {
logger = Logger.getLogger(name);
}
// Set up LogManager instance
- protected void setUpManager(String config) throws Exception {
+ protected void setUpManager(final String config) throws Exception {
manager = LogManager.getLogManager();
- InputStream is =
+ final InputStream is =
this.getClass().getClassLoader().getResourceAsStream(config);
manager.readConfiguration(is);
is.close();
diff --git a/src/test/java/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java b/src/test/java/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java
index 446d58d..145e433 100644
--- a/src/test/java/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java
+++ b/src/test/java/org/apache/commons/logging/jdk14/DefaultConfigTestCase.java
@@ -52,7 +52,7 @@ public class DefaultConfigTestCase extends TestCase {
*
* @param name Name of the test case
*/
- public DefaultConfigTestCase(String name) {
+ public DefaultConfigTestCase(final String name) {
super(name);
}
@@ -88,12 +88,12 @@ public class DefaultConfigTestCase extends TestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- PathableClassLoader loader = new PathableClassLoader(null);
+ final PathableClassLoader loader = new PathableClassLoader(null);
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
loader.addLogicalLib("testclasses");
loader.addLogicalLib("commons-logging");
- Class testClass = loader.loadClass(DefaultConfigTestCase.class.getName());
+ final Class testClass = loader.loadClass(DefaultConfigTestCase.class.getName());
return new PathableTestSuite(testClass, loader);
}
@@ -126,7 +126,7 @@ public class DefaultConfigTestCase extends TestCase {
"org.apache.commons.logging.impl.LogFactoryImpl",
factory.getClass().getName());
- String names[] = factory.getAttributeNames();
+ final String names[] = factory.getAttributeNames();
assertNotNull("Names exists", names);
assertEquals("Names empty", 0, names.length);
@@ -137,13 +137,13 @@ public class DefaultConfigTestCase extends TestCase {
public void testSerializable() throws Exception {
// Serialize and deserialize the instance
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(log);
oos.close();
- ByteArrayInputStream bais =
+ final ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
+ final ObjectInputStream ois = new ObjectInputStream(bais);
log = (Log) ois.readObject();
ois.close();
@@ -183,7 +183,7 @@ public class DefaultConfigTestCase extends TestCase {
// Set up log instance
- protected void setUpLog(String name) throws Exception {
+ protected void setUpLog(final String name) throws Exception {
log = LogFactory.getLog(name);
}
diff --git a/src/test/java/org/apache/commons/logging/jdk14/TestHandler.java b/src/test/java/org/apache/commons/logging/jdk14/TestHandler.java
index eb53cee..ca49830 100644
--- a/src/test/java/org/apache/commons/logging/jdk14/TestHandler.java
+++ b/src/test/java/org/apache/commons/logging/jdk14/TestHandler.java
@@ -62,7 +62,7 @@ public class TestHandler extends Handler {
}
- public void publish(LogRecord record) {
+ public void publish(final LogRecord record) {
records.add(record);
}
diff --git a/src/test/java/org/apache/commons/logging/log4j/StandardTests.java b/src/test/java/org/apache/commons/logging/log4j/StandardTests.java
index 2f86f74..5ce6c40 100644
--- a/src/test/java/org/apache/commons/logging/log4j/StandardTests.java
+++ b/src/test/java/org/apache/commons/logging/log4j/StandardTests.java
@@ -88,13 +88,13 @@ public abstract class StandardTests extends TestCase {
* Test that a LogFactory gets created as expected.
*/
public void testCreateFactory() {
- LogFactory factory = LogFactory.getFactory();
+ final LogFactory factory = LogFactory.getFactory();
assertNotNull("LogFactory exists", factory);
assertEquals("LogFactory class",
"org.apache.commons.logging.impl.LogFactoryImpl",
factory.getClass().getName());
- String names[] = factory.getAttributeNames();
+ final String names[] = factory.getAttributeNames();
assertNotNull("Names exists", names);
assertEquals("Names empty", 0, names.length);
}
@@ -103,9 +103,9 @@ public abstract class StandardTests extends TestCase {
* Verify that we can log messages without exceptions.
*/
public void testPlainMessages() throws Exception {
- List logEvents = new ArrayList();
+ final List logEvents = new ArrayList();
setUpTestAppender(logEvents);
- Log log = LogFactory.getLog("test-category");
+ final Log log = LogFactory.getLog("test-category");
logPlainMessages(log);
checkLoggingEvents(logEvents, false);
}
@@ -114,9 +114,9 @@ public abstract class StandardTests extends TestCase {
* Verify that we can log exception messages.
*/
public void testExceptionMessages() throws Exception {
- List logEvents = new ArrayList();
+ final List logEvents = new ArrayList();
setUpTestAppender(logEvents);
- Log log = LogFactory.getLog("test-category");
+ final Log log = LogFactory.getLog("test-category");
logExceptionMessages(log);
checkLoggingEvents(logEvents, true);
}
@@ -125,18 +125,18 @@ public abstract class StandardTests extends TestCase {
* Test Serializability of Log instance
*/
public void testSerializable() throws Exception {
- List logEvents = new ArrayList();
+ final List logEvents = new ArrayList();
setUpTestAppender(logEvents);
- Log log = LogFactory.getLog("test-category");
+ final Log log = LogFactory.getLog("test-category");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(log);
oos.close();
- ByteArrayInputStream bais =
+ final ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
- Log newLog = (Log) ois.readObject();
+ final ObjectInputStream ois = new ObjectInputStream(bais);
+ final Log newLog = (Log) ois.readObject();
ois.close();
// Check the characteristics of the resulting object
@@ -162,7 +162,7 @@ public abstract class StandardTests extends TestCase {
* logevents with no associated exception info). True if
* logExceptionMessages was called.
*/
- private void checkLoggingEvents(List logEvents, boolean thrown) {
+ private void checkLoggingEvents(final List logEvents, final boolean thrown) {
LogEvent ev;
assertEquals("Unexpected number of log events", 4, logEvents.size());
@@ -192,7 +192,7 @@ public abstract class StandardTests extends TestCase {
/**
* Log plain messages.
*/
- private void logPlainMessages(Log log) {
+ private void logPlainMessages(final Log log) {
log.trace("trace"); // Should not actually get logged
log.debug("debug"); // Should not actually get logged
log.info("info");
@@ -204,8 +204,8 @@ public abstract class StandardTests extends TestCase {
/**
* Log messages with exceptions
*/
- private void logExceptionMessages(Log log) {
- Throwable t = new DummyException();
+ private void logExceptionMessages(final Log log) {
+ final Throwable t = new DummyException();
log.trace("trace", t); // Should not actually get logged
log.debug("debug", t); // Should not actually get logged
log.info("info", t);
diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java
index 1b7bace..313a2fc 100644
--- a/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java
+++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/ApiClasspathStandardTestCase.java
@@ -36,16 +36,16 @@ public class ApiClasspathStandardTestCase extends TestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- PathableClassLoader parent = new PathableClassLoader(null);
+ final PathableClassLoader parent = new PathableClassLoader(null);
parent.useExplicitLoader("junit.", Test.class.getClassLoader());
parent.addLogicalLib("commons-logging-api");
- PathableClassLoader child = new PathableClassLoader(parent);
+ final PathableClassLoader child = new PathableClassLoader(parent);
child.addLogicalLib("log4j12");
child.addLogicalLib("commons-logging");
child.addLogicalLib("testclasses");
- Class testClass = child.loadClass(
+ final Class testClass = child.loadClass(
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
return new PathableTestSuite(testClass, child);
}
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 71da059..5c211cf 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
@@ -34,13 +34,13 @@ public class AppClasspathStandardTestCase extends TestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- PathableClassLoader loader = new PathableClassLoader(null);
+ final PathableClassLoader loader = new PathableClassLoader(null);
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
loader.addLogicalLib("testclasses");
loader.addLogicalLib("log4j12");
loader.addLogicalLib("commons-logging");
- Class testClass = loader.loadClass(
+ final Class testClass = loader.loadClass(
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
return new PathableTestSuite(testClass, loader);
}
diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java
index 2620dbd..ca60f98 100644
--- a/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java
+++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/ChildClasspathStandardTestCase.java
@@ -35,15 +35,15 @@ public class ChildClasspathStandardTestCase extends TestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- PathableClassLoader parent = new PathableClassLoader(null);
+ final PathableClassLoader parent = new PathableClassLoader(null);
parent.useExplicitLoader("junit.", Test.class.getClassLoader());
- PathableClassLoader child = new PathableClassLoader(parent);
+ final PathableClassLoader child = new PathableClassLoader(parent);
child.addLogicalLib("testclasses");
child.addLogicalLib("log4j12");
child.addLogicalLib("commons-logging");
- Class testClass = child.loadClass(
+ final Class testClass = child.loadClass(
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
return new PathableTestSuite(testClass, child);
}
diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/Log4j12StandardTests.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/Log4j12StandardTests.java
index a03e74a..7005b4e 100644
--- a/src/test/java/org/apache/commons/logging/log4j/log4j12/Log4j12StandardTests.java
+++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/Log4j12StandardTests.java
@@ -32,9 +32,9 @@ import org.apache.log4j.Logger;
public class Log4j12StandardTests extends StandardTests {
- public void setUpTestAppender(List logEvents) {
- TestAppender appender = new TestAppender(logEvents);
- Logger rootLogger = Logger.getRootLogger();
+ public void setUpTestAppender(final List logEvents) {
+ final TestAppender appender = new TestAppender(logEvents);
+ final Logger rootLogger = Logger.getRootLogger();
rootLogger.removeAllAppenders();
rootLogger.addAppender(appender);
rootLogger.setLevel(Level.INFO);
diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java
index 3654d92..733fd60 100644
--- a/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java
+++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/ParentClasspathStandardTestCase.java
@@ -34,15 +34,15 @@ public class ParentClasspathStandardTestCase extends TestCase {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- PathableClassLoader parent = new PathableClassLoader(null);
+ final PathableClassLoader parent = new PathableClassLoader(null);
parent.useExplicitLoader("junit.", Test.class.getClassLoader());
parent.addLogicalLib("commons-logging");
parent.addLogicalLib("log4j12");
- PathableClassLoader child = new PathableClassLoader(parent);
+ final PathableClassLoader child = new PathableClassLoader(parent);
child.addLogicalLib("testclasses");
- Class testClass = child.loadClass(
+ final Class testClass = child.loadClass(
"org.apache.commons.logging.log4j.log4j12.Log4j12StandardTests");
return new PathableTestSuite(testClass, child);
}
diff --git a/src/test/java/org/apache/commons/logging/log4j/log4j12/TestAppender.java b/src/test/java/org/apache/commons/logging/log4j/log4j12/TestAppender.java
index 5ad71c8..e3da4b3 100644
--- a/src/test/java/org/apache/commons/logging/log4j/log4j12/TestAppender.java
+++ b/src/test/java/org/apache/commons/logging/log4j/log4j12/TestAppender.java
@@ -36,7 +36,7 @@ public class TestAppender extends AppenderSkeleton {
/**
* Constructor.
*/
- public TestAppender(List logEvents) {
+ public TestAppender(final List logEvents) {
events = logEvents;
}
@@ -49,8 +49,8 @@ public class TestAppender extends AppenderSkeleton {
// ------------------------------------------------------- Appender Methods
- protected void append(LoggingEvent event) {
- StandardTests.LogEvent lev = new StandardTests.LogEvent();
+ protected void append(final LoggingEvent event) {
+ final StandardTests.LogEvent lev = new StandardTests.LogEvent();
lev.level = event.getLevel().toString();
diff --git a/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java b/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java
index 4c1fbd8..26e24a1 100644
--- a/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java
+++ b/src/test/java/org/apache/commons/logging/logkit/StandardTestCase.java
@@ -61,15 +61,15 @@ public class StandardTestCase extends AbstractLogTest {
* Return the tests included in this test suite.
*/
public static Test suite() throws Exception {
- Class thisClass = StandardTestCase.class;
+ final Class thisClass = StandardTestCase.class;
- PathableClassLoader loader = new PathableClassLoader(null);
+ final PathableClassLoader loader = new PathableClassLoader(null);
loader.useExplicitLoader("junit.", Test.class.getClassLoader());
loader.addLogicalLib("testclasses");
loader.addLogicalLib("commons-logging");
loader.addLogicalLib("logkit");
- Class testClass = loader.loadClass(thisClass.getName());
+ final Class testClass = loader.loadClass(thisClass.getName());
return new PathableTestSuite(testClass, loader);
}
@@ -115,7 +115,7 @@ public class StandardTestCase extends AbstractLogTest {
"org.apache.commons.logging.impl.LogFactoryImpl",
factory.getClass().getName());
- String names[] = factory.getAttributeNames();
+ final String names[] = factory.getAttributeNames();
assertNotNull("Names exists", names);
assertEquals("Names empty", 0, names.length);
}
@@ -130,13 +130,13 @@ public class StandardTestCase extends AbstractLogTest {
checkStandard();
// Serialize and deserialize the instance
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(log);
oos.close();
- ByteArrayInputStream bais =
+ final ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
+ final ObjectInputStream ois = new ObjectInputStream(bais);
log = (Log) ois.readObject();
ois.close();
diff --git a/src/test/java/org/apache/commons/logging/noop/NoOpLogTestCase.java b/src/test/java/org/apache/commons/logging/noop/NoOpLogTestCase.java
index fa54c82..4a04e5f 100644
--- a/src/test/java/org/apache/commons/logging/noop/NoOpLogTestCase.java
+++ b/src/test/java/org/apache/commons/logging/noop/NoOpLogTestCase.java
@@ -68,13 +68,13 @@ public class NoOpLogTestCase extends AbstractLogTest
checkLog(log);
// Serialize and deserialize the instance
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(log);
oos.close();
- ByteArrayInputStream bais =
+ final ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
+ final ObjectInputStream ois = new ObjectInputStream(bais);
log = (Log) ois.readObject();
ois.close();
@@ -84,7 +84,7 @@ public class NoOpLogTestCase extends AbstractLogTest
// -------------------------------------------------------- Support Methods
- private void checkLog(Log log) {
+ private void checkLog(final Log log) {
assertNotNull("Log exists", log);
assertEquals("Log class",
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 b49ebc1..00eb9c9 100644
--- a/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java
+++ b/src/test/java/org/apache/commons/logging/pathable/ChildFirstTestCase.java
@@ -52,12 +52,12 @@ public class ChildFirstTestCase extends TestCase {
*
*/
public static Test suite() throws Exception {
- Class thisClass = ChildFirstTestCase.class;
- ClassLoader thisClassLoader = thisClass.getClassLoader();
+ final Class thisClass = ChildFirstTestCase.class;
+ final ClassLoader thisClassLoader = thisClass.getClassLoader();
// Make the parent a direct child of the bootloader to hide all
// other classes in the system classpath
- PathableClassLoader parent = new PathableClassLoader(null);
+ final PathableClassLoader parent = new PathableClassLoader(null);
parent.setParentFirst(false);
// Make the junit classes visible as a special case, as junit
@@ -71,7 +71,7 @@ public class ChildFirstTestCase extends TestCase {
parent.addLogicalLib("commons-logging");
// Create a child classloader to load the test case through
- PathableClassLoader child = new PathableClassLoader(parent);
+ final PathableClassLoader child = new PathableClassLoader(parent);
child.setParentFirst(false);
// Obviously, the child classloader needs to have the test classes
@@ -80,11 +80,11 @@ public class ChildFirstTestCase extends TestCase {
child.addLogicalLib("commons-logging-adapters");
// Create a third classloader to be the context classloader.
- PathableClassLoader context = new PathableClassLoader(child);
+ final PathableClassLoader context = new PathableClassLoader(child);
context.setParentFirst(false);
// reload this class via the child classloader
- Class testClass = child.loadClass(thisClass.getName());
+ final Class testClass = child.loadClass(thisClass.getName());
// and return our custom TestSuite class
return new PathableTestSuite(testClass, context);
@@ -96,7 +96,7 @@ public class ChildFirstTestCase extends TestCase {
* this object instance.
*/
private Set getAncestorCLs() {
- Set s = new HashSet();
+ final Set s = new HashSet();
ClassLoader cl = this.getClass().getClassLoader();
while (cl != null) {
s.add(cl);
@@ -113,14 +113,14 @@ public class ChildFirstTestCase extends TestCase {
*/
public void testPaths() throws Exception {
// the context classloader is not expected to be null
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
assertNotNull("Context classloader is null", contextLoader);
assertEquals("Context classloader has unexpected type",
PathableClassLoader.class.getName(),
contextLoader.getClass().getName());
// the classloader that loaded this class is obviously not null
- ClassLoader thisLoader = this.getClass().getClassLoader();
+ final ClassLoader thisLoader = this.getClass().getClassLoader();
assertNotNull("thisLoader is null", thisLoader);
assertEquals("thisLoader has unexpected type",
PathableClassLoader.class.getName(),
@@ -132,7 +132,7 @@ public class ChildFirstTestCase extends TestCase {
thisLoader, contextLoader.getParent());
// thisLoader's parent should be available
- ClassLoader parentLoader = thisLoader.getParent();
+ final ClassLoader parentLoader = thisLoader.getParent();
assertNotNull("Parent classloader is null", parentLoader);
assertEquals("Parent classloader has unexpected type",
PathableClassLoader.class.getName(),
@@ -144,7 +144,7 @@ public class ChildFirstTestCase extends TestCase {
// getSystemClassloader is not a PathableClassLoader; it's of a
// built-in type. This also verifies that system classloader is none of
// (context, child, parent).
- ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
+ final ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
assertNotNull("System classloader is null", systemLoader);
assertFalse("System classloader has unexpected type",
PathableClassLoader.class.getName().equals(
@@ -153,38 +153,38 @@ public class ChildFirstTestCase extends TestCase {
// junit classes should be visible; their classloader is not
// in the hierarchy of parent classloaders for this class,
// though it is accessable due to trickery in the PathableClassLoader.
- Class junitTest = contextLoader.loadClass("junit.framework.Test");
- Set ancestorCLs = getAncestorCLs();
+ final Class junitTest = contextLoader.loadClass("junit.framework.Test");
+ final Set ancestorCLs = getAncestorCLs();
assertFalse("Junit not loaded by ancestor classloader",
ancestorCLs.contains(junitTest.getClassLoader()));
// jcl api classes should be visible only via the parent
- Class logClass = contextLoader.loadClass("org.apache.commons.logging.Log");
+ final Class logClass = contextLoader.loadClass("org.apache.commons.logging.Log");
assertSame("Log class not loaded via parent",
logClass.getClassLoader(), parentLoader);
// jcl adapter classes should be visible via both parent and child. However
// as the classloaders are child-first we should see the child one.
- Class log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
+ final Class log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
assertSame("Log4JLogger not loaded via child",
log4jClass.getClassLoader(), thisLoader);
// test classes should be visible via the child only
- Class testClass = contextLoader.loadClass("org.apache.commons.logging.PathableTestSuite");
+ final Class testClass = contextLoader.loadClass("org.apache.commons.logging.PathableTestSuite");
assertSame("PathableTestSuite not loaded via child",
testClass.getClassLoader(), thisLoader);
// test loading of class that is not available
try {
- Class noSuchClass = contextLoader.loadClass("no.such.class");
+ final Class noSuchClass = contextLoader.loadClass("no.such.class");
fail("Class no.such.class is unexpectedly available");
assertNotNull(noSuchClass); // silence warning about unused var
- } catch(ClassNotFoundException ex) {
+ } catch(final ClassNotFoundException ex) {
// ok
}
// String class classloader is null
- Class stringClass = contextLoader.loadClass("java.lang.String");
+ final Class stringClass = contextLoader.loadClass("java.lang.String");
assertNull("String class classloader is not null!",
stringClass.getClassLoader());
}
@@ -195,8 +195,8 @@ public class ChildFirstTestCase extends TestCase {
public void testResource() {
URL resource;
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader childLoader = contextLoader.getParent();
+ final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader childLoader = contextLoader.getParent();
// getResource where it doesn't exist
resource = childLoader.getResource("nosuchfile");
@@ -228,10 +228,10 @@ public class ChildFirstTestCase extends TestCase {
URL[] urls;
// verify the classloader hierarchy
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader childLoader = contextLoader.getParent();
- ClassLoader parentLoader = childLoader.getParent();
- ClassLoader bootLoader = parentLoader.getParent();
+ 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);
// getResources where no instances exist
@@ -264,7 +264,7 @@ public class ChildFirstTestCase extends TestCase {
// There is no guarantee about the ordering of results returned from getResources
// To make this test portable across JVMs, sort the string to give them a known order
- String[] urlsToStrings = new String[2];
+ final String[] urlsToStrings = new String[2];
urlsToStrings[0] = urls[0].toString();
urlsToStrings[1] = urls[1].toString();
Arrays.sort(urlsToStrings);
@@ -277,13 +277,13 @@ public class ChildFirstTestCase extends TestCase {
/**
* Utility method to convert an enumeration-of-URLs into an array of URLs.
*/
- private static URL[] toURLArray(Enumeration e) {
- ArrayList l = new ArrayList();
+ private static URL[] toURLArray(final Enumeration e) {
+ final ArrayList l = new ArrayList();
while (e.hasMoreElements()) {
- URL u = (URL) e.nextElement();
+ final URL u = (URL) e.nextElement();
l.add(u);
}
- URL[] tmp = new URL[l.size()];
+ final URL[] tmp = new URL[l.size()];
return (URL[]) l.toArray(tmp);
}
@@ -294,10 +294,10 @@ public class ChildFirstTestCase extends TestCase {
java.io.InputStream is;
// verify the classloader hierarchy
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader childLoader = contextLoader.getParent();
- ClassLoader parentLoader = childLoader.getParent();
- ClassLoader bootLoader = parentLoader.getParent();
+ 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);
// getResourceAsStream where no instances exist
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 86fd475..0d0da99 100644
--- a/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java
+++ b/src/test/java/org/apache/commons/logging/pathable/GeneralTestCase.java
@@ -35,15 +35,15 @@ public class GeneralTestCase extends TestCase {
* Set up a custom classloader hierarchy for this test case.
*/
public static Test suite() throws Exception {
- Class thisClass = GeneralTestCase.class;
- ClassLoader thisClassLoader = thisClass.getClassLoader();
+ final Class thisClass = GeneralTestCase.class;
+ final ClassLoader thisClassLoader = thisClass.getClassLoader();
- PathableClassLoader loader = new PathableClassLoader(null);
+ final PathableClassLoader loader = new PathableClassLoader(null);
loader.useExplicitLoader("junit.", thisClassLoader);
loader.addLogicalLib("testclasses");
// reload this class via the child classloader
- Class testClass = loader.loadClass(thisClass.getName());
+ final Class testClass = loader.loadClass(thisClass.getName());
// and return our custom TestSuite class
return new PathableTestSuite(testClass, loader);
@@ -87,12 +87,12 @@ public class GeneralTestCase extends TestCase {
* a non-custom one.
*/
private static void checkAndSetContext() {
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
assertEquals("ContextLoader is of unexpected type",
contextLoader.getClass().getName(),
PathableClassLoader.class.getName());
- URL[] noUrls = new URL[0];
+ final URL[] noUrls = new URL[0];
Thread.currentThread().setContextClassLoader(new URLClassLoader(noUrls));
}
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 3aaa407..3c22618 100644
--- a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
+++ b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
@@ -52,12 +52,12 @@ public class ParentFirstTestCase extends TestCase {
*
*/
public static Test suite() throws Exception {
- Class thisClass = ParentFirstTestCase.class;
- ClassLoader thisClassLoader = thisClass.getClassLoader();
+ final Class thisClass = ParentFirstTestCase.class;
+ final ClassLoader thisClassLoader = thisClass.getClassLoader();
// Make the parent a direct child of the bootloader to hide all
// other classes in the system classpath
- PathableClassLoader parent = new PathableClassLoader(null);
+ final PathableClassLoader parent = new PathableClassLoader(null);
// Make the junit classes visible as a special case, as junit
// won't be able to call this class at all without this. The
@@ -70,7 +70,7 @@ public class ParentFirstTestCase extends TestCase {
parent.addLogicalLib("commons-logging");
// create a child classloader to load the test case through
- PathableClassLoader child = new PathableClassLoader(parent);
+ final PathableClassLoader child = new PathableClassLoader(parent);
// obviously, the child classloader needs to have the test classes
// in its path!
@@ -78,10 +78,10 @@ public class ParentFirstTestCase extends TestCase {
child.addLogicalLib("commons-logging-adapters");
// create a third classloader to be the context classloader.
- PathableClassLoader context = new PathableClassLoader(child);
+ final PathableClassLoader context = new PathableClassLoader(child);
// reload this class via the child classloader
- Class testClass = child.loadClass(thisClass.getName());
+ final Class testClass = child.loadClass(thisClass.getName());
// and return our custom TestSuite class
return new PathableTestSuite(testClass, context);
@@ -93,7 +93,7 @@ public class ParentFirstTestCase extends TestCase {
* this object instance.
*/
private Set getAncestorCLs() {
- Set s = new HashSet();
+ final Set s = new HashSet();
ClassLoader cl = this.getClass().getClassLoader();
while (cl != null) {
s.add(cl);
@@ -110,14 +110,14 @@ public class ParentFirstTestCase extends TestCase {
*/
public void testPaths() throws Exception {
// the context classloader is not expected to be null
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
assertNotNull("Context classloader is null", contextLoader);
assertEquals("Context classloader has unexpected type",
PathableClassLoader.class.getName(),
contextLoader.getClass().getName());
// the classloader that loaded this class is obviously not null
- ClassLoader thisLoader = this.getClass().getClassLoader();
+ final ClassLoader thisLoader = this.getClass().getClassLoader();
assertNotNull("thisLoader is null", thisLoader);
assertEquals("thisLoader has unexpected type",
PathableClassLoader.class.getName(),
@@ -129,7 +129,7 @@ public class ParentFirstTestCase extends TestCase {
thisLoader, contextLoader.getParent());
// thisLoader's parent should be available
- ClassLoader parentLoader = thisLoader.getParent();
+ final ClassLoader parentLoader = thisLoader.getParent();
assertNotNull("Parent classloader is null", parentLoader);
assertEquals("Parent classloader has unexpected type",
PathableClassLoader.class.getName(),
@@ -141,7 +141,7 @@ public class ParentFirstTestCase extends TestCase {
// getSystemClassloader is not a PathableClassLoader; it's of a
// built-in type. This also verifies that system classloader is none of
// (context, child, parent).
- ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
+ final ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
assertNotNull("System classloader is null", systemLoader);
assertFalse("System classloader has unexpected type",
PathableClassLoader.class.getName().equals(
@@ -150,38 +150,38 @@ public class ParentFirstTestCase extends TestCase {
// junit classes should be visible; their classloader is not
// in the hierarchy of parent classloaders for this class,
// though it is accessable due to trickery in the PathableClassLoader.
- Class junitTest = contextLoader.loadClass("junit.framework.Test");
- Set ancestorCLs = getAncestorCLs();
+ final Class junitTest = contextLoader.loadClass("junit.framework.Test");
+ final Set ancestorCLs = getAncestorCLs();
assertFalse("Junit not loaded by ancestor classloader",
ancestorCLs.contains(junitTest.getClassLoader()));
// jcl api classes should be visible only via the parent
- Class logClass = contextLoader.loadClass("org.apache.commons.logging.Log");
+ final Class logClass = contextLoader.loadClass("org.apache.commons.logging.Log");
assertSame("Log class not loaded via parent",
logClass.getClassLoader(), parentLoader);
// jcl adapter classes should be visible via both parent and child. However
// as the classloaders are parent-first we should see the parent one.
- Class log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
+ final Class log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
assertSame("Log4JLogger not loaded via parent",
log4jClass.getClassLoader(), parentLoader);
// test classes should be visible via the child only
- Class testClass = contextLoader.loadClass("org.apache.commons.logging.PathableTestSuite");
+ final Class testClass = contextLoader.loadClass("org.apache.commons.logging.PathableTestSuite");
assertSame("PathableTestSuite not loaded via child",
testClass.getClassLoader(), thisLoader);
// test loading of class that is not available
try {
- Class noSuchClass = contextLoader.loadClass("no.such.class");
+ final Class noSuchClass = contextLoader.loadClass("no.such.class");
fail("Class no.such.class is unexpectedly available");
assertNotNull(noSuchClass); // silence warning about unused var
- } catch(ClassNotFoundException ex) {
+ } catch(final ClassNotFoundException ex) {
// ok
}
// String class classloader is null
- Class stringClass = contextLoader.loadClass("java.lang.String");
+ final Class stringClass = contextLoader.loadClass("java.lang.String");
assertNull("String class classloader is not null!",
stringClass.getClassLoader());
}
@@ -192,8 +192,8 @@ public class ParentFirstTestCase extends TestCase {
public void testResource() {
URL resource;
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader childLoader = contextLoader.getParent();
+ final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader childLoader = contextLoader.getParent();
// getResource where it doesn't exist
resource = childLoader.getResource("nosuchfile");
@@ -225,10 +225,10 @@ public class ParentFirstTestCase extends TestCase {
URL[] urls;
// verify the classloader hierarchy
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader childLoader = contextLoader.getParent();
- ClassLoader parentLoader = childLoader.getParent();
- ClassLoader bootLoader = parentLoader.getParent();
+ 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);
// getResources where no instances exist
@@ -254,7 +254,7 @@ public class ParentFirstTestCase extends TestCase {
// There is no gaurantee about the ordering of results returned from getResources
// To make this test portable across JVMs, sort the string to give them a known order
- String[] urlsToStrings = new String[2];
+ final String[] urlsToStrings = new String[2];
urlsToStrings[0] = urls[0].toString();
urlsToStrings[1] = urls[1].toString();
Arrays.sort(urlsToStrings);
@@ -268,13 +268,13 @@ public class ParentFirstTestCase extends TestCase {
/**
* Utility method to convert an enumeration-of-URLs into an array of URLs.
*/
- private static URL[] toURLArray(Enumeration e) {
- ArrayList l = new ArrayList();
+ private static URL[] toURLArray(final Enumeration e) {
+ final ArrayList l = new ArrayList();
while (e.hasMoreElements()) {
- URL u = (URL) e.nextElement();
+ final URL u = (URL) e.nextElement();
l.add(u);
}
- URL[] tmp = new URL[l.size()];
+ final URL[] tmp = new URL[l.size()];
return (URL[]) l.toArray(tmp);
}
@@ -285,10 +285,10 @@ public class ParentFirstTestCase extends TestCase {
java.io.InputStream is;
// verify the classloader hierarchy
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader childLoader = contextLoader.getParent();
- ClassLoader parentLoader = childLoader.getParent();
- ClassLoader bootLoader = parentLoader.getParent();
+ 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);
// getResourceAsStream where no instances exist
diff --git a/src/test/java/org/apache/commons/logging/security/DummyClass.java b/src/test/java/org/apache/commons/logging/security/DummyClass.java
index ece0e7c..0b07c39 100644
--- a/src/test/java/org/apache/commons/logging/security/DummyClass.java
+++ b/src/test/java/org/apache/commons/logging/security/DummyClass.java
@@ -15,7 +15,7 @@ import org.apache.commons.logging.LogFactory;
public class DummyClass {
public DummyClass() {
- Log log = LogFactory.getLog(DummyClass.class);
+ final Log log = LogFactory.getLog(DummyClass.class);
log.info("Some log message");
}
}
diff --git a/src/test/java/org/apache/commons/logging/security/MockSecurityManager.java b/src/test/java/org/apache/commons/logging/security/MockSecurityManager.java
index 4d7d3ba..b48c5e4 100644
--- a/src/test/java/org/apache/commons/logging/security/MockSecurityManager.java
+++ b/src/test/java/org/apache/commons/logging/security/MockSecurityManager.java
@@ -42,7 +42,7 @@ public class MockSecurityManager extends SecurityManager {
* Define the set of permissions to be granted to classes in the o.a.c.l package,
* but NOT to unit-test classes in o.a.c.l.security package.
*/
- public void addPermission(Permission p) {
+ public void addPermission(final Permission p) {
permissions.add(p);
}
@@ -58,7 +58,7 @@ public class MockSecurityManager extends SecurityManager {
return untrustedCodeCount;
}
- public void checkPermission(Permission p) throws SecurityException {
+ public void checkPermission(final Permission p) throws SecurityException {
if (setSecurityManagerPerm.implies(p)) {
// ok, allow this; we don't want to block any calls to setSecurityManager
// otherwise this custom security manager cannot be reset to the original.
@@ -69,7 +69,7 @@ public class MockSecurityManager extends SecurityManager {
// Allow read-only access to files, as this is needed to load classes!
// Ideally, we would limit this to just .class and .jar files.
if (p instanceof FilePermission) {
- FilePermission fp = (FilePermission) p;
+ final FilePermission fp = (FilePermission) p;
if (fp.getActions().equals("read")) {
// System.out.println("Permit read of files");
return;
@@ -78,14 +78,14 @@ public class MockSecurityManager extends SecurityManager {
System.out.println("\n\ntesting permission:" + p.getClass() + ":"+ p);
- Exception e = new Exception();
+ final Exception e = new Exception();
e.fillInStackTrace();
- StackTraceElement[] stack = e.getStackTrace();
+ final StackTraceElement[] stack = e.getStackTrace();
// scan the call stack from most recent to oldest.
// start at 1 to skip the entry in the stack for this method
for(int i=1; i