Antoine Levy-Lambert 19 years ago
parent
commit
85168f7e1a
1 changed files with 23 additions and 1 deletions
  1. +23
    -1
      src/main/org/apache/tools/ant/types/resources/URLResource.java

+ 23
- 1
src/main/org/apache/tools/ant/types/resources/URLResource.java View File

@@ -25,6 +25,8 @@ import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;
import java.net.JarURLConnection;
import java.util.jar.JarFile;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
@@ -202,7 +204,9 @@ public class URLResource extends Resource {
}
try {
connect();
return conn.getContentLength();
long contentlength = conn.getContentLength();
close();
return contentlength;
} catch (IOException e) {
return UNKNOWN_SIZE;
}
@@ -300,11 +304,29 @@ public class URLResource extends Resource {
}
}

private void close() {
if (conn != null) {
try {
if (conn instanceof JarURLConnection) {
JarURLConnection juc = (JarURLConnection) conn;
JarFile jf = juc.getJarFile();
jf.close();
jf = null;
}
} catch (IOException exc) {

} finally {
conn = null;
}
}
}

/**
* Finalize this URLResource.
* @throws Throwable on error.
*/
protected void finalize() throws Throwable {
close();
conn = null;
super.finalize();
}


Loading…
Cancel
Save