[ 
http://jira.qos.ch/browse/LBCORE-127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ceki Gulcu resolved LBCORE-127.
-------------------------------

    Fix Version/s: 0.9.18
       Resolution: Fixed

Fixed in 
http://github.com/ceki/logback/commit/f73e9afc1951ff45ebaae0d0806e6126aab37bc8

> Logback auto config closes the jar file previously opened in user code
> ----------------------------------------------------------------------
>
>                 Key: LBCORE-127
>                 URL: http://jira.qos.ch/browse/LBCORE-127
>             Project: logback-core
>          Issue Type: Bug
>          Components: Joran
>    Affects Versions: 0.9.17
>            Reporter: tomliliu
>            Assignee: Ceki Gulcu
>            Priority: Blocker
>             Fix For: 0.9.18
>
>
> User code opens an input stream from a jar file first. Then logback auto 
> config loads the configuration file from the same jar. User code will get the 
> following exception when read the input stream later.
> {code title="Stack Trace"}
> java.util.zip.ZipException: ZipFile closed
>       at java.util.zip.ZipFile.ensureOpenOrZipException(ZipFile.java:413)
>       at java.util.zip.ZipFile.access$1100(ZipFile.java:29)
>       at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:445)
>       at java.io.FilterInputStream.read(FilterInputStream.java:116)
>       at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
>       at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
>       at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
>       at java.io.InputStreamReader.read(InputStreamReader.java:167)
>       at java.io.BufferedReader.fill(BufferedReader.java:136)
>       at java.io.BufferedReader.readLine(BufferedReader.java:299)
>       at java.io.BufferedReader.readLine(BufferedReader.java:362)
> {code}
> {code title="Reproduce"}
> InputStream resourceAsStream = 
> Thread.currentThread().getContextClassLoader().getResourceAsStream(logLocation);
> BufferedReader reader = new BufferedReader(new 
> InputStreamReader(resourceAsStream));            
> final Logger logger = LoggerFactory.getLogger(LogbackBugReproduce.class);
> logger.debug(reader.readLine());
> {code}
> It looks like in 
> ch.qos.logback.core.joran.GenericConfigurator.doConfigure(URL url) method:
> urlConnection.setDefaultUseCaches(false);
> InputStream in = urlConnection.getInputStream();
> doConfigure(in);
> in.close();
> The input stream is associated with the same zip file instance of the users. 
> Then close the input stream will close the zip file that user currently is 
> using.
> After changing it to:
> urlConnection.setUseCaches(false);
> InputStream in = urlConnection.getInputStream();
> doConfigure(in);
>  in.close();
> The input stream is associated with a different zip file instance. Then close 
> the input stream will not affect the zip file used by the user code.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
logback-dev mailing list
logback-dev@qos.ch
http://qos.ch/mailman/listinfo/logback-dev

Reply via email to