Bug 47465 - Reading configuration files from a JAR locks the JAR file
Reading configuration files from a JAR locks the JAR file
Product: Log4j
Classification: Unclassified
Component: Configurator
All All
: P2 normal
: ---
Assigned To: log4j-dev
Depends on:
  Show dependency tree
Reported: 2009-07-02 03:20 UTC by Mark Thomas
Modified: 2009-10-03 15:06 UTC (History)
0 users

Patch and test cases (5.55 KB, patch)
2009-07-02 03:45 UTC, Mark Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Thomas 2009-07-02 03:20:48 UTC
If a log4j configuration file is found by the classpath search inside a JAR file, the file will be loaded from the JAR. However, the initial URLConnection.getDefaultUseCaches() setting means that caching is used and the JAR file is locked.

This is a particular problem for container environments like Tomcat, as it prevents a web application from being removed. Whilst the workaround is simple - don't put your log4j configuration in a JAR - it impacts a large number of users.

I have a patch and test case for PropertyConfigurator. I still need to test DOMConfigurator. I will update this bug report with the results of that test (and a patch if necessary) later today.
Comment 1 Mark Thomas 2009-07-02 03:45:08 UTC
Created attachment 23919 [details]
Patch and test cases

Test cases to demonstrate the issue and a patch to fix the issue attached.

Note the test cases use files paths that work on my machine. These do not appear to be consistent with the other test cases so a few tweaks may be required.
Comment 2 Scott Deboy 2009-10-03 15:06:23 UTC
Patch applied to svn trunk in r821433.

Thanks Mark!