You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by "Pavel Sher (JIRA)" <ji...@apache.org> on 2009/12/22 11:10:29 UTC
[jira] Commented: (IVY-1152) Ivy does not close URL connection to
ivy-report.xsl properly
[ https://issues.apache.org/jira/browse/IVY-1152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12793573#action_12793573 ]
Pavel Sher commented on IVY-1152:
---------------------------------
Well, I tried to fix this issue in the same way, however this does not seem to work.
The opened input stream seems to be left after the getLastModified() call inside void download(URL src, File dest, CopyProgressListener l) method:
long lastModified = srcConn.getLastModified();
if (lastModified > 0) {
dest.setLastModified(lastModified);
}
if I add additional check to this code:
if (!(srcConn instanceof java.net.JarURLConnection)) {
long lastModified = srcConn.getLastModified();
if (lastModified > 0) {
dest.setLastModified(lastModified);
}
}
The stream is not open anymore, and everything looks fine. On Windows you can check it with help of SysInternals Process Explorer. On Unix you can probably use lsof utility (however I did not try it).
Basically it looks like a bug in JVM, and it is not critical for those who use Ivy inside short lived processes. I've reproduced this problem in our tests which start artifacts resolution process via Ivy API, however I am not sure whether these not closed input streams do any harm. I also tried different versions of JVM and it looks like in Java 1.5 this bug is not so easy reproducable as it in Java 1.6. In Java 1.5 I see 2 streams open and this number is not increasing, while in Java 1.6 I see about 20 streams and it seems their number grows if I run more tests.
Maybe it is safer to use Class.getResourceAsStream instead of URLs.
> Ivy does not close URL connection to ivy-report.xsl properly
> ------------------------------------------------------------
>
> Key: IVY-1152
> URL: https://issues.apache.org/jira/browse/IVY-1152
> Project: Ivy
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0, 2.1.0
> Reporter: Pavel Sher
> Assignee: Maarten Coene
> Fix For: trunk
>
>
> It seems BasicURLHanlder.disconnect() does not properly close URL connection to ivy-report.xsl file. In my case URL looks like:
> jar:file:/<path>/ivy-2.0.jar!/org/apache/ivy/plugins/report/ivy-report.xsl
> In disconnect() method there is a check for URL connection class:
> "sun.net.www.protocol.file.FileURLConnection".equals(con.getClass().getName())
> However in runtime this check does not work because instead of FileURLConnection there is JarURLConnection:
> sun.net.www.protocol.jar.JarURLConnection
> This leads to leaked input streams if Ivy is used programmatically within the same JVM.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.