Browse Source

More classloader improvements

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269353 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
f1bfa32916
3 changed files with 23 additions and 22 deletions
  1. +19
    -22
      src/main/org/apache/tools/ant/AntClassLoader.java
  2. +3
    -0
      src/main/org/apache/tools/ant/taskdefs/Available.java
  3. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java

+ 19
- 22
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -629,10 +629,6 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
return useParentFirst; return useParentFirst;
} }






/** /**
* Finds the resource with the given name. A resource is * Finds the resource with the given name. A resource is
* some data (images, audio, text, etc) * some data (images, audio, text, etc)
@@ -730,22 +726,18 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
} }
} }
else { else {
ZipFile zipFile = null;
try {
ZipFile zipFile = (ZipFile)zipFiles.get(file);
if (zipFile == null) {
zipFile = new ZipFile(file); zipFile = new ZipFile(file);

ZipEntry entry = zipFile.getEntry(resourceName);
if (entry != null) {
try {
return new URL("jar:file:"+file.toString()+"!/"+entry);
} catch (MalformedURLException ex) {
return null;
}
}
zipFiles.put(file, zipFile);
} }
finally {
if (zipFile != null) {
zipFile.close();

ZipEntry entry = zipFile.getEntry(resourceName);
if (entry != null) {
try {
return new URL("jar:file:"+file.toString()+"!/"+entry);
} catch (MalformedURLException ex) {
return null;
} }
} }
} }
@@ -937,10 +929,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
} }
} }


public void buildStarted(BuildEvent event) {
}

public void buildFinished(BuildEvent event) {
public void cleanup() {
pathComponents = null; pathComponents = null;
project = null; project = null;
for (Enumeration e = zipFiles.elements(); e.hasMoreElements(); ) { for (Enumeration e = zipFiles.elements(); e.hasMoreElements(); ) {
@@ -952,6 +941,14 @@ public class AntClassLoader extends ClassLoader implements BuildListener {
// ignore // ignore
} }
} }
zipFiles = new Hashtable();
}
public void buildStarted(BuildEvent event) {
}

public void buildFinished(BuildEvent event) {
cleanup();
} }


public void targetStarted(BuildEvent event) { public void targetStarted(BuildEvent event) {


+ 3
- 0
src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -164,6 +164,9 @@ public class Available extends Task {
} }


this.project.setProperty(property, value); this.project.setProperty(property, value);
if (loader != null) {
loader.cleanup();
}
} }


private boolean checkFile() { private boolean checkFile() {


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java View File

@@ -145,6 +145,7 @@ public class ExecuteJava {
} finally { } finally {
if (loader != null) { if (loader != null) {
loader.resetThreadContextLoader(); loader.resetThreadContextLoader();
loader.cleanup();
} }
if (sysProperties != null) { if (sysProperties != null) {
sysProperties.restoreSystem(); sysProperties.restoreSystem();


Loading…
Cancel
Save