You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2002/04/24 23:25:33 UTC

cvs commit: jakarta-log4j/src/java/org/apache/log4j/xml log4j.dtd

ceki        02/04/24 14:25:33

  Modified:    src/java/org/apache/log4j/helpers Loader.java
               src/java/org/apache/log4j/jdbc JDBCAppender.java
               src/java/org/apache/log4j/xml log4j.dtd
  Log:
  - Defesive code in case Loader.class.getClassLoader returns null.
  
  - Removed an extra System.out.println statement in JDBCAppender
  
  Revision  Changes    Path
  1.17      +30 -27    jakarta-log4j/src/java/org/apache/log4j/helpers/Loader.java
  
  Index: Loader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/helpers/Loader.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Loader.java	22 Feb 2002 10:39:55 -0000	1.16
  +++ Loader.java	24 Apr 2002 21:25:32 -0000	1.17
  @@ -61,7 +61,7 @@
     URL getResource(String resource) {
       ClassLoader classLoader = null;
       URL url = null;
  -
  +    
       try {
         if(!java1) {
   	classLoader = Thread.currentThread().getContextClassLoader();	
  @@ -78,17 +78,21 @@
         // We could not find resource. Ler us now try with the
         // classloader that loaded this class.
         classLoader = Loader.class.getClassLoader(); 
  -
  -      LogLog.debug("Trying to find ["+resource+"] using "+classLoader
  -		   +" class loader.");
  -      url = classLoader.getResource(resource);      
  -      if(url != null) {
  -	return url;
  +      if(classLoader == null) {
  +	LogLog.warn("Loader.class.getClassLoader returned null!");
  +      } else {
  +	
  +	LogLog.debug("Trying to find ["+resource+"] using "+classLoader
  +		     +" class loader.");
  +	url = classLoader.getResource(resource);
  +	if(url != null) {
  +	  return url;
  +	}
         }
       } catch(Throwable t) {
         LogLog.warn(TSTR, t);
       }
  -
  +    
       // Last ditch attempt: get the resource from the class path. It
       // may be the case that clazz was loaded by the Extentsion class
       // loader which the parent of the system class loader. Hence the
  @@ -97,18 +101,17 @@
   		 "] using ClassLoader.getSystemResource().");
       return ClassLoader.getSystemResource(resource);
     } 
  -
  +  
     /**
  -     Are we running under JDK 1.x? 
  -          
  -   */
  +     Are we running under JDK 1.x?        
  +  */
     public
     static
     boolean isJava1() {
       return java1;
     }
  -
  -
  +  
  +  
     /**
        Load the specified class using the <code>Thread</code>
        <code>contextClassLoader</code> if running under Java2 or current
  @@ -118,18 +121,18 @@
     public 
     Class loadClass (Double clazz) throws ClassNotFoundException {
       return null;
  -//    if(java1) {
  -//	return Class.forName(clazz);
  -//    } else {
  -//	try {
  -//	  return Thread.currentThread().getContextClassLoader().loadClass(clazz);
  -//	} catch(Exception e) {
  -//	  // we reached here because
  -//	  // currentThread().getContextClassLoader() is null or because
  -//	  // of a security exceptio, or because clazz could not be
  -//	  // loaded, in any case we now try one more time
  -//	  return Class.forName(clazz);
  -//	}
  -//    }
  +    //    if(java1) {
  +    //	return Class.forName(clazz);
  +    //    } else {
  +    //	try {
  +    //	  return Thread.currentThread().getContextClassLoader().loadClass(clazz);
  +    //	} catch(Exception e) {
  +    //	  // we reached here because
  +    //	  // currentThread().getContextClassLoader() is null or because
  +    //	  // of a security exceptio, or because clazz could not be
  +    //	  // loaded, in any case we now try one more time
  +    //	  return Class.forName(clazz);
  +    //	}
  +    //    }
     } 
   }
  
  
  
  1.6       +1 -1      jakarta-log4j/src/java/org/apache/log4j/jdbc/JDBCAppender.java
  
  Index: JDBCAppender.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/jdbc/JDBCAppender.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JDBCAppender.java	24 Apr 2002 01:16:13 -0000	1.5
  +++ JDBCAppender.java	24 Apr 2002 21:25:32 -0000	1.6
  @@ -164,7 +164,7 @@
       stmt.close();
       closeConnection(con);
   
  -    System.out.println("Execute: " + sql);
  +    //System.out.println("Execute: " + sql);
     }
   
   
  
  
  
  1.16      +1 -3      jakarta-log4j/src/java/org/apache/log4j/xml/log4j.dtd
  
  Index: log4j.dtd
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/log4j.dtd,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- log4j.dtd	26 Mar 2002 08:39:02 -0000	1.15
  +++ log4j.dtd	24 Apr 2002 21:25:32 -0000	1.16
  @@ -24,7 +24,7 @@
        
   <!ATTLIST log4j:configuration
     xmlns:log4j              CDATA #FIXED "http://jakarta.apache.org/log4j/" 
  -  threshold                (all|debug|info|warn|error|fatal|off|null)  "null"
  +  threshold                (all|debug|info|warn|error|fatal|off|null) "null"
     debug                    (true|false|null)  "null"
   >
   
  @@ -56,7 +56,6 @@
     class		CDATA	#REQUIRED
   >
   
  -
   <!-- ErrorHandlers can be of any class. They can admit any number of -->
   <!-- parameters. -->
   
  @@ -71,7 +70,6 @@
   <!ATTLIST logger-ref
     ref IDREF #REQUIRED
   >
  -
   
   <!ELEMENT param EMPTY>
   <!ATTLIST param
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>