ceki 01/04/22 09:08:24 Modified: docs HISTORY src/java/org/apache/log4j/helpers Loader.java Log: - The previous code in Loader.getResource ignored the delegation model. It was bad code even if it worked. It is amazing how often I keep screwing this up. - Added another try-catch block for InvalidJarIndexException where required. - Changed "caught InvalidJarIndexException" LogLog.warning message to LogLog.debug Revision Changes Path 1.40 +6 -3 jakarta-log4j/docs/HISTORY Index: HISTORY =================================================================== RCS file: /home/cvs/jakarta-log4j/docs/HISTORY,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- HISTORY 2001/04/22 15:10:51 1.39 +++ HISTORY 2001/04/22 16:08:23 1.40 @@ -10,11 +10,14 @@ - Release of version 1.1b5 - - Corrected a performance bug in LocationInfo. [*] + - Corrected an important performance bug in LocationInfo. Hein Couwet + and [EMAIL PROTECTED] have independently identified the bug. This is + yet another example of the fact that the number of eyeballs + studying code makes a difference. [*] - Corrected the incorrect value returned by LocationInfo.getClassName - method when running under Visual Age. Thanks to Mathias Rupprecht - for supplying the relevant patch. [*] + method when running under IBM Visual Age. Thanks to Mathias + Rupprecht for supplying the relevant patch. [*] - Corrected a bug where the build.sh file in the distribution would be in DOS CRLF format. Thanks to [EMAIL PROTECTED] for reporting the 1.5 +24 -16 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.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Loader.java 2001/04/22 14:05:49 1.4 +++ Loader.java 2001/04/22 16:08:24 1.5 @@ -20,6 +20,7 @@ public class Loader extends java.lang.Object { + static String JARSTR = "Caught InvalidJarException. This may be innocuous."; /** This method will search for <code>resource</code> in different @@ -54,19 +55,20 @@ // changed to directory separators LogLog.debug("Trying to find ["+resource+"] using Class.getResource()."); - try - { + + + try { url = clazz.getResource(resource); - } - catch (sun.misc.InvalidJarIndexException e) - { - LogLog.warn("Caught InvalidJarException!"); + if(url != null) + return url; + } catch (sun.misc.InvalidJarIndexException e) { + LogLog.debug(JARSTR); } - if(url != null) - return url; - // attempt to get the resource under CLAZZ/resource from the system class path + // attempt to get the resource under CLAZZ/resource from the + // system class path. The system class loader should not throw + // InvalidJarIndexExceptions String fullyQualified = resolveName(resource, clazz); LogLog.debug("Trying to find ["+fullyQualified+ "] using ClassLoader.getSystemResource()."); @@ -74,18 +76,24 @@ if(url != null) return url; - // Try all the class loaders of clazz and parents looking resource - for(ClassLoader loader = clazz.getClassLoader(); loader != null; - loader = loader.getParent()) { - LogLog.debug("Trying to find ["+resource+"] using "+loader+" class loader."); + // Let the class loader of clazz and parents (by the delagation + // property) seearch for resource + ClassLoader loader = clazz.getClassLoader(); + LogLog.debug("Trying to find ["+resource+"] using "+loader + +" class loader."); + + try { url = loader.getResource(resource); if(url != null) return url; + } catch(sun.misc.InvalidJarIndexException e) { + LogLog.debug(JARSTR); } - - + - // attempt to get the resource from the class path + // Attempt to 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 code below. LogLog.debug("Trying to find ["+resource+"] using ClassLoader.getSystemResource()."); url = ClassLoader.getSystemResource(resource); return url; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]