conor 02/05/29 19:56:23
Modified: src/main/org/apache/tools/ant Tag: ANT_15_BRANCH
AntClassLoader.java Project.java
Added: src/testcases/org/apache/tools/ant Tag: ANT_15_BRANCH
AntClassLoaderTest.java
Log:
Handle case where class loader is still active after it has been cleaned up
or the project has ended.
PR: 9138
One thing to note in this change. I have made the fireBuildStarted and fireBuilkdFinished methods public in Project. I think this is overdue to all people to more easily embed Project without trying to embed Main too. It was necessary in the test case I added.
Conor
Revision Changes Path
No revision
No revision
1.52.2.2 +5 -5 jakarta-ant/src/main/org/apache/tools/ant/AntClassLoader.java
Index: AntClassLoader.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/AntClassLoader.java,v
retrieving revision 1.52.2.1
retrieving revision 1.52.2.2
diff -u -w -u -r1.52.2.1 -r1.52.2.2
--- AntClassLoader.java 1 May 2002 06:18:37 -0000 1.52.2.1
+++ AntClassLoader.java 30 May 2002 02:56:23 -0000 1.52.2.2
@@ -391,7 +391,8 @@
if (LoaderUtils.isContextLoaderAvailable()) {
savedContextLoader = LoaderUtils.getContextClassLoader();
ClassLoader loader = this;
- if ("only".equals(project.getProperty("build.sysclasspath"))) {
+ if (project != null + && "only".equals(project.getProperty("build.sysclasspath"))) {
loader = this.getClass().getClassLoader();
}
LoaderUtils.setContextClassLoader(loader);
@@ -1103,10 +1104,7 @@
* Cleans up any resources held by this classloader. Any open archive
* files are closed.
*/
- public void cleanup() {
- project.removeBuildListener(this);
- pathComponents = null;
- project = null;
+ public synchronized void cleanup() {
for (Enumeration e = zipFiles.elements(); e.hasMoreElements();) {
ZipFile zipFile = (ZipFile)e.nextElement();
try {
@@ -1133,6 +1131,8 @@
* @param event the buildFinished event
*/
public void buildFinished(BuildEvent event) {
+ project.removeBuildListener(this);
+ project = null;
cleanup();
}
1.108.2.2 +3 -3 jakarta-ant/src/main/org/apache/tools/ant/Project.java
Index: Project.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
retrieving revision 1.108.2.1
retrieving revision 1.108.2.2
diff -u -w -u -r1.108.2.1 -r1.108.2.2
--- Project.java 28 May 2002 13:53:13 -0000 1.108.2.1
+++ Project.java 30 May 2002 02:56:23 -0000 1.108.2.2
@@ -83,7 +83,7 @@
*
* @author [EMAIL PROTECTED]
*
- * @version $Revision: 1.108.2.1 $
+ * @version $Revision: 1.108.2.2 $
*/
public class Project {
@@ -1755,7 +1755,7 @@
/**
* Sends a "build started" event to the build listeners for this project.
*/
- protected void fireBuildStarted() {
+ public void fireBuildStarted() {
BuildEvent event = new BuildEvent(this);
for (int i = 0; i < listeners.size(); i++) {
BuildListener listener = (BuildListener) listeners.elementAt(i);
@@ -1769,7 +1769,7 @@
* failure. May be <code>null</code>, indicating
* a successful build.
*/
- protected void fireBuildFinished(Throwable exception) {
+ public void fireBuildFinished(Throwable exception) {
BuildEvent event = new BuildEvent(this);
event.setException(exception);
for (int i = 0; i < listeners.size(); i++) {
No revision
No revision
1.1.2.1 +112 -0 jakarta-ant/src/testcases/org/apache/tools/ant/Attic/AntClassLoaderTest.java
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
