@@ -1407,12 +1407,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { | |||||
*/ | */ | ||||
public synchronized void cleanup() { | public synchronized void cleanup() { | ||||
for (final Enumeration<JarFile> e = jarFiles.elements(); e.hasMoreElements();) { | for (final Enumeration<JarFile> e = jarFiles.elements(); e.hasMoreElements();) { | ||||
final JarFile jarFile = e.nextElement(); | |||||
try { | |||||
jarFile.close(); | |||||
} catch (final IOException ioe) { | |||||
// ignore | |||||
} | |||||
FileUtils.close(e.nextElement()); | |||||
} | } | ||||
jarFiles = new Hashtable<File, JarFile>(); | jarFiles = new Hashtable<File, JarFile>(); | ||||
if (project != null) { | if (project != null) { | ||||
@@ -23,6 +23,7 @@ import java.io.IOException; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
import org.apache.tools.ant.util.FileUtils; | |||||
/** | /** | ||||
* Logs standard output and error of a subprocess to the log system of ant. | * Logs standard output and error of a subprocess to the log system of ant. | ||||
@@ -59,12 +60,7 @@ public class LogStreamHandler extends PumpStreamHandler { | |||||
*/ | */ | ||||
public void stop() { | public void stop() { | ||||
super.stop(); | super.stop(); | ||||
try { | |||||
getErr().close(); | |||||
getOut().close(); | |||||
} catch (IOException e) { | |||||
// plain impossible | |||||
throw new BuildException(e); | |||||
} | |||||
FileUtils.close(getErr()); | |||||
FileUtils.close(getOut()); | |||||
} | } | ||||
} | } |
@@ -692,19 +692,11 @@ public class SQLExec extends JDBCTask { | |||||
} | } | ||||
} finally { | } finally { | ||||
try { | try { | ||||
if (getStatement() != null) { | |||||
getStatement().close(); | |||||
} | |||||
} catch (SQLException ex) { | |||||
// ignore | |||||
} | |||||
try { | |||||
if (getConnection() != null) { | |||||
getConnection().close(); | |||||
} | |||||
FileUtils.close(getStatement()); | |||||
} catch (SQLException ex) { | } catch (SQLException ex) { | ||||
// ignore | // ignore | ||||
} | } | ||||
FileUtils.close(getConnection()); | |||||
} | } | ||||
log(goodSql + " of " + totalSql + " SQL statements executed successfully"); | log(goodSql + " of " + totalSql + " SQL statements executed successfully"); | ||||
@@ -23,6 +23,7 @@ import java.io.IOException; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
import org.apache.tools.ant.util.FileUtils; | |||||
/** | /** | ||||
* Condition to wait for a TCP/IP socket to have a listener. Its attributes are: | * Condition to wait for a TCP/IP socket to have a listener. Its attributes are: | ||||
@@ -73,13 +74,7 @@ public class Socket extends ProjectComponent implements Condition { | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
return false; | return false; | ||||
} finally { | } finally { | ||||
if (s != null) { | |||||
try { | |||||
s.close(); | |||||
} catch (IOException ioe) { | |||||
// Intentionally left blank | |||||
} | |||||
} | |||||
FileUtils.close(s); | |||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
@@ -22,6 +22,7 @@ import java.io.IOException; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.taskdefs.PumpStreamHandler; | import org.apache.tools.ant.taskdefs.PumpStreamHandler; | ||||
import org.apache.tools.ant.util.FileUtils; | |||||
/** | /** | ||||
* A dummy stream handler that just passes stuff to the parser. | * A dummy stream handler that just passes stuff to the parser. | ||||
@@ -49,13 +50,8 @@ class RedirectingStreamHandler | |||||
public void stop() { | public void stop() { | ||||
super.stop(); | super.stop(); | ||||
try { | |||||
getErr().close(); | |||||
getOut().close(); | |||||
} catch (final IOException e) { | |||||
// plain impossible | |||||
throw new BuildException(e); | |||||
} | |||||
FileUtils.close(getErr()); | |||||
FileUtils.close(getOut()); | |||||
} | } | ||||
} | } | ||||
@@ -267,16 +267,10 @@ public abstract class AbstractAnalyzer implements DependencyAnalyzer { | |||||
} | } | ||||
} else { | } else { | ||||
// must be a zip of some sort | // must be a zip of some sort | ||||
ZipFile zipFile = null; | |||||
try { | |||||
zipFile = new ZipFile(element); | |||||
try (ZipFile zipFile = new ZipFile(element)) { | |||||
if (zipFile.getEntry(resourceLocation) != null) { | if (zipFile.getEntry(resourceLocation) != null) { | ||||
return element; | return element; | ||||
} | } | ||||
} finally { | |||||
if (zipFile != null) { | |||||
zipFile.close(); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||