1
0

Use final.

This commit is contained in:
Gary Gregory
2020-11-20 22:12:48 -05:00
parent 896fbd2f56
commit 66aa7aacbe
60 changed files with 805 additions and 805 deletions

View File

@@ -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
}

View File

@@ -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 <code>Log</code>
* 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 <code>Log</code>
* 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 {
* <code>LogFactory</code> when that class is loaded via the same
* classloader that loaded the <code>logFactoryClass</code>.
*/
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 + "] ";

View File

@@ -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 <code>Log</code> 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 <code>Log</code> 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) {

View File

@@ -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));
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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 <code>Log</code>
* 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 <code>Log</code>
* 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 <code>null</code>
* 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 <i>not</i>
* 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.");

View File

@@ -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);
}

View File

@@ -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.

View File

@@ -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
}
}

View File

@@ -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 <code>StringBuffer</code> 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);

View File

@@ -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 <code>null</code>
*/
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 <code>null</code>
*/
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;
}