[ 
https://issues.apache.org/jira/browse/LOG4J2-3423?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Radim Tlusty reopened LOG4J2-3423:
----------------------------------

I like the solution with {{setUseCaches(false)}} and it resolves the problem 
with closing of the JAR file, when the obtained input stream with the logging 
configuration is closed.

Unfortunately when I've used the SNAPSHOT version in my test, the JAR file 
still remains open. 

It probably relates to invocation of the {{UrlConnection.getLastModified()}} 
method. 

This is called from {{ConfigurationSource.getConfigurationSource(URL)}} when 
the file can't be resolved from the URL and it's probably the case when URL to 
JAR resource is used, because the URL format is something like 
{{jar:file:<path-to-jar-file>!<resource-within-jar>}}. 

The method {{getLastModified}} finally ends up in class 
{{sun.net.www.protocol.file.FileURLConnection}}, which seems to open the stream 
and never closes it.

> JAR file containing Log4j configuration isn't closed
> ----------------------------------------------------
>
>                 Key: LOG4J2-3423
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3423
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.14.0
>         Environment: Windows
>            Reporter: Radim Tlusty
>            Assignee: Gary D. Gregory
>            Priority: Major
>             Fix For: 2.17.3
>
>
> If the Log4j configuration file is inside of a JAR file, then the JAR file 
> (which is backed by the {{JarURLConnection}} retrieved from 
> {{{}URL.openConnection{}}}) isn't closed.
> This causes problems on Tomcat running on Windows during undeploying of an 
> application, because the opened JAR file can't be deleted.
> The problem was introduced during implementation of LOG4J2-2901 (version 
> 2.14.0), where the {{URL.openStream}} was replaced by {{URL.openConnection}} 
> in the class {{{}org.apache.logging.log4j.core.config.ConfigurationSource{}}}.
> The proposed solution (https://github.com/apache/logging-log4j2/pull/780) is 
> to use the {{URL.openConnection}} only when needed (~ configuration URL has 
> HTTPS protocol), otherwise similar code as in previous versions (<= 2.13.3) 
> would be used.
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to