Modified:
websites/production/commons/content/proper/commons-logging/jacoco/org.apache.commons.logging/LogFactory.java.html
==============================================================================
---
websites/production/commons/content/proper/commons-logging/jacoco/org.apache.commons.logging/LogFactory.java.html
(original)
+++
websites/production/commons/content/proper/commons-logging/jacoco/org.apache.commons.logging/LogFactory.java.html
Thu Jul 4 12:10:51 2024
@@ -43,6 +43,7 @@ import java.util.ServiceLoader;
* <strong>IMPLEMENTATION NOTE</strong> - This implementation is
heavily
* based on the SAXParserFactory and DocumentBuilderFactory implementations
* (corresponding to the JAXP pluggability APIs) found in Apache Xerces.
+ * </p>
*/
public abstract class LogFactory {
// Implementation note re AccessController usage
@@ -156,15 +157,19 @@ public abstract class LogFactory {
* class loaders to be substituted by an alternative implementation.
* <p>
* <strong>Note:</strong> {@code LogFactory} will print:
+ * </p>
* <pre>
* [ERROR] LogFactory: Load of custom hashtable failed
* </pre>
+ * <p>
* to system error and then continue using a standard Hashtable.
+ * </p>
* <p>
* <strong>Usage:</strong> Set this property when Java is
invoked
* and {@code LogFactory} will attempt to load a new instance
* of the given implementation class.
* For example, running the following ant scriplet:
+ * </p>
* <pre>
* &lt;java classname="${test.runner}" fork="yes"
failonerror="${test.failonerror}"&gt;
* ...
@@ -173,13 +178,16 @@ public abstract class LogFactory {
*
value="org.apache.commons.logging.AltHashtable"/&gt;
* &lt;/java&gt;
* </pre>
+ * <p>
* will mean that {@code LogFactory} will load an instance of
* {@code org.apache.commons.logging.AltHashtable}.
+ * </p>
* <p>
* A typical use case is to allow a custom
* Hashtable implementation using weak references to be substituted.
* This will allow class loaders to be garbage collected without
* the need to release them (on 1.3+ JVMs only, of course ;).
+ * </p>
*/
public static final String HASHTABLE_IMPLEMENTATION_PROPERTY =
"org.apache.commons.logging.LogFactory.HashtableImpl";
@@ -230,8 +238,8 @@ public abstract class LogFactory {
static {
// note: it's safe to call methods before initDiagnostics (though
// diagnostic output gets discarded).
-<span class="fc" id="L233"> final ClassLoader thisClassLoader =
getClassLoader(LogFactory.class);</span>
-<span class="fc" id="L234"> thisClassLoaderRef = new
WeakReference<>(thisClassLoader);</span>
+<span class="fc" id="L241"> final ClassLoader thisClassLoader =
getClassLoader(LogFactory.class);</span>
+<span class="fc" id="L242"> thisClassLoaderRef = new
WeakReference<>(thisClassLoader);</span>
// In order to avoid confusion where multiple instances of JCL are
// being used via different class loaders within the same app, we
// ensure each logged message has a prefix of form
@@ -243,22 +251,22 @@ public abstract class LogFactory {
// output diagnostics from this class are static.
String classLoaderName;
try {
-<span class="pc bpc" id="L246" title="1 of 2 branches missed."> if
(thisClassLoader == null) {</span>
-<span class="nc" id="L247"> classLoaderName =
"BOOTLOADER";</span>
+<span class="pc bpc" id="L254" title="1 of 2 branches missed."> if
(thisClassLoader == null) {</span>
+<span class="nc" id="L255"> classLoaderName =
"BOOTLOADER";</span>
} else {
-<span class="fc" id="L249"> classLoaderName =
objectId(thisClassLoader);</span>
+<span class="fc" id="L257"> classLoaderName =
objectId(thisClassLoader);</span>
}
-<span class="nc" id="L251"> } catch (final SecurityException e) {</span>
-<span class="nc" id="L252"> classLoaderName =
"UNKNOWN";</span>
-<span class="fc" id="L253"> }</span>
-<span class="fc" id="L254"> diagnosticPrefix = "[LogFactory from
" + classLoaderName + "] ";</span>
-<span class="fc" id="L255"> DIAGNOSTICS_STREAM =
initDiagnostics();</span>
-<span class="fc" id="L256">
logClassLoaderEnvironment(LogFactory.class);</span>
-<span class="fc" id="L257"> factories = createFactoryStore();</span>
-<span class="pc bpc" id="L258" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L259"> logDiagnostic("BOOTSTRAP
COMPLETED");</span>
+<span class="nc" id="L259"> } catch (final SecurityException e) {</span>
+<span class="nc" id="L260"> classLoaderName =
"UNKNOWN";</span>
+<span class="fc" id="L261"> }</span>
+<span class="fc" id="L262"> diagnosticPrefix = "[LogFactory from
" + classLoaderName + "] ";</span>
+<span class="fc" id="L263"> DIAGNOSTICS_STREAM =
initDiagnostics();</span>
+<span class="fc" id="L264">
logClassLoaderEnvironment(LogFactory.class);</span>
+<span class="fc" id="L265"> factories = createFactoryStore();</span>
+<span class="pc bpc" id="L266" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L267"> logDiagnostic("BOOTSTRAP
COMPLETED");</span>
}
-<span class="fc" id="L261"> }</span>
+<span class="fc" id="L269"> }</span>
/**
* Remember this factory, so later calls to LogFactory.getCachedFactory
@@ -273,14 +281,14 @@ public abstract class LogFactory {
// Ideally we would assert(factory != null) here. However reporting
// errors from within a logging implementation is a little tricky!
-<span class="pc bpc" id="L276" title="1 of 2 branches missed."> if
(factory != null) {</span>
-<span class="fc bfc" id="L277" title="All 2 branches covered."> if
(classLoader == null) {</span>
-<span class="fc" id="L278"> nullClassLoaderFactory =
factory;</span>
+<span class="pc bpc" id="L284" title="1 of 2 branches missed."> if
(factory != null) {</span>
+<span class="fc bfc" id="L285" title="All 2 branches covered."> if
(classLoader == null) {</span>
+<span class="fc" id="L286"> nullClassLoaderFactory =
factory;</span>
} else {
-<span class="fc" id="L280"> factories.put(classLoader,
factory);</span>
+<span class="fc" id="L288"> factories.put(classLoader,
factory);</span>
}
}
-<span class="fc" id="L283"> }</span>
+<span class="fc" id="L291"> }</span>
/**
* Implements the operations described in the Javadoc for newFactory.
@@ -294,18 +302,18 @@ public abstract class LogFactory {
protected static Object createFactory(final String factoryClassName, final
ClassLoader classLoader) {
// This will be used to diagnose bad configurations
// and allow a useful message to be sent to the user
-<span class="fc" id="L297"> Class<?> logFactoryClass =
null;</span>
+<span class="fc" id="L305"> Class<?> logFactoryClass =
null;</span>
try {
-<span class="pc bpc" id="L299" title="1 of 2 branches missed."> if
(classLoader != null) {</span>
+<span class="pc bpc" id="L307" title="1 of 2 branches missed."> if
(classLoader != null) {</span>
try {
// First the given class loader param (thread class loader)
// Warning: must typecast here & allow exception
// to be generated/caught & recast properly.
-<span class="fc" id="L305"> logFactoryClass =
classLoader.loadClass(factoryClassName);</span>
-<span class="pc bpc" id="L306" title="1 of 2 branches missed.">
if (LogFactory.class.isAssignableFrom(logFactoryClass)) {</span>
-<span class="pc bpc" id="L307" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L308">
logDiagnostic("Loaded class " + logFactoryClass.getName() + "
from class loader " + objectId(classLoader));</span>
+<span class="fc" id="L313"> logFactoryClass =
classLoader.loadClass(factoryClassName);</span>
+<span class="pc bpc" id="L314" title="1 of 2 branches missed.">
if (LogFactory.class.isAssignableFrom(logFactoryClass)) {</span>
+<span class="pc bpc" id="L315" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L316">
logDiagnostic("Loaded class " + logFactoryClass.getName() + "
from class loader " + objectId(classLoader));</span>
}
} else //
// This indicates a problem with the ClassLoader tree.
@@ -318,72 +326,72 @@ public abstract class LogFactory {
// problem is to remove the extra JCL jars from the
// ClassLoader hierarchy.
//
-<span class="nc bnc" id="L321" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L322"> logDiagnostic("Factory
class " + logFactoryClass.getName() + " loaded from class loader
" + objectId(logFactoryClass.getClassLoader())</span>
-<span class="nc" id="L323"> + " does not
extend '" + LogFactory.class.getName() + "' as loaded by this class
loader.");</span>
-<span class="nc" id="L324"> logHierarchy("[BAD CL
TREE] ", classLoader);</span>
+<span class="nc bnc" id="L329" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L330"> logDiagnostic("Factory
class " + logFactoryClass.getName() + " loaded from class loader
" + objectId(logFactoryClass.getClassLoader())</span>
+<span class="nc" id="L331"> + " does not
extend '" + LogFactory.class.getName() + "' as loaded by this class
loader.");</span>
+<span class="nc" id="L332"> logHierarchy("[BAD CL
TREE] ", classLoader);</span>
}
-<span class="fc" id="L327"> return
logFactoryClass.getConstructor().newInstance();</span>
+<span class="fc" id="L335"> return
logFactoryClass.getConstructor().newInstance();</span>
-<span class="fc" id="L329"> } catch (final
ClassNotFoundException ex) {</span>
-<span class="pc bpc" id="L330" title="1 of 2 branches missed.">
if (classLoader == thisClassLoaderRef.get()) {</span>
+<span class="fc" id="L337"> } catch (final
ClassNotFoundException ex) {</span>
+<span class="pc bpc" id="L338" title="1 of 2 branches missed.">
if (classLoader == thisClassLoaderRef.get()) {</span>
// Nothing more to try, onwards.
-<span class="pc bpc" id="L332" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L333">
logDiagnostic("Unable to locate any class called '" +
factoryClassName + "' via class loader " +
objectId(classLoader));</span>
+<span class="pc bpc" id="L340" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L341">
logDiagnostic("Unable to locate any class called '" +
factoryClassName + "' via class loader " +
objectId(classLoader));</span>
}
-<span class="fc" id="L335"> throw ex;</span>
+<span class="fc" id="L343"> throw ex;</span>
}
// ignore exception, continue
-<span class="nc" id="L338"> } catch (final NoClassDefFoundError
e) {</span>
-<span class="nc bnc" id="L339" title="All 2 branches missed.">
if (classLoader == thisClassLoaderRef.get()) {</span>
+<span class="nc" id="L346"> } catch (final NoClassDefFoundError
e) {</span>
+<span class="nc bnc" id="L347" title="All 2 branches missed.">
if (classLoader == thisClassLoaderRef.get()) {</span>
// Nothing more to try, onwards.
-<span class="nc bnc" id="L341" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L342">
logDiagnostic("Class '" + factoryClassName + "' cannot be
loaded" + " via class loader " + objectId(classLoader)</span>
+<span class="nc bnc" id="L349" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L350">
logDiagnostic("Class '" + factoryClassName + "' cannot be
loaded" + " via class loader " + objectId(classLoader)</span>
+ " - it depends on some other class
that cannot be found.");
}
-<span class="nc" id="L345"> throw e;</span>
+<span class="nc" id="L353"> throw e;</span>
}
// ignore exception, continue
-<span class="nc" id="L348"> } catch (final ClassCastException
e) {</span>
-<span class="nc bnc" id="L349" title="All 2 branches missed.">
if (classLoader == thisClassLoaderRef.get()) {</span>
+<span class="nc" id="L356"> } catch (final ClassCastException
e) {</span>
+<span class="nc bnc" id="L357" title="All 2 branches missed.">
if (classLoader == thisClassLoaderRef.get()) {</span>
// There's no point in falling through to the code
below that
// tries again with thisClassLoaderRef, because we've
just tried
// loading with that loader (not the TCCL). Just throw
an
// appropriate exception here.
-<span class="nc" id="L355"> final boolean
implementsLogFactory = implementsLogFactory(logFactoryClass);</span>
+<span class="nc" id="L363"> final boolean
implementsLogFactory = implementsLogFactory(logFactoryClass);</span>
//
// Construct a good message: users may not actual
expect that a custom implementation
// has been specified. Several well known containers
use this mechanism to adapt JCL
// to their native logging system.
//
-<span class="nc" id="L362"> final StringBuilder msg =
new StringBuilder();</span>
-<span class="nc" id="L363"> msg.append("The
application has specified that a custom LogFactory implementation
");</span>
-<span class="nc" id="L364"> msg.append("should be
used but Class '");</span>
-<span class="nc" id="L365">
msg.append(factoryClassName);</span>
-<span class="nc" id="L366"> msg.append("' cannot
be converted to '");</span>
-<span class="nc" id="L367">
msg.append(LogFactory.class.getName());</span>
-<span class="nc" id="L368"> msg.append("'.
");</span>
-<span class="nc bnc" id="L369" title="All 2 branches missed.">
if (implementsLogFactory) {</span>
-<span class="nc" id="L370"> msg.append("The
conflict is caused by the presence of multiple LogFactory classes
");</span>
-<span class="nc" id="L371"> msg.append("in
incompatible class loaders. ");</span>
-<span class="nc" id="L372">
msg.append("Background can be found in
https://commons.apache.org/logging/tech.html. ");</span>
-<span class="nc" id="L373"> msg.append("If you
have not explicitly specified a custom LogFactory then it is likely
");</span>
-<span class="nc" id="L374"> msg.append("that
the container has set one without your knowledge. ");</span>
-<span class="nc" id="L375"> msg.append("In
this case, consider using the commons-logging-adapters.jar file or
");</span>
-<span class="nc" id="L376">
msg.append("specifying the standard LogFactory from the command line.
");</span>
+<span class="nc" id="L370"> final StringBuilder msg =
new StringBuilder();</span>
+<span class="nc" id="L371"> msg.append("The
application has specified that a custom LogFactory implementation
");</span>
+<span class="nc" id="L372"> msg.append("should be
used but Class '");</span>
+<span class="nc" id="L373">
msg.append(factoryClassName);</span>
+<span class="nc" id="L374"> msg.append("' cannot
be converted to '");</span>
+<span class="nc" id="L375">
msg.append(LogFactory.class.getName());</span>
+<span class="nc" id="L376"> msg.append("'.
");</span>
+<span class="nc bnc" id="L377" title="All 2 branches missed.">
if (implementsLogFactory) {</span>
+<span class="nc" id="L378"> msg.append("The
conflict is caused by the presence of multiple LogFactory classes
");</span>
+<span class="nc" id="L379"> msg.append("in
incompatible class loaders. ");</span>
+<span class="nc" id="L380">
msg.append("Background can be found in
https://commons.apache.org/logging/tech.html. ");</span>
+<span class="nc" id="L381"> msg.append("If you
have not explicitly specified a custom LogFactory then it is likely
");</span>
+<span class="nc" id="L382"> msg.append("that
the container has set one without your knowledge. ");</span>
+<span class="nc" id="L383"> msg.append("In
this case, consider using the commons-logging-adapters.jar file or
");</span>
+<span class="nc" id="L384">
msg.append("specifying the standard LogFactory from the command line.
");</span>
} else {
-<span class="nc" id="L378"> msg.append("Please
check the custom implementation. ");</span>
+<span class="nc" id="L386"> msg.append("Please
check the custom implementation. ");</span>
}
-<span class="nc" id="L380"> msg.append("Help can
be found at
https://commons.apache.org/logging/troubleshooting.html.");</span>
+<span class="nc" id="L388"> msg.append("Help can
be found at
https://commons.apache.org/logging/troubleshooting.html.");</span>
-<span class="nc bnc" id="L382" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L383">
logDiagnostic(msg.toString());</span>
+<span class="nc bnc" id="L390" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L391">
logDiagnostic(msg.toString());</span>
}
-<span class="nc" id="L386"> throw new
ClassCastException(msg.toString());</span>
+<span class="nc" id="L394"> throw new
ClassCastException(msg.toString());</span>
}
// Ignore exception, continue. Presumably the class loader
was the
@@ -398,7 +406,7 @@ public abstract class LogFactory {
// in a shared classpath. In that case:
// (a) the class really does implement LogFactory (bad log
msg above)
// (b) the fallback code will result in exactly the same
problem.
-<span class="nc" id="L401"> }</span>
+<span class="nc" id="L409"> }</span>
}
/*
@@ -412,22 +420,22 @@ public abstract class LogFactory {
*/
// Warning: must typecast here & allow exception
// to be generated/caught & recast properly.
-<span class="nc bnc" id="L415" title="All 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L416"> logDiagnostic(</span>
-<span class="nc" id="L417"> "Unable to load
factory class via class loader " + objectId(classLoader) + " - trying
the class loader associated with this LogFactory.");</span>
- }
-<span class="nc" id="L419"> logFactoryClass =
Class.forName(factoryClassName);</span>
-<span class="nc" id="L420"> return
logFactoryClass.newInstance();</span>
-<span class="fc" id="L421"> } catch (final Exception e) {</span>
+<span class="nc bnc" id="L423" title="All 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L424"> logDiagnostic(</span>
+<span class="nc" id="L425"> "Unable to load
factory class via class loader " + objectId(classLoader) + " - trying
the class loader associated with this LogFactory.");</span>
+ }
+<span class="nc" id="L427"> logFactoryClass =
Class.forName(factoryClassName);</span>
+<span class="nc" id="L428"> return
logFactoryClass.newInstance();</span>
+<span class="fc" id="L429"> } catch (final Exception e) {</span>
// Check to see if we've got a bad configuration
-<span class="pc bpc" id="L423" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L424"> logDiagnostic("Unable to
create LogFactory instance.");</span>
+<span class="pc bpc" id="L431" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L432"> logDiagnostic("Unable to
create LogFactory instance.");</span>
}
-<span class="pc bpc" id="L426" title="3 of 4 branches missed."> if
(logFactoryClass != null &&
!LogFactory.class.isAssignableFrom(logFactoryClass)) {</span>
-<span class="nc" id="L427"> return new
LogConfigurationException("The chosen LogFactory implementation does not
extend LogFactory." + " Please check your configuration.",</span>
+<span class="pc bpc" id="L434" title="3 of 4 branches missed."> if
(logFactoryClass != null &&
!LogFactory.class.isAssignableFrom(logFactoryClass)) {</span>
+<span class="nc" id="L435"> return new
LogConfigurationException("The chosen LogFactory implementation does not
extend LogFactory." + " Please check your configuration.",</span>
e);
}
-<span class="fc" id="L430"> return new
LogConfigurationException(e);</span>
+<span class="fc" id="L438"> return new
LogConfigurationException(e);</span>
}
}
@@ -445,45 +453,46 @@ public abstract class LogFactory {
* Note that the correct way to ensure no memory leaks occur is to ensure
* that LogFactory.release(contextClassLoader) is called whenever a
* webapp is undeployed.
+ * </p>
*/
private static Hashtable<ClassLoader, LogFactory>
createFactoryStore() {
-<span class="fc" id="L450"> Hashtable<ClassLoader, LogFactory>
result = null;</span>
+<span class="fc" id="L459"> Hashtable<ClassLoader, LogFactory>
result = null;</span>
String storeImplementationClass;
try {
-<span class="fc" id="L453"> storeImplementationClass =
getSystemProperty(HASHTABLE_IMPLEMENTATION_PROPERTY, null);</span>
-<span class="nc" id="L454"> } catch (final SecurityException ex)
{</span>
+<span class="fc" id="L462"> storeImplementationClass =
getSystemProperty(HASHTABLE_IMPLEMENTATION_PROPERTY, null);</span>
+<span class="fc" id="L463"> } catch (final SecurityException ex)
{</span>
// Permissions don't allow this to be accessed. Default to the
"modern"
// weak hashtable implementation if it is available.
-<span class="nc" id="L457"> storeImplementationClass = null;</span>
-<span class="fc" id="L458"> }</span>
+<span class="fc" id="L466"> storeImplementationClass = null;</span>
+<span class="fc" id="L467"> }</span>
-<span class="fc bfc" id="L460" title="All 2 branches covered."> if
(storeImplementationClass == null) {</span>
-<span class="fc" id="L461"> storeImplementationClass =
WEAK_HASHTABLE_CLASSNAME;</span>
+<span class="fc bfc" id="L469" title="All 2 branches covered."> if
(storeImplementationClass == null) {</span>
+<span class="fc" id="L470"> storeImplementationClass =
WEAK_HASHTABLE_CLASSNAME;</span>
}
try {
-<span class="fc" id="L464"> final
Class<Hashtable<ClassLoader, LogFactory>> implementationClass =
(Class<Hashtable<ClassLoader, LogFactory>>) Class</span>
-<span class="fc" id="L465">
.forName(storeImplementationClass);</span>
-<span class="fc" id="L466"> result =
implementationClass.getConstructor().newInstance();</span>
-<span class="nc" id="L467"> } catch (final Throwable t) {</span>
-<span class="nc" id="L468"> handleThrowable(t); // may re-throw
t</span>
+<span class="fc" id="L473"> final
Class<Hashtable<ClassLoader, LogFactory>> implementationClass =
(Class<Hashtable<ClassLoader, LogFactory>>) Class</span>
+<span class="fc" id="L474">
.forName(storeImplementationClass);</span>
+<span class="fc" id="L475"> result =
implementationClass.getConstructor().newInstance();</span>
+<span class="nc" id="L476"> } catch (final Throwable t) {</span>
+<span class="nc" id="L477"> handleThrowable(t); // may re-throw
t</span>
// ignore
-<span class="nc bnc" id="L471" title="All 2 branches missed."> if
(!WEAK_HASHTABLE_CLASSNAME.equals(storeImplementationClass)) {</span>
+<span class="nc bnc" id="L480" title="All 2 branches missed."> if
(!WEAK_HASHTABLE_CLASSNAME.equals(storeImplementationClass)) {</span>
// if the user's trying to set up a custom implementation,
give a clue
-<span class="nc bnc" id="L473" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc bnc" id="L482" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
// use internal logging to issue the warning
-<span class="nc" id="L475"> logDiagnostic("[ERROR]
LogFactory: Load of custom Hashtable failed");</span>
+<span class="nc" id="L484"> logDiagnostic("[ERROR]
LogFactory: Load of custom Hashtable failed");</span>
} else {
// we *really* want this output, even if diagnostics
weren't
// explicitly enabled by the user.
-<span class="nc" id="L479">
System.err.println("[ERROR] LogFactory: Load of custom Hashtable
failed");</span>
+<span class="nc" id="L488">
System.err.println("[ERROR] LogFactory: Load of custom Hashtable
failed");</span>
}
}
-<span class="fc" id="L482"> }</span>
-<span class="pc bpc" id="L483" title="1 of 2 branches missed."> if
(result == null) {</span>
-<span class="nc" id="L484"> result = new Hashtable<>();</span>
+<span class="fc" id="L491"> }</span>
+<span class="pc bpc" id="L492" title="1 of 2 branches missed."> if
(result == null) {</span>
+<span class="nc" id="L493"> result = new Hashtable<>();</span>
}
-<span class="fc" id="L486"> return result;</span>
+<span class="fc" id="L495"> return result;</span>
}
/**
@@ -491,13 +500,16 @@ public abstract class LogFactory {
* <p>
* Most/all code should call getContextClassLoaderInternal rather than
* calling this method directly.
+ * </p>
* <p>
* The thread context class loader is available for JDK 1.2
* or later, if certain security conditions are met.
+ * </p>
* <p>
* Note that no internal logging is done within this method because
* this method is called every time LogFactory.getLogger() is called,
* and we don't want too much output generated here.
+ * </p>
*
* @throws LogConfigurationException if a suitable class loader
* cannot be identified.
@@ -507,12 +519,10 @@ public abstract class LogFactory {
* @since 1.1
*/
protected static ClassLoader directGetContextClassLoader() throws
LogConfigurationException {
-<span class="fc" id="L510"> ClassLoader classLoader = null;</span>
-
+<span class="fc" id="L522"> ClassLoader classLoader = null;</span>
try {
-<span class="fc" id="L513"> classLoader =
Thread.currentThread().getContextClassLoader();</span>
-<span class="nc" id="L514"> } catch (final SecurityException ignore)
{</span>
- //
+<span class="fc" id="L524"> classLoader =
Thread.currentThread().getContextClassLoader();</span>
+<span class="fc" id="L525"> } catch (final SecurityException ignore)
{</span>
// getContextClassLoader() throws SecurityException when
// the context class loader isn't an ancestor of the
// calling class's class loader, or if security
@@ -520,12 +530,9 @@ public abstract class LogFactory {
//
// We ignore this exception to be consistent with the previous
// behavior (e.g. 1.1.3 and earlier).
- //
- // ignore
-<span class="fc" id="L525"> }</span>
-
+<span class="fc" id="L533"> }</span>
// Return the selected class loader
-<span class="fc" id="L528"> return classLoader;</span>
+<span class="fc" id="L535"> return classLoader;</span>
}
/**
@@ -543,14 +550,14 @@ public abstract class LogFactory {
* we have seen this particular class loader.
*/
private static LogFactory getCachedFactory(final ClassLoader
contextClassLoader) {
-<span class="fc bfc" id="L546" title="All 2 branches covered."> if
(contextClassLoader == null) {</span>
+<span class="fc bfc" id="L553" title="All 2 branches covered."> if
(contextClassLoader == null) {</span>
// We have to handle this specially, as factories is a Hashtable
// and those don't accept null as a key value.
//
// nb: nullClassLoaderFactory might be null. That's ok.
-<span class="fc" id="L551"> return nullClassLoaderFactory;</span>
+<span class="fc" id="L558"> return nullClassLoaderFactory;</span>
}
-<span class="fc" id="L553"> return
factories.get(contextClassLoader);</span>
+<span class="fc" id="L560"> return
factories.get(contextClassLoader);</span>
}
/**
@@ -588,12 +595,12 @@ public abstract class LogFactory {
*/
protected static ClassLoader getClassLoader(final Class<?> clazz) {
try {
-<span class="fc" id="L591"> return clazz.getClassLoader();</span>
-<span class="nc" id="L592"> } catch (final SecurityException ex)
{</span>
-<span class="nc bnc" id="L593" title="All 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L594"> logDiagnostic("Unable to get
class loader for class '" + clazz + "' due to security restrictions -
" + ex.getMessage());</span>
+<span class="fc" id="L598"> return clazz.getClassLoader();</span>
+<span class="nc" id="L599"> } catch (final SecurityException ex)
{</span>
+<span class="nc bnc" id="L600" title="All 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L601"> logDiagnostic("Unable to get
class loader for class '" + clazz + "' due to security restrictions -
" + ex.getMessage());</span>
}
-<span class="nc" id="L596"> throw ex;</span>
+<span class="nc" id="L603"> throw ex;</span>
}
}
@@ -605,9 +612,11 @@ public abstract class LogFactory {
* null is returned. If more than one is found, then the file with the
greatest
* value for its PRIORITY property is returned. If multiple files have the
* same PRIORITY value then the first in the classpath is returned.
+ * </p>
* <p>
* This differs from the 1.0.x releases; those always use the first one
found.
* However as the priority is a new field, this change is backwards
compatible.
+ * </p>
* <p>
* The purpose of the priority field is to allow a webserver administrator
to
* override logging settings in all webapps by placing a
commons-logging.properties
@@ -615,74 +624,75 @@ public abstract class LogFactory {
* commons-logging.properties files without priorities which are in the
* webapps. Webapps can also use explicit priorities to override a
configuration
* file in the shared classpath if needed.
+ * </p>
*/
private static Properties getConfigurationFile(final ClassLoader
classLoader, final String fileName) {
-<span class="fc" id="L620"> Properties props = null;</span>
-<span class="fc" id="L621"> double priority = 0.0;</span>
-<span class="fc" id="L622"> URL propsUrl = null;</span>
+<span class="fc" id="L630"> Properties props = null;</span>
+<span class="fc" id="L631"> double priority = 0.0;</span>
+<span class="fc" id="L632"> URL propsUrl = null;</span>
try {
-<span class="fc" id="L624"> final Enumeration<URL> urls =
getResources(classLoader, fileName);</span>
+<span class="fc" id="L634"> final Enumeration<URL> urls =
getResources(classLoader, fileName);</span>
-<span class="pc bpc" id="L626" title="1 of 2 branches missed."> if
(urls == null) {</span>
-<span class="nc" id="L627"> return null;</span>
+<span class="pc bpc" id="L636" title="1 of 2 branches missed."> if
(urls == null) {</span>
+<span class="nc" id="L637"> return null;</span>
}
-<span class="fc bfc" id="L630" title="All 2 branches covered.">
while (urls.hasMoreElements()) {</span>
-<span class="fc" id="L631"> final URL url =
urls.nextElement();</span>
+<span class="fc bfc" id="L640" title="All 2 branches covered.">
while (urls.hasMoreElements()) {</span>
+<span class="fc" id="L641"> final URL url =
urls.nextElement();</span>
-<span class="fc" id="L633"> final Properties newProps =
getProperties(url);</span>
-<span class="pc bpc" id="L634" title="1 of 2 branches missed.">
if (newProps != null) {</span>
-<span class="fc bfc" id="L635" title="All 2 branches covered.">
if (props == null) {</span>
-<span class="fc" id="L636"> propsUrl = url;</span>
-<span class="fc" id="L637"> props = newProps;</span>
-<span class="fc" id="L638"> final String priorityStr =
props.getProperty(PRIORITY_KEY);</span>
-<span class="fc" id="L639"> priority = 0.0;</span>
-<span class="fc bfc" id="L640" title="All 2 branches covered.">
if (priorityStr != null) {</span>
-<span class="fc" id="L641"> priority =
Double.parseDouble(priorityStr);</span>
+<span class="fc" id="L643"> final Properties newProps =
getProperties(url);</span>
+<span class="pc bpc" id="L644" title="1 of 2 branches missed.">
if (newProps != null) {</span>
+<span class="fc bfc" id="L645" title="All 2 branches covered.">
if (props == null) {</span>
+<span class="fc" id="L646"> propsUrl = url;</span>
+<span class="fc" id="L647"> props = newProps;</span>
+<span class="fc" id="L648"> final String priorityStr =
props.getProperty(PRIORITY_KEY);</span>
+<span class="fc" id="L649"> priority = 0.0;</span>
+<span class="fc bfc" id="L650" title="All 2 branches covered.">
if (priorityStr != null) {</span>
+<span class="fc" id="L651"> priority =
Double.parseDouble(priorityStr);</span>
}
-<span class="pc bpc" id="L644" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L645">
logDiagnostic("[LOOKUP] Properties file found at '" + url +
"'" + " with priority " + priority);</span>
+<span class="pc bpc" id="L654" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L655">
logDiagnostic("[LOOKUP] Properties file found at '" + url +
"'" + " with priority " + priority);</span>
}
-<span class="fc" id="L647"> } else {</span>
-<span class="fc" id="L648"> final String newPriorityStr
= newProps.getProperty(PRIORITY_KEY);</span>
-<span class="fc" id="L649"> double newPriority =
0.0;</span>
-<span class="fc bfc" id="L650" title="All 2 branches covered.">
if (newPriorityStr != null) {</span>
-<span class="fc" id="L651"> newPriority =
Double.parseDouble(newPriorityStr);</span>
+<span class="fc" id="L657"> } else {</span>
+<span class="fc" id="L658"> final String newPriorityStr
= newProps.getProperty(PRIORITY_KEY);</span>
+<span class="fc" id="L659"> double newPriority =
0.0;</span>
+<span class="fc bfc" id="L660" title="All 2 branches covered.">
if (newPriorityStr != null) {</span>
+<span class="fc" id="L661"> newPriority =
Double.parseDouble(newPriorityStr);</span>
}
-<span class="fc bfc" id="L654" title="All 2 branches covered.">
if (newPriority > priority) {</span>
-<span class="pc bpc" id="L655" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L656">
logDiagnostic("[LOOKUP] Properties file at '" + url + "'" +
" with priority " + newPriority + " overrides file at '" +
propsUrl</span>
+<span class="fc bfc" id="L664" title="All 2 branches covered.">
if (newPriority > priority) {</span>
+<span class="pc bpc" id="L665" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L666">
logDiagnostic("[LOOKUP] Properties file at '" + url + "'" +
" with priority " + newPriority + " overrides file at '" +
propsUrl</span>
+ "'" + " with priority
" + priority);
}
-<span class="fc" id="L660"> propsUrl = url;</span>
-<span class="fc" id="L661"> props = newProps;</span>
-<span class="fc" id="L662"> priority =
newPriority;</span>
-<span class="pc bpc" id="L663" title="1 of 2 branches missed.">
} else if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L664">
logDiagnostic("[LOOKUP] Properties file at '" + url + "'" +
" with priority " + newPriority + " does not override file at
'"</span>
+<span class="fc" id="L670"> propsUrl = url;</span>
+<span class="fc" id="L671"> props = newProps;</span>
+<span class="fc" id="L672"> priority =
newPriority;</span>
+<span class="pc bpc" id="L673" title="1 of 2 branches missed.">
} else if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L674">
logDiagnostic("[LOOKUP] Properties file at '" + url + "'" +
" with priority " + newPriority + " does not override file at
'"</span>
+ propsUrl + "'" + " with
priority " + priority);
}
}
}
-<span class="fc" id="L670"> }</span>
-<span class="nc" id="L671"> } catch (final SecurityException e) {</span>
-<span class="nc bnc" id="L672" title="All 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L673">
logDiagnostic("SecurityException thrown while trying to find/read config
files.");</span>
- }
-<span class="fc" id="L675"> }</span>
-
-<span class="pc bpc" id="L677" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc bnc" id="L678" title="All 2 branches missed."> if
(props == null) {</span>
-<span class="nc" id="L679"> logDiagnostic("[LOOKUP] No
properties file of name '" + fileName + "' found.");</span>
+<span class="fc" id="L680"> }</span>
+<span class="nc" id="L681"> } catch (final SecurityException e) {</span>
+<span class="nc bnc" id="L682" title="All 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L683">
logDiagnostic("SecurityException thrown while trying to find/read config
files.");</span>
+ }
+<span class="fc" id="L685"> }</span>
+
+<span class="pc bpc" id="L687" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc bnc" id="L688" title="All 2 branches missed."> if
(props == null) {</span>
+<span class="nc" id="L689"> logDiagnostic("[LOOKUP] No
properties file of name '" + fileName + "' found.");</span>
} else {
-<span class="nc" id="L681"> logDiagnostic("[LOOKUP]
Properties file of name '" + fileName + "' found at '" +
propsUrl + '"');</span>
+<span class="nc" id="L691"> logDiagnostic("[LOOKUP]
Properties file of name '" + fileName + "' found at '" +
propsUrl + '"');</span>
}
}
-<span class="fc" id="L685"> return props;</span>
+<span class="fc" id="L695"> return props;</span>
}
/**
@@ -691,11 +701,13 @@ public abstract class LogFactory {
* In versions prior to 1.1, this method did not use an AccessController.
* In version 1.1, an AccessController wrapper was incorrectly added to
* this method, causing a minor security flaw.
+ * </p>
* <p>
* In version 1.1.1 this change was reverted; this method no longer uses
* an AccessController. User code wishing to obtain the context class
loader
* must invoke this method via AccessController.doPrivileged if it needs
* support for that.
+ * </p>
*
* @return the context class loader associated with the current thread,
* or null if security doesn't allow it.
@@ -703,7 +715,7 @@ public abstract class LogFactory {
* attempting to get the context class loader.
*/
protected static ClassLoader getContextClassLoader() throws
LogConfigurationException {
-<span class="nc" id="L706"> return directGetContextClassLoader();</span>
+<span class="nc" id="L718"> return directGetContextClassLoader();</span>
}
/**
@@ -721,7 +733,7 @@ public abstract class LogFactory {
* attempting to get the context class loader.
*/
private static ClassLoader getContextClassLoaderInternal() throws
LogConfigurationException {
-<span class="fc" id="L724"> return
AccessController.doPrivileged((PrivilegedAction<ClassLoader>)
LogFactory::directGetContextClassLoader);</span>
+<span class="fc" id="L736"> return
AccessController.doPrivileged((PrivilegedAction<ClassLoader>)
LogFactory::directGetContextClassLoader);</span>
}
/**
@@ -748,26 +760,26 @@ public abstract class LogFactory {
*/
public static LogFactory getFactory() throws LogConfigurationException {
// Identify the class loader we will be using
-<span class="fc" id="L751"> final ClassLoader contextClassLoader =
getContextClassLoaderInternal();</span>
+<span class="fc" id="L763"> final ClassLoader contextClassLoader =
getContextClassLoaderInternal();</span>
// This is an odd enough situation to report about. This
// output will be a nuisance on JDK1.1, as the system
// class loader is null in that environment.
-<span class="pc bpc" id="L756" title="1 of 4 branches missed."> if
(contextClassLoader == null && isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L757"> logDiagnostic("Context class
loader is null.");</span>
+<span class="pc bpc" id="L768" title="1 of 4 branches missed."> if
(contextClassLoader == null && isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L769"> logDiagnostic("Context class
loader is null.");</span>
}
// Return any previously registered factory for this class loader
-<span class="fc" id="L761"> LogFactory factory =
getCachedFactory(contextClassLoader);</span>
-<span class="fc bfc" id="L762" title="All 2 branches covered."> if
(factory != null) {</span>
-<span class="fc" id="L763"> return factory;</span>
+<span class="fc" id="L773"> LogFactory factory =
getCachedFactory(contextClassLoader);</span>
+<span class="fc bfc" id="L774" title="All 2 branches covered."> if
(factory != null) {</span>
+<span class="fc" id="L775"> return factory;</span>
}
-<span class="pc bpc" id="L766" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L767"> logDiagnostic(</span>
+<span class="pc bpc" id="L778" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L779"> logDiagnostic(</span>
"[LOOKUP] LogFactory implementation requested for the
first time for context class loader " +
-<span class="nc" id="L769">
objectId(contextClassLoader));</span>
-<span class="nc" id="L770"> logHierarchy("[LOOKUP] ",
contextClassLoader);</span>
+<span class="nc" id="L781">
objectId(contextClassLoader));</span>
+<span class="nc" id="L782"> logHierarchy("[LOOKUP] ",
contextClassLoader);</span>
}
// Load properties file.
@@ -780,16 +792,16 @@ 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.
-<span class="fc" id="L783"> final Properties props =
getConfigurationFile(contextClassLoader, FACTORY_PROPERTIES);</span>
+<span class="fc" id="L795"> final Properties props =
getConfigurationFile(contextClassLoader, FACTORY_PROPERTIES);</span>
// 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).
-<span class="fc" id="L787"> ClassLoader baseClassLoader =
contextClassLoader;</span>
-<span class="fc bfc" id="L788" title="All 2 branches covered."> if
(props != null) {</span>
-<span class="fc" id="L789"> final String useTCCLStr =
props.getProperty(TCCL_KEY);</span>
+<span class="fc" id="L799"> ClassLoader baseClassLoader =
contextClassLoader;</span>
+<span class="fc bfc" id="L800" title="All 2 branches covered."> if
(props != null) {</span>
+<span class="fc" id="L801"> final String useTCCLStr =
props.getProperty(TCCL_KEY);</span>
// The Boolean.valueOf(useTCCLStr).booleanValue() formulation
// is required for Java 1.2 compatibility.
-<span class="pc bpc" id="L792" title="1 of 4 branches missed."> if
(useTCCLStr != null && !Boolean.parseBoolean(useTCCLStr)) {</span>
+<span class="pc bpc" id="L804" title="1 of 4 branches missed."> if
(useTCCLStr != null && !Boolean.parseBoolean(useTCCLStr)) {</span>
// Don't use current context class loader when locating any
// LogFactory or Log classes, just use the class that loaded
// this abstract class. When this class is deployed in a shared
@@ -797,49 +809,49 @@ public abstract class LogFactory {
// own logging implementations. It also means that it is up to
the
// implementation whether to load library-specific config files
// from the TCCL or not.
-<span class="fc" id="L800"> baseClassLoader =
thisClassLoaderRef.get();</span>
+<span class="fc" id="L812"> baseClassLoader =
thisClassLoaderRef.get();</span>
}
}
// Determine which concrete LogFactory subclass to use.
// First, try a global system property
-<span class="pc bpc" id="L806" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L807"> logDiagnostic("[LOOKUP] Looking
for system property [" + FACTORY_PROPERTY +</span>
+<span class="pc bpc" id="L818" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L819"> logDiagnostic("[LOOKUP] Looking
for system property [" + FACTORY_PROPERTY +</span>
"] to define the LogFactory subclass to
use...");
}
try {
-<span class="fc" id="L812"> final String factoryClass =
getSystemProperty(FACTORY_PROPERTY, null);</span>
-<span class="fc bfc" id="L813" title="All 2 branches covered."> if
(factoryClass != null) {</span>
-<span class="pc bpc" id="L814" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L815"> logDiagnostic("[LOOKUP]
Creating an instance of LogFactory class '" + factoryClass +</span>
+<span class="fc" id="L824"> final String factoryClass =
getSystemProperty(FACTORY_PROPERTY, null);</span>
+<span class="fc bfc" id="L825" title="All 2 branches covered."> if
(factoryClass != null) {</span>
+<span class="pc bpc" id="L826" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L827"> logDiagnostic("[LOOKUP]
Creating an instance of LogFactory class '" + factoryClass +</span>
"' as specified by system property
" + FACTORY_PROPERTY);
}
-<span class="fc" id="L818"> factory = newFactory(factoryClass,
baseClassLoader, contextClassLoader);</span>
-<span class="pc bpc" id="L819" title="1 of 2 branches missed."> }
else if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L820"> logDiagnostic("[LOOKUP] No
system property [" + FACTORY_PROPERTY + "] defined.");</span>
- }
-<span class="nc" id="L822"> } catch (final SecurityException e) {</span>
-<span class="nc bnc" id="L823" title="All 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L824"> logDiagnostic("[LOOKUP] A
security exception occurred while trying to create an" +</span>
-<span class="nc" id="L825"> " instance of
the custom factory class" + ": [" + trim(e.getMessage()) +</span>
+<span class="fc" id="L830"> factory = newFactory(factoryClass,
baseClassLoader, contextClassLoader);</span>
+<span class="pc bpc" id="L831" title="1 of 2 branches missed."> }
else if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L832"> logDiagnostic("[LOOKUP] No
system property [" + FACTORY_PROPERTY + "] defined.");</span>
+ }
+<span class="fc" id="L834"> } catch (final SecurityException e) {</span>
+<span class="pc bpc" id="L835" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L836"> logDiagnostic("[LOOKUP] A
security exception occurred while trying to create an" +</span>
+<span class="nc" id="L837"> " instance of
the custom factory class" + ": [" + trim(e.getMessage()) +</span>
"]. Trying alternative
implementations...");
}
// ignore
-<span class="nc" id="L829"> } catch (final RuntimeException e) {</span>
+<span class="nc" id="L841"> } catch (final RuntimeException e) {</span>
// This is not consistent with the behavior when a bad LogFactory
class is
// specified in a services file.
//
// One possible exception that can occur here is a
ClassCastException when
// the specified class wasn't castable to this LogFactory type.
-<span class="nc bnc" id="L835" title="All 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L836"> logDiagnostic("[LOOKUP] An
exception occurred while trying to create an" +</span>
+<span class="nc bnc" id="L847" title="All 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L848"> logDiagnostic("[LOOKUP] An
exception occurred while trying to create an" +</span>
" instance of the custom factory
class" + ": [" +
-<span class="nc" id="L838"> trim(e.getMessage())
+</span>
+<span class="nc" id="L850"> trim(e.getMessage())
+</span>
"] as specified by a system
property.");
}
-<span class="nc" id="L841"> throw e;</span>
-<span class="pc" id="L842"> }</span>
+<span class="nc" id="L853"> throw e;</span>
+<span class="fc" id="L854"> }</span>
// Second, try to find a service by using the JDK 1.3 class
// discovery mechanism, which involves putting a file with the name
@@ -847,69 +859,67 @@ public abstract class LogFactory {
// contents of the file is a single line specifying a concrete class
// that implements the desired interface.
-<span class="fc bfc" id="L850" title="All 2 branches covered."> if
(factory == null) {</span>
-<span class="pc bpc" id="L851" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L852"> logDiagnostic("[LOOKUP] Using
ServiceLoader to define the LogFactory subclass to use...");</span>
+<span class="fc bfc" id="L862" title="All 2 branches covered."> if
(factory == null) {</span>
+<span class="pc bpc" id="L863" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L864"> logDiagnostic("[LOOKUP] Using
ServiceLoader to define the LogFactory subclass to use...");</span>
}
try {
-<span class="fc" id="L855"> final
ServiceLoader<LogFactory> serviceLoader =
ServiceLoader.load(LogFactory.class);</span>
-<span class="fc" id="L856"> final Iterator<LogFactory>
iterator = serviceLoader.iterator();</span>
+<span class="fc" id="L867"> final
ServiceLoader<LogFactory> serviceLoader =
ServiceLoader.load(LogFactory.class);</span>
+<span class="fc" id="L868"> final Iterator<LogFactory>
iterator = serviceLoader.iterator();</span>
-<span class="fc" id="L858"> int i = MAX_BROKEN_SERVICES;</span>
-<span class="fc bfc" id="L859" title="All 4 branches covered.">
while (factory == null && i-- > 0) {</span>
+<span class="fc" id="L870"> int i = MAX_BROKEN_SERVICES;</span>
+<span class="fc bfc" id="L871" title="All 4 branches covered.">
while (factory == null && i-- > 0) {</span>
try {
-<span class="fc bfc" id="L861" title="All 2 branches covered.">
if (iterator.hasNext()) {</span>
-<span class="fc" id="L862"> factory =
iterator.next();</span>
+<span class="fc bfc" id="L873" title="All 2 branches covered.">
if (iterator.hasNext()) {</span>
+<span class="fc" id="L874"> factory =
iterator.next();</span>
}
-<span class="fc" id="L864"> } catch (final
ServiceConfigurationError | LinkageError ex) {</span>
-<span class="pc bpc" id="L865" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L866">
logDiagnostic("[LOOKUP] An exception occurred while trying to find
an" +</span>
+<span class="fc" id="L876"> } catch (final
ServiceConfigurationError | LinkageError ex) {</span>
+<span class="pc bpc" id="L877" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L878">
logDiagnostic("[LOOKUP] An exception occurred while trying to find
an" +</span>
" instance of LogFactory" +
-<span class="nc" id="L868"> ": ["
+ trim(ex.getMessage()) +</span>
+<span class="nc" id="L880"> ": ["
+ trim(ex.getMessage()) +</span>
"]. Trying alternative
implementations...");
}
-<span class="fc" id="L871"> }</span>
+<span class="fc" id="L883"> }</span>
}
-<span class="nc" id="L873"> } catch (final Exception ex) {</span>
+<span class="nc" id="L885"> } catch (final Exception ex) {</span>
// 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.
-<span class="nc bnc" id="L877" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L878"> logDiagnostic(</span>
+<span class="nc bnc" id="L889" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L890"> logDiagnostic(</span>
"[LOOKUP] A security exception occurred while
trying to create an" +
" instance of the custom factory class" +
-<span class="nc" id="L881"> ": [" +
trim(ex.getMessage()) +</span>
+<span class="nc" id="L893"> ": [" +
trim(ex.getMessage()) +</span>
"]. Trying alternative implementations...");
}
// ignore
-<span class="fc" id="L885"> }</span>
+<span class="fc" id="L897"> }</span>
}
// Third try looking into the properties file read earlier (if found)
-<span class="fc bfc" id="L890" title="All 2 branches covered."> if
(factory == null) {</span>
-<span class="fc bfc" id="L891" title="All 2 branches covered."> if
(props != null) {</span>
-<span class="pc bpc" id="L892" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L893"> logDiagnostic(</span>
+<span class="fc bfc" id="L902" title="All 2 branches covered."> if
(factory == null) {</span>
+<span class="fc bfc" id="L903" title="All 2 branches covered."> if
(props != null) {</span>
+<span class="pc bpc" id="L904" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L905"> logDiagnostic(</span>
"[LOOKUP] Looking in properties file for entry
with key '" + FACTORY_PROPERTY +
"' to define the LogFactory subclass to
use...");
}
-<span class="fc" id="L897"> final String factoryClass =
props.getProperty(FACTORY_PROPERTY);</span>
-<span class="fc bfc" id="L898" title="All 2 branches covered.">
if (factoryClass != null) {</span>
-<span class="pc bpc" id="L899" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L900"> logDiagnostic(</span>
+<span class="fc" id="L909"> final String factoryClass =
props.getProperty(FACTORY_PROPERTY);</span>
+<span class="fc bfc" id="L910" title="All 2 branches covered.">
if (factoryClass != null) {</span>
+<span class="pc bpc" id="L911" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L912"> logDiagnostic(</span>
"[LOOKUP] Properties file specifies
LogFactory subclass '" + factoryClass + "'");
}
-<span class="fc" id="L903"> factory =
newFactory(factoryClass, baseClassLoader, contextClassLoader);</span>
+<span class="fc" id="L915"> factory =
newFactory(factoryClass, baseClassLoader, contextClassLoader);</span>
// TODO: think about whether we need to handle exceptions
from newFactory
- } else {
-<span class="pc bpc" id="L907" title="1 of 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L908">
logDiagnostic("[LOOKUP] Properties file has no entry specifying LogFactory
subclass.");</span>
- }
+<span class="pc bpc" id="L918" title="1 of 2 branches missed.">
} else if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L919"> logDiagnostic("[LOOKUP]
Properties file has no entry specifying LogFactory subclass.");</span>
}
-<span class="pc bpc" id="L911" title="1 of 2 branches missed."> }
else if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L912"> logDiagnostic("[LOOKUP] No
properties file available to determine" + " LogFactory subclass
from..");</span>
+<span class="pc bpc" id="L921" title="1 of 2 branches missed."> }
else if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L922"> logDiagnostic("[LOOKUP] No
properties file available to determine" + " LogFactory subclass
from..");</span>
}
}
@@ -917,29 +927,29 @@ public abstract class LogFactory {
try {
// We prefer Log4j API, since it does not stringify objects.
-<span class="fc bfc" id="L920" title="All 4 branches covered."> if
(factory == null && isClassAvailable(LOG4J_API_LOGGER,
baseClassLoader)) {</span>
+<span class="fc bfc" id="L930" title="All 4 branches covered."> if
(factory == null && isClassAvailable(LOG4J_API_LOGGER,
baseClassLoader)) {</span>
// If the Log4j API is redirected to SLF4J, we use SLF4J
directly.
-<span class="fc bfc" id="L922" title="All 2 branches covered.">
if (isClassAvailable(LOG4J_TO_SLF4J_BRIDGE, baseClassLoader)) {</span>
-<span class="fc" id="L923"> logDiagnostic(</span>
+<span class="fc bfc" id="L932" title="All 2 branches covered.">
if (isClassAvailable(LOG4J_TO_SLF4J_BRIDGE, baseClassLoader)) {</span>
+<span class="fc" id="L933"> logDiagnostic(</span>
"[LOOKUP] Log4j API to SLF4J redirection
detected. Loading the SLF4J LogFactory implementation '" + FACTORY_SLF4J +
"'.");
-<span class="fc" id="L925"> factory =
newFactory(FACTORY_SLF4J, baseClassLoader, contextClassLoader);</span>
+<span class="fc" id="L935"> factory =
newFactory(FACTORY_SLF4J, baseClassLoader, contextClassLoader);</span>
} else {
-<span class="fc" id="L927"> logDiagnostic("[LOOKUP]
Log4j API detected. Loading the Log4j API LogFactory implementation '" +
FACTORY_LOG4J_API + "'.");</span>
-<span class="fc" id="L928"> factory =
newFactory(FACTORY_LOG4J_API, baseClassLoader, contextClassLoader);</span>
+<span class="fc" id="L937"> logDiagnostic("[LOOKUP]
Log4j API detected. Loading the Log4j API LogFactory implementation '" +
FACTORY_LOG4J_API + "'.");</span>
+<span class="fc" id="L938"> factory =
newFactory(FACTORY_LOG4J_API, baseClassLoader, contextClassLoader);</span>
}
}
-<span class="fc bfc" id="L932" title="All 4 branches covered."> if
(factory == null && isClassAvailable(SLF4J_API_LOGGER,
baseClassLoader)) {</span>
-<span class="fc" id="L933"> logDiagnostic("[LOOKUP] SLF4J
detected. Loading the SLF4J LogFactory implementation '" + FACTORY_SLF4J +
"'.");</span>
-<span class="fc" id="L934"> factory = newFactory(FACTORY_SLF4J,
baseClassLoader, contextClassLoader);</span>
- }
-<span class="nc" id="L936"> } catch (final Exception e) {</span>
-<span class="nc" id="L937"> logDiagnostic("[LOOKUP] An
exception occurred while creating LogFactory: " + e.getMessage());</span>
-<span class="fc" id="L938"> }</span>
-
-<span class="fc bfc" id="L940" title="All 2 branches covered."> if
(factory == null) {</span>
-<span class="pc bpc" id="L941" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L942"> logDiagnostic(</span>
+<span class="fc bfc" id="L942" title="All 4 branches covered."> if
(factory == null && isClassAvailable(SLF4J_API_LOGGER,
baseClassLoader)) {</span>
+<span class="fc" id="L943"> logDiagnostic("[LOOKUP] SLF4J
detected. Loading the SLF4J LogFactory implementation '" + FACTORY_SLF4J +
"'.");</span>
+<span class="fc" id="L944"> factory = newFactory(FACTORY_SLF4J,
baseClassLoader, contextClassLoader);</span>
+ }
+<span class="fc" id="L946"> } catch (final Exception e) {</span>
+<span class="fc" id="L947"> logDiagnostic("[LOOKUP] An
exception occurred while creating LogFactory: " + e.getMessage());</span>
+<span class="fc" id="L948"> }</span>
+
+<span class="fc bfc" id="L950" title="All 2 branches covered."> if
(factory == null) {</span>
+<span class="pc bpc" id="L951" title="1 of 2 branches missed."> if
(isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L952"> logDiagnostic(</span>
"[LOOKUP] Loading the default LogFactory
implementation '" + FACTORY_DEFAULT +
"' via the same class loader that loaded this
LogFactory" +
" class (ie not looking in the context class
loader).");
@@ -954,26 +964,26 @@ public abstract class LogFactory {
// version of the LogFactoryImpl class and have it used dynamically
// by an old LogFactory class in the parent, but that isn't
// necessarily a good idea anyway.
-<span class="fc" id="L957"> factory = newFactory(FACTORY_DEFAULT,
thisClassLoaderRef.get(), contextClassLoader);</span>
+<span class="fc" id="L967"> factory = newFactory(FACTORY_DEFAULT,
thisClassLoaderRef.get(), contextClassLoader);</span>
}
-<span class="pc bpc" id="L960" title="1 of 2 branches missed."> if
(factory != null) {</span>
+<span class="pc bpc" id="L970" title="1 of 2 branches missed."> if
(factory != null) {</span>
/**
* Always cache using context class loader.
*/
-<span class="fc" id="L964"> cacheFactory(contextClassLoader,
factory);</span>
+<span class="fc" id="L974"> cacheFactory(contextClassLoader,
factory);</span>
-<span class="fc bfc" id="L966" title="All 2 branches covered."> if
(props != null) {</span>
-<span class="fc" id="L967"> final Enumeration<?> names =
props.propertyNames();</span>
-<span class="fc bfc" id="L968" title="All 2 branches covered.">
while (names.hasMoreElements()) {</span>
-<span class="fc" id="L969"> final String name =
Objects.toString(names.nextElement(), null);</span>
-<span class="fc" id="L970"> final String value =
props.getProperty(name);</span>
-<span class="fc" id="L971"> factory.setAttribute(name,
value);</span>
-<span class="fc" id="L972"> }</span>
+<span class="fc bfc" id="L976" title="All 2 branches covered."> if
(props != null) {</span>
+<span class="fc" id="L977"> final Enumeration<?> names =
props.propertyNames();</span>
+<span class="fc bfc" id="L978" title="All 2 branches covered.">
while (names.hasMoreElements()) {</span>
+<span class="fc" id="L979"> final String name =
Objects.toString(names.nextElement(), null);</span>
+<span class="fc" id="L980"> final String value =
props.getProperty(name);</span>
+<span class="fc" id="L981"> factory.setAttribute(name,
value);</span>
+<span class="fc" id="L982"> }</span>
}
}
-<span class="fc" id="L976"> return factory;</span>
+<span class="fc" id="L986"> return factory;</span>
}
/**
@@ -984,7 +994,7 @@ public abstract class LogFactory {
* @throws LogConfigurationException if a suitable {@code Log} instance
cannot be returned
*/
public static Log getLog(final Class<?> clazz) throws
LogConfigurationException {
-<span class="fc" id="L987"> return
getFactory().getInstance(clazz);</span>
+<span class="fc" id="L997"> return
getFactory().getInstance(clazz);</span>
}
/**
@@ -996,7 +1006,7 @@ public abstract class LogFactory {
* @throws LogConfigurationException if a suitable {@code Log} instance
cannot be returned
*/
public static Log getLog(final String name) throws
LogConfigurationException {
-<span class="fc" id="L999"> return
getFactory().getInstance(name);</span>
+<span class="fc" id="L1009"> return
getFactory().getInstance(name);</span>
}
/**
@@ -1006,33 +1016,34 @@ public abstract class LogFactory {
* This method must therefore remain private to avoid security issues.
* <p>
* {@code Null} is returned if the URL cannot be opened.
+ * </p>
*/
private static Properties getProperties(final URL url) {
-<span class="fc" id="L1011"> return
AccessController.doPrivileged((PrivilegedAction<Properties>) () ->
{</span>
+<span class="fc" id="L1022"> return
AccessController.doPrivileged((PrivilegedAction<Properties>) () ->
{</span>
// 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.
try {
-<span class="fc" id="L1016"> final URLConnection connection =
url.openConnection();</span>
-<span class="fc" id="L1017">
connection.setUseCaches(false);</span>
-<span class="fc" id="L1018"> try (InputStream stream =
connection.getInputStream()) {</span>
-<span class="pc bpc" id="L1019" title="1 of 2 branches missed.">
if (stream != null) {</span>
-<span class="fc" id="L1020"> final Properties props =
new Properties();</span>
-<span class="fc" id="L1021"> props.load(stream);</span>
-<span class="fc" id="L1022"> return props;</span>
+<span class="fc" id="L1027"> final URLConnection connection =
url.openConnection();</span>
+<span class="fc" id="L1028">
connection.setUseCaches(false);</span>
+<span class="fc" id="L1029"> try (InputStream stream =
connection.getInputStream()) {</span>
+<span class="pc bpc" id="L1030" title="1 of 2 branches missed.">
if (stream != null) {</span>
+<span class="fc" id="L1031"> final Properties props =
new Properties();</span>
+<span class="fc" id="L1032"> props.load(stream);</span>
+<span class="fc" id="L1033"> return props;</span>
}
-<span class="pc bpc" id="L1024" title="1 of 2 branches missed.">
} catch (final IOException e) {</span>
-<span class="nc bnc" id="L1025" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L1026"> logDiagnostic("Unable
to close stream for URL " + url);</span>
+<span class="pc bpc" id="L1035" title="1 of 2 branches missed.">
} catch (final IOException e) {</span>
+<span class="nc bnc" id="L1036" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L1037"> logDiagnostic("Unable
to close stream for URL " + url);</span>
}
-<span class="nc" id="L1028"> }</span>
-<span class="nc" id="L1029"> } catch (final IOException e) {</span>
-<span class="nc bnc" id="L1030" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L1031"> logDiagnostic("Unable to
read URL " + url);</span>
+<span class="nc" id="L1039"> }</span>
+<span class="nc" id="L1040"> } catch (final IOException e) {</span>
+<span class="nc bnc" id="L1041" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L1042"> logDiagnostic("Unable to
read URL " + url);</span>
}
-<span class="nc" id="L1033"> }</span>
+<span class="nc" id="L1044"> }</span>
-<span class="nc" id="L1035"> return null;</span>
+<span class="nc" id="L1046"> return null;</span>
});
}
@@ -1044,28 +1055,30 @@ public abstract class LogFactory {
* operation is done under an AccessController so that this method will
* succeed when this jarfile is privileged but the caller is not.
* This method must therefore remain private to avoid security issues.
+ * </p>
* <p>
* If no instances are found, an Enumeration is returned whose
* hasMoreElements method returns false (ie an "empty"
enumeration).
* If resources could not be listed for some reason, null is returned.
+ * </p>
*/
private static Enumeration<URL> getResources(final ClassLoader
loader, final String name) {
-<span class="fc" id="L1053"> return
AccessController.doPrivileged((PrivilegedAction<Enumeration<URL>>)
() -> {</span>
+<span class="fc" id="L1066"> return
AccessController.doPrivileged((PrivilegedAction<Enumeration<URL>>)
() -> {</span>
try {
-<span class="fc bfc" id="L1055" title="All 2 branches covered.">
if (loader != null) {</span>
-<span class="fc" id="L1056"> return
loader.getResources(name);</span>
+<span class="fc bfc" id="L1068" title="All 2 branches covered.">
if (loader != null) {</span>
+<span class="fc" id="L1069"> return
loader.getResources(name);</span>
}
-<span class="fc" id="L1058"> return
ClassLoader.getSystemResources(name);</span>
-<span class="nc" id="L1059"> } catch (final IOException e) {</span>
-<span class="nc bnc" id="L1060" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
-<span class="nc" id="L1061"> logDiagnostic("Exception
while trying to find configuration file " + name + ":" +
e.getMessage());</span>
+<span class="fc" id="L1071"> return
ClassLoader.getSystemResources(name);</span>
+<span class="nc" id="L1072"> } catch (final IOException e) {</span>
+<span class="nc bnc" id="L1073" title="All 2 branches missed.">
if (isDiagnosticsEnabled()) {</span>
+<span class="nc" id="L1074"> logDiagnostic("Exception
while trying to find configuration file " + name + ":" +
e.getMessage());</span>
}
-<span class="nc" id="L1063"> return null;</span>
-<span class="nc" id="L1064"> } catch (final NoSuchMethodError e)
{</span>
+<span class="nc" id="L1076"> return null;</span>
+<span class="nc" id="L1077"> } catch (final NoSuchMethodError e)
{</span>
// we must be running on a 1.1 JVM which doesn't support
// ClassLoader.getSystemResources; just return null in
// this case.
-<span class="nc" id="L1068"> return null;</span>
+<span class="nc" id="L1081"> return null;</span>
}
});
}
@@ -1078,10 +1091,11 @@ public abstract class LogFactory {
* Take care not to expose the value returned by this method to the
* calling application in any way; otherwise the calling app can use that
* info to access data that should not be available to it.
+ * </p>
*/
private static String getSystemProperty(final String key, final String def)
throws SecurityException {
-<span class="fc" id="L1084"> return
AccessController.doPrivileged((PrivilegedAction<String>) () ->
System.getProperty(key, def));</span>
+<span class="fc" id="L1098"> return
AccessController.doPrivileged((PrivilegedAction<String>) () ->
System.getProperty(key, def));</span>
}
/**
@@ -1097,14 +1111,14 @@ public abstract class LogFactory {
* @param t the Throwable to check
*/
protected static void handleThrowable(final Throwable t) {
-<span class="pc bpc" id="L1100" title="1 of 2 branches missed."> if (t
instanceof ThreadDeath) {</span>
-<span class="nc" id="L1101"> throw (ThreadDeath) t;</span>
+<span class="pc bpc" id="L1114" title="1 of 2 branches missed."> if (t
instanceof ThreadDeath) {</span>
+<span class="nc" id="L1115"> throw (ThreadDeath) t;</span>
}
-<span class="pc bpc" id="L1103" title="1 of 2 branches missed."> if (t
instanceof VirtualMachineError) {</span>
-<span class="nc" id="L1104"> throw (VirtualMachineError) t;</span>
+<span class="pc bpc" id="L1117" title="1 of 2 branches missed."> if (t
instanceof VirtualMachineError) {</span>
+<span class="nc" id="L1118"> throw (VirtualMachineError) t;</span>
}
// All other instances of Throwable will be silently ignored
-<span class="fc" id="L1107"> }</span>
+<span class="fc" id="L1121"> }</span>
/**
* Determines whether the given class actually implements {@code
LogFactory}.
@@ -1117,43 +1131,44 @@ public abstract class LogFactory {
* @return true if the {@code logFactoryClass} does extend
* {@code LogFactory} when that class is loaded via the same
* class loader that loaded the {@code logFactoryClass}.
+ * </p>
*/
private static boolean implementsLogFactory(final Class<?>
logFactoryClass) {
-<span class="nc" id="L1122"> boolean implementsLogFactory =
false;</span>
-<span class="nc bnc" id="L1123" title="All 2 branches missed."> if
(logFactoryClass != null) {</span>
+<span class="nc" id="L1137"> boolean implementsLogFactory =
false;</span>
+<span class="nc bnc" id="L1138" title="All 2 branches missed."> if
(logFactoryClass != null) {</span>
try {
-<span class="nc" id="L1125"> final ClassLoader
logFactoryClassLoader = logFactoryClass.getClassLoader();</span>
-<span class="nc bnc" id="L1126" title="All 2 branches missed.">
if (logFactoryClassLoader == null) {</span>
-<span class="nc" id="L1127"> logDiagnostic("[CUSTOM
LOG FACTORY] was loaded by the boot class loader");</span>
+<span class="nc" id="L1140"> final ClassLoader
logFactoryClassLoader = logFactoryClass.getClassLoader();</span>
+<span class="nc bnc" id="L1141" title="All 2 branches missed.">
if (logFactoryClassLoader == null) {</span>
+<span class="nc" id="L1142"> logDiagnostic("[CUSTOM
LOG FACTORY] was loaded by the boot class loader");</span>
} else {
-<span class="nc" id="L1129"> logHierarchy("[CUSTOM LOG
FACTORY] ", logFactoryClassLoader);</span>
-<span class="nc" id="L1130"> final Class<?>
factoryFromCustomLoader =
Class.forName("org.apache.commons.logging.LogFactory", false,
logFactoryClassLoader);</span>
-<span class="nc" id="L1131"> implementsLogFactory =
factoryFromCustomLoader.isAssignableFrom(logFactoryClass);</span>
-<span class="nc" id="L1132"> final String
logFactoryClassName = logFactoryClass.getName();</span>
-<span class="nc bnc" id="L1133" title="All 2 branches missed.">
if (implementsLogFactory) {</span>
-<span class="nc" id="L1134">
logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClassName + "
implements LogFactory but was loaded by an incompatible class
loader.");</span>
+<span class="nc" id="L1144"> logHierarchy("[CUSTOM LOG
FACTORY] ", logFactoryClassLoader);</span>
+<span class="nc" id="L1145"> final Class<?>
factoryFromCustomLoader =
Class.forName("org.apache.commons.logging.LogFactory", false,
logFactoryClassLoader);</span>
+<span class="nc" id="L1146"> implementsLogFactory =
factoryFromCustomLoader.isAssignableFrom(logFactoryClass);</span>
+<span class="nc" id="L1147"> final String
logFactoryClassName = logFactoryClass.getName();</span>
+<span class="nc bnc" id="L1148" title="All 2 branches missed.">
if (implementsLogFactory) {</span>
+<span class="nc" id="L1149">
logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClassName + "
implements LogFactory but was loaded by an incompatible class
loader.");</span>
} else {
-<span class="nc" id="L1136">
logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClassName + "
does not implement LogFactory.");</span>
+<span class="nc" id="L1151">
logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClassName + "
does not implement LogFactory.");</span>
}
}
-<span class="nc" id="L1139"> } catch (final SecurityException e)
{</span>
+<span class="nc" id="L1154"> } catch (final SecurityException e)
{</span>
//
// The application is running within a hostile security
environment.
// This will make it very hard to diagnose issues with JCL.
// Consider running less securely whilst debugging this issue.
//
-<span class="nc" id="L1145"> logDiagnostic("[CUSTOM LOG
FACTORY] SecurityException caught trying to determine whether "</span>
-<span class="nc" id="L1146"> + "the compatibility
was caused by a class loader conflict: " + e.getMessage());</span>
-<span class="nc" id="L1147"> } catch (final LinkageError e) {</span>
+<span class="nc" id="L1160"> logDiagnostic("[CUSTOM LOG
FACTORY] SecurityException caught trying to determine whether "</span>
+<span class="nc" id="L1161"> + "the compatibility
was caused by a class loader conflict: " + e.getMessage());</span>
+<span class="nc" id="L1162"> } catch (final LinkageError e) {</span>
//
// This should be an unusual circumstance.
// LinkageError's usually indicate that a dependent class has
incompatibly changed.
// Another possibility may be an exception thrown by an
initializer.
// Time for a clean rebuild?
//
-<span class="nc" id="L1154"> logDiagnostic("[CUSTOM LOG
FACTORY] LinkageError caught trying to determine whether "</span>
-<span class="nc" id="L1155"> + "the compatibility
was caused by a class loader conflict: " + e.getMessage());</span>
-<span class="nc" id="L1156"> } catch (final ClassNotFoundException
e) {</span>
+<span class="nc" id="L1169"> logDiagnostic("[CUSTOM LOG
FACTORY] LinkageError caught trying to determine whether "</span>
+<span class="nc" id="L1170"> + "the compatibility
was caused by a class loader conflict: " + e.getMessage());</span>
+<span class="nc" id="L1171"> } catch (final ClassNotFoundException
e) {</span>
//
// LogFactory cannot be loaded by the class loader which
loaded the custom factory implementation.
// The custom implementation is not viable until this is
corrected.
@@ -1161,11 +1176,11 @@ public abstract class LogFactory {
// Running with diagnostics on should give information about
the class loaders used
// to load the custom factory.
//
-<span class="nc" id="L1164"> logDiagnostic("[CUSTOM LOG
FACTORY] LogFactory class cannot be loaded by the class loader which loaded
"</span>
+<span class="nc" id="L1179"> logDiagnostic("[CUSTOM LOG
FACTORY] LogFactory class cannot be loaded by the class loader which loaded
"</span>
+ "the custom LogFactory implementation. Is the
custom factory in the right class loader?");
-<span class="nc" id="L1166"> }</span>
+<span class="nc" id="L1181"> }</span>
}
-<span class="nc" id="L1168"> return implementsLogFactory;</span>
+<span class="nc" id="L1183"> return implementsLogFactory;</span>
}
/**
@@ -1177,42 +1192,42 @@ public abstract class LogFactory {
private static PrintStream initDiagnostics() {
String dest;
try {
-<span class="fc" id="L1180"> dest =
getSystemProperty(DIAGNOSTICS_DEST_PROPERTY, null);</span>
[... 444 lines stripped ...]