Author: skitching
Date: Mon Jun 20 03:09:51 2005
New Revision: 191431

URL: http://svn.apache.org/viewcvs?rev=191431&view=rev
Log:
Issue warning instead of error when ALLOW_FLAWED_CONTEXT is true and the context
classloader is not related to the classloader used for LogFactoryImpl. This can
happen with JBoss' Unified Classloader approach. See bugzilla#35423.
Thanks to Brian Stansberry for the patch.

Modified:
    
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java

Modified: 
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java?rev=191431&r1=191430&r2=191431&view=diff
==============================================================================
--- 
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
 (original)
+++ 
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java
 Mon Jun 20 03:09:51 2005
@@ -949,10 +949,26 @@
                 contextClassLoader, thisClassLoader);
 
         if (baseClassLoader == null) {
+           // The two classloaders are not part of a parent child relationship.
+           // In some classloading setups (e.g. JBoss with its 
+           // UnifiedLoaderRepository) this can still work, so if user hasn't
+           // forbidden it, just return the contextClassLoader.
+           if (allowFlawedContext) {              
+              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
+              // contextClassLoader is not null, so we can just return it.
+              return contextClassLoader;
+           }
+           else {
             throw new LogConfigurationException(
                 "Bad classloader hierarchy; LogFactoryImpl was loaded via"
                 + " a classloader that is not related to the current context"
-                + " classloader."); 
+                + " classloader.");
+           }           
         }
 
         if (baseClassLoader != contextClassLoader) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to