Browse Source

make sure classloader cleans up resources in any case, PR 38260, submitted by Stephan Michels

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@373714 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 19 years ago
parent
commit
bd8be1a39f
5 changed files with 19 additions and 9 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +2
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +4
    -1
      src/main/org/apache/tools/ant/taskdefs/Available.java
  5. +8
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java

+ 1
- 0
CONTRIBUTORS View File

@@ -210,6 +210,7 @@ Stefan Bodewig
Stefano Mazzocchi
Stephane Bailliez
stephan
Stephan Michels
Stephen Chin
Steve Cohen
Steve Loughran


+ 2
- 0
WHATSNEW View File

@@ -181,6 +181,8 @@ Fixed bugs:
* <junit> task did not print all the Test names when using forkmode='once'.
Bugzilla report 37426.

* <available> could leak resources, Bugzilla Report 38260.

Other changes:
--------------
* Minor performance improvements Bugzilla report 37777


+ 4
- 0
contributors.xml View File

@@ -856,6 +856,10 @@
<name>
<last>stephan</last>
</name>
<name>
<first>Stephan</first>
<last>Michels</last>
</name>
<name>
<first>Stephen</first>
<last>Chin</last>


+ 4
- 1
src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2005 The Apache Software Foundation
* Copyright 2000-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -233,6 +233,7 @@ public class Available extends Task implements Condition {
* @exception BuildException if the condition is not configured correctly
*/
public boolean eval() throws BuildException {
try {
if (classname == null && file == null && resource == null) {
throw new BuildException("At least one of (classname|file|"
+ "resource) is required", getLocation());
@@ -273,6 +274,7 @@ public class Available extends Task implements Condition {
Project.MSG_VERBOSE);
return false;
}
} finally {
if (loader != null) {
loader.cleanup();
loader = null;
@@ -280,6 +282,7 @@ public class Available extends Task implements Condition {
if (!isTask) {
setTaskName(null);
}
}
return true;
}



+ 8
- 8
src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2005 The Apache Software Foundation
* Copyright 2000-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -665,6 +665,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool {
JarFile wlJar = null;
File newWLJarFile = null;
JarOutputStream newJarStream = null;
ClassLoader genericLoader = null;

try {
log("Checking if weblogic Jar needs to be rebuilt for jar " + weblogicJarFile.getName(),
@@ -694,8 +695,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool {
}

//Cycle Through generic and make sure its in weblogic
ClassLoader genericLoader
= getClassLoaderFromJar(genericJarFile);
genericLoader = getClassLoaderFromJar(genericJarFile);

for (Enumeration e = genericEntries.keys(); e.hasMoreElements();) {
String filepath = (String) e.nextElement();
@@ -797,11 +797,6 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool {
log("Weblogic Jar rebuild needed due to changed "
+ "interface or XML", Project.MSG_VERBOSE);
}

if (genericLoader instanceof AntClassLoader) {
AntClassLoader loader = (AntClassLoader) genericLoader;
loader.cleanup();
}
} else {
rebuild = true;
}
@@ -846,6 +841,11 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool {
rebuild = true;
}
}
if (genericLoader != null
&& genericLoader instanceof AntClassLoader) {
AntClassLoader loader = (AntClassLoader) genericLoader;
loader.cleanup();
}
}

return rebuild;


Loading…
Cancel
Save