commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31597] New: - Incorrect test for availability of log4j
Date Fri, 08 Oct 2004 08:35:05 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31597>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31597

Incorrect test for availability of log4j

           Summary: Incorrect test for availability of log4j
           Product: Commons
           Version: 1.0.3
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Logging
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: nntp_ds@fastmail.fm


Corrrected code from LogFactoryImpl is below.  Log4j is only available if the
the class loader that loads Log4JLogger can load Logger.  The orginal test
is incorrect when both of these conditions are met
a.) the context loader can load Logger ( directly or not ), and
b.) Log4jLogger is actually loaded by a parent of the loader that loads Logger.

The failure of course occurs because Log4jLogger has a direct dep on Logger.

    protected boolean isLog4JAvailable() {

        try {
             
            /* <incorrect> */
            //loadClass("org.apache.log4j.Logger");
            //loadClass("org.apache.commons.logging.impl.Log4JLogger");
            /* </incorrect> */
           
loadClass("org.apache.commons.logging.impl.Log4JLogger").getClassLoader().loadClass(
"org.apache.log4j.Logger" );
            return (true);
        } catch (Throwable t) {
            return (false);
        }
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message