1
0

Remove trailing spaces.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@1432580 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart
2013-01-13 10:41:05 +00:00
parent 45182accb1
commit 81e90d14a3
15 changed files with 480 additions and 549 deletions

View File

@@ -340,7 +340,6 @@ public abstract class LogFactory {
try {
Class implementationClass = Class.forName(storeImplementationClass);
result = (Hashtable) implementationClass.newInstance();
} catch (Throwable t) {
// ignore
if (!WEAK_HASHTABLE_CLASSNAME.equals(storeImplementationClass)) {
@@ -365,10 +364,10 @@ public abstract class LogFactory {
/** Utility method to safely trim a string. */
private static String trim(String src) {
if (src == null) {
return null;
}
return src.trim();
if (src == null) {
return null;
}
return src.trim();
}
/**
@@ -422,8 +421,8 @@ public abstract class LogFactory {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] LogFactory implementation requested for the first time for context classloader "
+ objectId(contextClassLoader));
"[LOOKUP] LogFactory implementation requested for the first time for context classloader " +
objectId(contextClassLoader));
logHierarchy("[LOOKUP] ", contextClassLoader);
}
@@ -463,35 +462,28 @@ public abstract class LogFactory {
// Determine which concrete LogFactory subclass to use.
// First, try a global system property
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Looking for system property [" + FACTORY_PROPERTY
+ "] to define the LogFactory subclass to use...");
logDiagnostic("[LOOKUP] Looking for system property [" + FACTORY_PROPERTY +
"] to define the LogFactory subclass to use...");
}
try {
String factoryClass = getSystemProperty(FACTORY_PROPERTY, null);
if (factoryClass != null) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Creating an instance of LogFactory class '" + factoryClass
+ "' as specified by system property " + FACTORY_PROPERTY);
logDiagnostic("[LOOKUP] Creating an instance of LogFactory class '" + factoryClass +
"' as specified by system property " + FACTORY_PROPERTY);
}
factory = newFactory(factoryClass, baseClassLoader, contextClassLoader);
} else {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] No system property [" + FACTORY_PROPERTY
+ "] defined.");
logDiagnostic("[LOOKUP] No system property [" + FACTORY_PROPERTY + "] defined.");
}
}
} catch (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...");
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) {
@@ -501,11 +493,9 @@ public abstract class LogFactory {
// One possible exception that can occur here is a ClassCastException when
// the specified class wasn't castable to this LogFactory type.
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] An exception occurred while trying to create an"
+ " instance of the custom factory class"
+ ": [" + trim(e.getMessage())
+ "] as specified by a system property.");
logDiagnostic("[LOOKUP] An exception occurred while trying to create an" +
" instance of the custom factory class" + ": [" + trim(e.getMessage()) +
"] as specified by a system property.");
}
throw e;
}
@@ -518,9 +508,8 @@ public abstract class LogFactory {
if (factory == null) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Looking for a resource file of name [" + SERVICE_ID
+ "] to define the LogFactory subclass to use...");
logDiagnostic("[LOOKUP] Looking for a resource file of name [" + SERVICE_ID +
"] to define the LogFactory subclass to use...");
}
try {
InputStream is = getResourceAsStream(contextClassLoader,
@@ -542,20 +531,16 @@ public abstract class LogFactory {
if (factoryClassName != null &&
! "".equals(factoryClassName)) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] Creating an instance of LogFactory class " + factoryClassName
+ " as specified by file '" + SERVICE_ID
+ "' which was present in the path of the context"
+ " classloader.");
logDiagnostic("[LOOKUP] Creating an instance of LogFactory class " + factoryClassName +
" as specified by file '" + SERVICE_ID +
"' which was present in the path of the context classloader.");
}
factory = newFactory(factoryClassName, baseClassLoader, contextClassLoader );
}
} else {
// is == null
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[LOOKUP] No resource file with name '" + SERVICE_ID
+ "' found.");
logDiagnostic("[LOOKUP] No resource file with name '" + SERVICE_ID + "' found.");
}
}
} catch( Exception ex ) {
@@ -869,13 +854,11 @@ public abstract class LogFactory {
try {
// Are we running on a JDK 1.2 or later system?
Method method = Thread.class.getMethod("getContextClassLoader",
(Class[]) null);
Method method = Thread.class.getMethod("getContextClassLoader", (Class[]) null);
// Get the thread context class loader (if there is one)
try {
classLoader = (ClassLoader)method.invoke(Thread.currentThread(),
(Object[]) null);
classLoader = (ClassLoader)method.invoke(Thread.currentThread(), (Object[]) null);
} catch (IllegalAccessException e) {
throw new LogConfigurationException
("Unexpected IllegalAccessException", e);
@@ -920,7 +903,6 @@ public abstract class LogFactory {
// + " classloader is the same as the class that loaded"
// + " the concrete LogFactory class.");
// }
}
// Return the selected class loader
@@ -1040,16 +1022,13 @@ public abstract class LogFactory {
if (result instanceof LogConfigurationException) {
LogConfigurationException ex = (LogConfigurationException) result;
if (isDiagnosticsEnabled()) {
logDiagnostic(
"An error occurred while loading the factory class:"
+ ex.getMessage());
logDiagnostic("An error occurred while loading the factory class:" + ex.getMessage());
}
throw ex;
}
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Created object " + objectId(result)
+ " to manage classloader " + objectId(contextClassLoader));
logDiagnostic("Created object " + objectId(result) + " to manage classloader " +
objectId(contextClassLoader));
}
return (LogFactory)result;
}
@@ -1234,9 +1213,7 @@ public abstract class LogFactory {
if (isDiagnosticsEnabled()) {
logDiagnostic("Unable to create LogFactory instance.");
}
if (logFactoryClass != null
&& !LogFactory.class.isAssignableFrom(logFactoryClass)) {
if (logFactoryClass != null && !LogFactory.class.isAssignableFrom(logFactoryClass)) {
return new LogConfigurationException(
"The chosen LogFactory implementation does not extend LogFactory."
+ " Please check your configuration.",
@@ -1356,9 +1333,8 @@ public abstract class LogFactory {
}
} catch(IOException e) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Exception while trying to find configuration file "
+ name + ":" + e.getMessage());
logDiagnostic("Exception while trying to find configuration file " +
name + ":" + e.getMessage());
}
return null;
} catch(NoSuchMethodError e) {
@@ -1512,13 +1488,9 @@ public abstract class LogFactory {
if (isDiagnosticsEnabled()) {
if (props == null) {
logDiagnostic(
"[LOOKUP] No properties file of name '" + fileName
+ "' found.");
logDiagnostic("[LOOKUP] No properties file of name '" + fileName + "' found.");
} else {
logDiagnostic(
"[LOOKUP] Properties file of name '" + fileName
+ "' found at '" + propsUrl + '"');
logDiagnostic("[LOOKUP] Properties file of name '" + fileName + "' found at '" + propsUrl + '"');
}
}
@@ -1675,9 +1647,7 @@ public abstract class LogFactory {
return;
}
logDiagnostic(
"[ENV] Class " + className + " was loaded via classloader "
+ objectId(classLoader));
logDiagnostic("[ENV] Class " + className + " was loaded via classloader " + objectId(classLoader));
logHierarchy("[ENV] Ancestry of classloader which loaded " + className + " is ", classLoader);
}
@@ -1701,8 +1671,7 @@ public abstract class LogFactory {
try {
systemClassLoader = ClassLoader.getSystemClassLoader();
} catch(SecurityException ex) {
logDiagnostic(
prefix + "Security forbids determining the system classloader.");
logDiagnostic(prefix + "Security forbids determining the system classloader.");
return;
}
if (classLoader != null) {

View File

@@ -70,7 +70,9 @@ public class LogFactoryImpl extends LogFactory {
/** Jdk14Logger class name */
private static final String LOGGING_IMPL_JDK14_LOGGER = "org.apache.commons.logging.impl.Jdk14Logger";
/** Jdk13LumberjackLogger class name */
private static final String LOGGING_IMPL_LUMBERJACK_LOGGER = "org.apache.commons.logging.impl.Jdk13LumberjackLogger";
private static final String LOGGING_IMPL_LUMBERJACK_LOGGER =
"org.apache.commons.logging.impl.Jdk13LumberjackLogger";
/** SimpleLog class name */
private static final String LOGGING_IMPL_SIMPLE_LOGGER = "org.apache.commons.logging.impl.SimpleLog";
@@ -127,7 +129,7 @@ public class LogFactoryImpl extends LogFactory {
* exception will be thrown and the app will fail to start. When set
* to true, discovery will continue (though the user might end up
* with a different logging implementation than they expected).
*
* <p>
* Default behaviour: true (tolerates bad logging adapters)
*
* See also method setAttribute.
@@ -143,7 +145,7 @@ public class LogFactoryImpl extends LogFactory {
* When set to false, an exception will be thrown and the app will fail
* to start. When set to true, discovery will continue (though the user
* might end up with a different logging implementation than they expected).
*
* <p>
* Default behaviour: true (tolerates bad Log class hierarchy)
*
* See also method setAttribute.
@@ -499,10 +501,10 @@ public class LogFactoryImpl extends LogFactory {
}
/**
* <p>Return <code>true</code> if <em>JDK 1.4 or later</em> logging
* Return <code>true</code> if <em>JDK 1.4 or later</em> logging
* is available. Also checks that the <code>Throwable</code> class
* supports <code>getStackTrace()</code>, which is required by
* Jdk14Logger.</p>
* Jdk14Logger.
*
* @deprecated Never invoked by this class; subclasses should not assume
* it will be.
@@ -975,11 +977,7 @@ public class LogFactoryImpl extends LogFactory {
for(;;) {
// Loop through the classloader hierarchy trying to find
// a viable classloader.
logDiagnostic(
"Trying to load '"
+ logAdapterClassName
+ "' from classloader "
+ objectId(currentCL));
logDiagnostic("Trying to load '" + logAdapterClassName + "' from classloader " + objectId(currentCL));
try {
if (isDiagnosticsEnabled()) {
// Show the location of the first occurrence of the .class file
@@ -1009,13 +1007,8 @@ public class LogFactoryImpl extends LogFactory {
// in this or any ancestor classloader. There's no point in
// trying higher up in the hierarchy in this case..
String msg = originalClassNotFoundException.getMessage();
logDiagnostic(
"The log adapter '"
+ logAdapterClassName
+ "' is not available via classloader "
+ objectId(currentCL)
+ ": "
+ msg.trim());
logDiagnostic("The log adapter '" + logAdapterClassName + "' is not available via classloader " +
objectId(currentCL) + ": " + msg.trim());
try {
// Try the class classloader.
// This may work in cases where the TCCL
@@ -1028,11 +1021,8 @@ public class LogFactoryImpl extends LogFactory {
} catch (ClassNotFoundException secondaryClassNotFoundException) {
// no point continuing: this adapter isn't available
msg = secondaryClassNotFoundException.getMessage();
logDiagnostic(
"The log adapter '"
+ logAdapterClassName
+ "' is not available via the LogFactoryImpl class classloader: "
+ msg.trim());
logDiagnostic("The log adapter '" + logAdapterClassName +
"' is not available via the LogFactoryImpl class classloader: " + msg.trim());
break;
}
}
@@ -1068,13 +1058,9 @@ public class LogFactoryImpl extends LogFactory {
// ancestor classloader. There's no point in trying higher up
// in the hierarchy in this case..
String msg = e.getMessage();
logDiagnostic(
"The log adapter '"
+ logAdapterClassName
+ "' is missing dependencies when loaded via classloader "
+ objectId(currentCL)
+ ": "
+ msg.trim());
logDiagnostic("The log adapter '" + logAdapterClassName +
"' is missing dependencies when loaded via classloader " + objectId(currentCL) +
": " + msg.trim());
break;
} catch (ExceptionInInitializerError e) {
// A static initializer block or the initializer code associated
@@ -1084,13 +1070,9 @@ public class LogFactoryImpl extends LogFactory {
// We treat this as meaning the adapter's underlying logging
// library could not be found.
String msg = e.getMessage();
logDiagnostic(
"The log adapter '"
+ logAdapterClassName
+ "' is unable to initialize itself when loaded via classloader "
+ objectId(currentCL)
+ ": "
+ msg.trim());
logDiagnostic("The log adapter '" + logAdapterClassName +
"' is unable to initialize itself when loaded via classloader " + objectId(currentCL) +
": " + msg.trim());
break;
} catch(LogConfigurationException e) {
// call to handleFlawedHierarchy above must have thrown
@@ -1121,21 +1103,15 @@ public class LogFactoryImpl extends LogFactory {
try {
this.logMethod = logAdapterClass.getMethod("setLogFactory",
logMethodSignature);
logDiagnostic("Found method setLogFactory(LogFactory) in '"
+ logAdapterClassName + "'");
logDiagnostic("Found method setLogFactory(LogFactory) in '" + logAdapterClassName + "'");
} catch (Throwable t) {
this.logMethod = null;
logDiagnostic(
"[INFO] '" + logAdapterClassName
+ "' from classloader " + objectId(currentCL)
+ " does not declare optional method "
+ "setLogFactory(LogFactory)");
logDiagnostic("[INFO] '" + logAdapterClassName + "' from classloader " + objectId(currentCL) +
" does not declare optional method " + "setLogFactory(LogFactory)");
}
logDiagnostic(
"Log adapter '" + logAdapterClassName
+ "' from classloader " + objectId(logAdapterClass.getClassLoader())
+ " has been selected for use.");
logDiagnostic("Log adapter '" + logAdapterClassName + "' from classloader " +
objectId(logAdapterClass.getClassLoader()) + " has been selected for use.");
}
return logAdapter;
@@ -1178,10 +1154,9 @@ public class LogFactoryImpl extends LogFactory {
// forbidden it, just return the contextClassLoader.
if (allowFlawedContext) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"[WARNING] the context classloader is not part of a"
+ " parent-child relationship with the classloader that"
+ " loaded LogFactoryImpl.");
logDiagnostic("[WARNING] the context classloader is not part of a" +
" parent-child relationship with the classloader that" +
" loaded LogFactoryImpl.");
}
// If contextClassLoader were null, getLowestClassLoader() would
// have returned thisClassLoader. The fact we are here means
@@ -1189,10 +1164,9 @@ public class LogFactoryImpl extends LogFactory {
return contextClassLoader;
}
else {
throw new LogConfigurationException(
"Bad classloader hierarchy; LogFactoryImpl was loaded via"
+ " a classloader that is not related to the current context"
+ " classloader.");
throw new LogConfigurationException("Bad classloader hierarchy; LogFactoryImpl was loaded via" +
" a classloader that is not related to the current context" +
" classloader.");
}
}
@@ -1205,17 +1179,17 @@ public class LogFactoryImpl extends LogFactory {
if (allowFlawedContext) {
if (isDiagnosticsEnabled()) {
logDiagnostic(
"Warning: the context classloader is an ancestor of the"
+ " classloader that loaded LogFactoryImpl; it should be"
+ " the same or a descendant. The application using"
+ " commons-logging should ensure the context classloader"
+ " is used correctly.");
"Warning: the context classloader is an ancestor of the" +
" classloader that loaded LogFactoryImpl; it should be" +
" the same or a descendant. The application using" +
" commons-logging should ensure the context classloader" +
" is used correctly.");
}
} else {
throw new LogConfigurationException(
"Bad classloader hierarchy; LogFactoryImpl was loaded via"
+ " a classloader that is not related to the current context"
+ " classloader.");
"Bad classloader hierarchy; LogFactoryImpl was loaded via" +
" a classloader that is not related to the current context" +
" classloader.");
}
}
@@ -1288,10 +1262,10 @@ public class LogFactoryImpl extends LogFactory {
Throwable discoveryFlaw) {
if (isDiagnosticsEnabled()) {
logDiagnostic("Could not instantiate Log '"
+ logAdapterClassName + "' -- "
+ discoveryFlaw.getClass().getName() + ": "
+ discoveryFlaw.getLocalizedMessage());
logDiagnostic("Could not instantiate Log '" +
logAdapterClassName + "' -- " +
discoveryFlaw.getClass().getName() + ": " +
discoveryFlaw.getLocalizedMessage());
if (discoveryFlaw instanceof InvocationTargetException ) {
// Ok, the lib is there but while trying to create a real underlying
@@ -1326,7 +1300,7 @@ public class LogFactoryImpl extends LogFactory {
* Report a problem loading the log adapter, then either return
* (if the situation is considered recoverable) or throw a
* LogConfigurationException.
* <p>
* <p>
* There are two possible reasons why we successfully loaded the
* specified log adapter class then failed to cast it to a Log object:
* <ol>
@@ -1367,17 +1341,11 @@ public class LogFactoryImpl extends LogFactory {
if (isDiagnosticsEnabled()) {
try {
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));
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) {
logDiagnostic(
"Error while trying to output diagnostics about"
+ " bad class '" + badClass + "'");
logDiagnostic("Error while trying to output diagnostics about" + " bad class '" + badClass + "'");
}
}

View File

@@ -598,8 +598,7 @@ 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);
classLoader = (ClassLoader)method.invoke(Thread.currentThread(), (Class[]) null);
} catch (IllegalAccessException e) {
// ignore
} catch (InvocationTargetException e) {

View File

@@ -15,7 +15,6 @@
* limitations under the License.
*/
package org.apache.commons.logging.impl;
import java.lang.ref.ReferenceQueue;
@@ -143,7 +142,6 @@ public final class WeakHashtable extends Hashtable {
*/
public WeakHashtable() {}
/**
*@see Hashtable
*/
@@ -207,7 +205,6 @@ public final class WeakHashtable extends Hashtable {
};
}
/**
*@see Hashtable
*/
@@ -341,7 +338,6 @@ public final class WeakHashtable extends Hashtable {
* has been garbage collected.
*/
private void purgeOne() {
synchronized (queue) {
WeakKey key = (WeakKey) queue.poll();
if (key != null) {
@@ -395,7 +391,6 @@ public final class WeakHashtable extends Hashtable {
}
}
/** Wrapper giving correct symantics for equals and hashcode */
private final static class Referenced {