Browse Source

I'm always scared of changing the core classes, so would be more reluctant to commit this if it wasnt needed so much by Axis. Once committed. I'm going to do more soak testing.

Purpose of fix: use weak references on Java1.2+ for the createdTasks list.
We may want to think of cleaning this list up for extra leak prevention.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273320 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 23 years ago
parent
commit
263a1d74de
1 changed files with 11 additions and 5 deletions
  1. +11
    -5
      src/main/org/apache/tools/ant/Project.java

+ 11
- 5
src/main/org/apache/tools/ant/Project.java View File

@@ -69,6 +69,7 @@ import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.JavaEnvUtils;
import org.apache.tools.ant.util.WeakishReference;

/**
* Central representation of an Ant project. This class defines an
@@ -1172,7 +1173,7 @@ public class Project {
v = new Vector();
createdTasks.put(type, v);
}
v.addElement(task);
v.addElement(WeakishReference.createReference(task));
}
}

@@ -1189,8 +1190,13 @@ public class Project {
if (v != null) {
Enumeration enum = v.elements();
while (enum.hasMoreElements()) {
Task t = (Task) enum.nextElement();
t.markInvalid();
WeakishReference ref=
(WeakishReference) enum.nextElement();
Task t = (Task) ref.get();
//being a weak ref, it may be null by this point
if(t!=null) {
t.markInvalid();
}
}
v.removeAllElements();
createdTasks.remove(type);
@@ -1802,10 +1808,10 @@ public class Project {
valueAsString = value.toString();
} catch (Throwable t) {
log("Caught exception (" + t.getClass().getName() +")"
+ " while expanding " + name + ": " + t.getMessage(),
+ " while expanding " + name + ": " + t.getMessage(),
MSG_WARN);
}
log("Adding reference: " + name + " -> " + valueAsString,
log("Adding reference: " + name + " -> " + valueAsString,
MSG_DEBUG);
references.put(name, value);
}


Loading…
Cancel
Save