Bug 43200 - Log4JEntityResolver will return null if log4j.dtd resource can not be found
Log4JEntityResolver will return null if log4j.dtd resource can not be found
Status: RESOLVED FIXED
Product: Log4j
Classification: Unclassified
Component: Configurator
1.2
Other other
: P2 normal
: ---
Assigned To: log4j-dev
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2007-08-23 09:00 UTC by Curt Arnold
Modified: 2007-10-23 11:41 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Curt Arnold 2007-08-23 09:00:07 UTC
If log4j.dtd can't be found by getResourceAsStream() (likely running in an IDE as described on log4j-dev 
on 2007-08-23 by Scott Deboy), Log4JEntityResolver would return null which would result in the parser 
attempting to locate the resource using the URL.  The change causes Log4JEntityResolver to return an 
InputSource backed by an empty ByteArrayInputStream which will prevent the parser from trying to locate 
log4j.dtd on its own.
Comment 1 Scott Deboy 2007-08-23 10:26:22 UTC
Just tried the xml-based appender/receivers in Chainsaw in an IDE without log4j
src/main/resources in my classpath - I still get an error:

'log4j:ERROR Could not find [log4j.dtd].  Used
[sun.misc.Launcher$AppClassLoad@...] class loader in the search.
Comment 2 Curt Arnold 2007-08-23 11:30:12 UTC
That would be as expected, LogLog.error is still called if the resource could not be found.  The thing that 
changed was instead of returning null which tells the parser to try to find it on its own, an empty 
InputSource is returned which will prevent the parser to try to find it on its own.  So hopefully you lost the 
exception from the parser when it could not find log4j.dtd.  Could downgrade it from a LogLog.error to a 
LogLog.warn.

There are two issues here: one is what do in the case that the resource can not be found.  Other than 
potentially downgrading the message to a LogLog.warn, I think the fix is good.  The other is why you can't 
find the resource and there isn't enough to go on for me to figure that out and to decide if it is a log4j 
issue or a IDE project issue.
Comment 3 Curt Arnold 2007-10-23 11:41:53 UTC
Changes committed rev 569053 and 569147 and released in log4j 1.2.15.