diff --git a/CONTRIBUTORS b/CONTRIBUTORS index bff5714ea..78278e795 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -210,6 +210,7 @@ Stefan Bodewig Stefano Mazzocchi Stephane Bailliez stephan +Stephan Michels Stephen Chin Steve Cohen Steve Loughran diff --git a/WHATSNEW b/WHATSNEW index 03dd33a41..9f5212f26 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -181,6 +181,8 @@ Fixed bugs: * task did not print all the Test names when using forkmode='once'. Bugzilla report 37426. +* could leak resources, Bugzilla Report 38260. + Other changes: -------------- * Minor performance improvements Bugzilla report 37777 diff --git a/contributors.xml b/contributors.xml index 9a4e61cde..c03f30634 100644 --- a/contributors.xml +++ b/contributors.xml @@ -856,6 +856,10 @@ stephan + + Stephan + Michels + Stephen Chin diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java index 822aa7ca1..beec53e71 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Available.java +++ b/src/main/org/apache/tools/ant/taskdefs/Available.java @@ -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; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java index 0a1e17792..8506fc071 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java @@ -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;