summaryrefslogtreecommitdiff
path: root/src/main/org/apache/tools
diff options
context:
space:
mode:
authorStefan Bodewig <bodewig@apache.org>2016-03-28 14:07:23 +0200
committerStefan Bodewig <bodewig@apache.org>2016-03-28 14:07:46 +0200
commita8d6367ddc214b4956b2a7d6b779930df5e43515 (patch)
tree8ff2a5c346ab236bf16bcb6ed6ee7ce6ab3f56b1 /src/main/org/apache/tools
parentcd1ff3566ed915392041314eb583a638bcb1eb64 (diff)
downloadant-a8d6367ddc214b4956b2a7d6b779930df5e43515.tar.gz
remove re-implementations of FileUtils.close()
Diffstat (limited to 'src/main/org/apache/tools')
-rw-r--r--src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java7
-rw-r--r--src/main/org/apache/tools/ant/DefaultLogger.java4
-rw-r--r--src/main/org/apache/tools/ant/DemuxOutputStream.java7
-rw-r--r--src/main/org/apache/tools/ant/listener/AnsiColorLogger.java9
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Ant.java6
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/CVSPass.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Javadoc.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Property.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Redirector.java17
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java25
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java7
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java7
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java9
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java7
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java16
-rw-r--r--src/main/org/apache/tools/ant/types/resources/TarResource.java4
20 files changed, 36 insertions, 145 deletions
diff --git a/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java b/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
index bdb7c0a8a..ae95c3b79 100644
--- a/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
+++ b/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
+import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.LoaderUtils;
/**
@@ -159,11 +160,7 @@ public class ArgumentProcessorRegistry {
return getProcessor(processorClassName);
}
} finally {
- try {
- isr.close();
- } catch (IOException e) {
- // ignore
- }
+ FileUtils.close(isr);
}
return null;
}
diff --git a/src/main/org/apache/tools/ant/DefaultLogger.java b/src/main/org/apache/tools/ant/DefaultLogger.java
index dbc604864..e0cd65121 100644
--- a/src/main/org/apache/tools/ant/DefaultLogger.java
+++ b/src/main/org/apache/tools/ant/DefaultLogger.java
@@ -293,9 +293,7 @@ public class DefaultLogger implements BuildLogger {
// shouldn't be possible
message.append(label).append(event.getMessage());
} finally {
- if (r != null) {
- FileUtils.close(r);
- }
+ FileUtils.close(r);
}
} else {
diff --git a/src/main/org/apache/tools/ant/DemuxOutputStream.java b/src/main/org/apache/tools/ant/DemuxOutputStream.java
index bd3991321..e69c3a4e5 100644
--- a/src/main/org/apache/tools/ant/DemuxOutputStream.java
+++ b/src/main/org/apache/tools/ant/DemuxOutputStream.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.WeakHashMap;
+import org.apache.tools.ant.util.FileUtils;
/**
* Logs content written by a thread and forwards the buffers onto the
@@ -113,11 +114,7 @@ public class DemuxOutputStream extends OutputStream {
private void resetBufferInfo() {
Thread current = Thread.currentThread();
BufferInfo bufferInfo = (BufferInfo) buffers.get(current);
- try {
- bufferInfo.buffer.close();
- } catch (IOException e) {
- // Shouldn't happen
- }
+ FileUtils.close(bufferInfo.buffer);
bufferInfo.buffer = new ByteArrayOutputStream();
bufferInfo.crSeen = false;
}
diff --git a/src/main/org/apache/tools/ant/listener/AnsiColorLogger.java b/src/main/org/apache/tools/ant/listener/AnsiColorLogger.java
index 2e6950059..7519a7e8d 100644
--- a/src/main/org/apache/tools/ant/listener/AnsiColorLogger.java
+++ b/src/main/org/apache/tools/ant/listener/AnsiColorLogger.java
@@ -25,6 +25,7 @@ import java.util.Properties;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.util.FileUtils;
/**
* Uses ANSI Color Code Sequences to colorize messages
@@ -193,13 +194,7 @@ public class AnsiColorLogger extends DefaultLogger {
} catch (IOException ioe) {
//Ignore - we will use the defaults.
} finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- //Ignore - We do not want this to stop the build.
- }
- }
+ FileUtils.close(in);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java
index eba4731a5..793d16c98 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Ant.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java
@@ -456,11 +456,7 @@ public class Ant extends Task {
}
if (output != null && out != null) {
- try {
- out.close();
- } catch (final Exception ex) {
- //ignore
- }
+ FileUtils.close(out);
}
dir = savedDir;
antFile = savedAntFile;
diff --git a/src/main/org/apache/tools/ant/taskdefs/CVSPass.java b/src/main/org/apache/tools/ant/taskdefs/CVSPass.java
index 53f5d3e02..af24504b7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/CVSPass.java
+++ b/src/main/org/apache/tools/ant/taskdefs/CVSPass.java
@@ -123,13 +123,7 @@ public class CVSPass extends Task {
} catch (IOException e) {
throw new BuildException(e);
} finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- // ignore
- }
- }
+ FileUtils.close(reader);
FileUtils.close(writer);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
index 7637be74c..f3c16ced0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
@@ -1823,12 +1823,8 @@ public class Javadoc extends Task {
out.logFlush();
err.logFlush();
- try {
- out.close();
- err.close();
- } catch (final IOException e) {
- // ignore
- }
+ FileUtils.close(out);
+ FileUtils.close(err);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java
index 4aee3d0f2..ccfb35623 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Property.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Property.java
@@ -630,13 +630,7 @@ public class Property extends Task {
} catch (IOException ex) {
throw new BuildException(ex, getLocation());
} finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- // ignore
- }
- }
+ FileUtils.close(is);
if (cleanup && cL != null) {
((AntClassLoader) cL).cleanup();
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java b/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
index 42ba0f486..0f64544ac 100644
--- a/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
+++ b/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
@@ -22,6 +22,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import org.apache.tools.ant.util.FileUtils;
+
/**
* Copies standard output and error of subprocesses to standard output and
* error of the parent process.
@@ -119,11 +121,7 @@ public class PumpStreamHandler implements ExecuteStreamHandler {
if (input != null) {
inputThread = createPump(input, os, true, nonBlockingRead);
} else {
- try {
- os.close();
- } catch (IOException e) {
- //ignore
- }
+ FileUtils.close(os);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Redirector.java b/src/main/org/apache/tools/ant/taskdefs/Redirector.java
index 3b35d2313..5b99d34d3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Redirector.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Redirector.java
@@ -39,6 +39,7 @@ import org.apache.tools.ant.Task;
import org.apache.tools.ant.filters.util.ChainReaderHelper;
import org.apache.tools.ant.types.FilterChain;
import org.apache.tools.ant.util.ConcatFileInputStream;
+import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.KeepAliveOutputStream;
import org.apache.tools.ant.util.LazyFileOutputStream;
import org.apache.tools.ant.util.LeadPipeInputStream;
@@ -983,22 +984,10 @@ public class Redirector {
*/
public void setProperties() {
synchronized (outMutex) {
- if (baos != null) {
- try {
- baos.close();
- } catch (final IOException eyeOhEx) {
- // Ignore exception
- }
- }
+ FileUtils.close(baos);
}
synchronized (errMutex) {
- if (errorBaos != null) {
- try {
- errorBaos.close();
- } catch (final IOException eyeOhEx) {
- // Ignore exception
- }
- }
+ FileUtils.close(errorBaos);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
index b63ef933e..d8ef51a2f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
@@ -362,13 +362,7 @@ public class EchoProperties extends Task {
log(ioe.getMessage(), Project.MSG_INFO);
}
} finally {
- if (os != null) {
- try {
- os.close();
- } catch (IOException ex) {
- //ignore
- }
- }
+ FileUtils.close(os);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
index 069bdfcf9..43b923705 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
@@ -40,6 +40,7 @@ import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.depend.DependencyAnalyzer;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -353,13 +354,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
+ "-" + ioe.getMessage(), Project.MSG_WARN);
} finally {
// Close up the file input stream for the class file
- if (iStream != null) {
- try {
- iStream.close();
- } catch (IOException closeException) {
- // ignore
- }
- }
+ FileUtils.close(iStream);
}
}
@@ -535,13 +530,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
ejbFiles = handler.getFiles();
} finally {
- if (descriptorStream != null) {
- try {
- descriptorStream.close();
- } catch (IOException closeException) {
- // ignore
- }
- }
+ FileUtils.close(descriptorStream);
}
return ejbFiles;
@@ -858,13 +847,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
+ ioe.getMessage();
throw new BuildException(msg, ioe);
} finally {
- if (jarStream != null) {
- try {
- jarStream.close();
- } catch (IOException closeException) {
- // ignore
- }
- }
+ FileUtils.close(jarStream);
}
} // end of writeJar
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
index ed799d331..41e90d0f0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
@@ -42,6 +42,8 @@ import org.xml.sax.HandlerBase;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.apache.tools.ant.util.FileUtils;
+
/**
* Compiles EJB stubs and skeletons for the iPlanet Application
* Server (iAS). The class will read a standard EJB descriptor (as well as an
@@ -1483,11 +1485,7 @@ public class IPlanetEjbc {
} catch (IOException e) {
e.printStackTrace();
} finally {
- try {
- reader.close();
- } catch (IOException e) {
- // Do nothing
- }
+ FileUtils.close(reader);
}
}
} // End of RedirectOutput inner class
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 550f59ce0..7fae8b3a8 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
@@ -883,14 +883,9 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool {
}
}
+ FileUtils.close(newJarStream);
if (newJarStream != null) {
try {
- newJarStream.close();
- } catch (IOException closeException) {
- // empty
- }
-
- try {
FILE_UTILS.rename(newWLJarFile, weblogicJarFile);
} catch (IOException renameException) {
log(renameException.getMessage(), Project.MSG_WARN);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
index d15f9f523..7114610e4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
@@ -848,14 +848,9 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {
}
}
+ FileUtils.close(newJarStream);
if (newJarStream != null) {
try {
- newJarStream.close();
- } catch (IOException closeException) {
- // Ignore
- }
-
- try {
FILE_UTILS.rename(newwasJarFile, websphereJarFile);
} catch (IOException renameException) {
log(renameException.getMessage(), Project.MSG_WARN);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java
index 5afc57f17..401dcfb6a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java
@@ -29,6 +29,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.MagicNames;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.util.FileUtils;
/**
* Generates a manifest that declares all the dependencies.
@@ -219,13 +220,7 @@ public final class JarLibManifestTask extends Task {
manifest.write(output);
output.flush();
} finally {
- if (null != output) {
- try {
- output.close();
- } catch (IOException e) {
- // ignore
- }
- }
+ FileUtils.close(output);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
index 499cca277..a78872712 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
@@ -312,13 +312,7 @@ public class jlink {
} catch (IOException ioe) {
//do nothing
} finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- //do nothing
- }
- }
+ FileUtils.close(input);
}
}
System.out.println("From " + file.getPath() + " and prefix " + prefix
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java
index 0b09fa203..4eb30fbe6 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java
@@ -26,6 +26,7 @@ import junit.framework.AssertionFailedError;
import junit.framework.Test;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.util.FileUtils;
/**
* Prints short summary output of the test to Ant's logging system.
@@ -202,11 +203,7 @@ public class SummaryJUnitResultFormatter
writeOutputLine(sb.toString().getBytes());
} finally {
if (out != System.out && out != System.err) {
- try {
- out.close();
- } catch (IOException e) {
- // ignore
- }
+ FileUtils.close(out);
}
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
index a4f241301..81752b352 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
@@ -1564,13 +1564,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
transferred++;
}
} finally {
- if (instream != null) {
- try {
- instream.close();
- } catch (IOException ex) {
- // ignore it
- }
- }
+ FileUtils.close(instream);
}
}
@@ -1702,13 +1696,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
}
}
} finally {
- if (outstream != null) {
- try {
- outstream.close();
- } catch (IOException ex) {
- // ignore it
- }
- }
+ FileUtils.close(outstream);
}
}
diff --git a/src/main/org/apache/tools/ant/types/resources/TarResource.java b/src/main/org/apache/tools/ant/types/resources/TarResource.java
index 62f1f2670..b906a6527 100644
--- a/src/main/org/apache/tools/ant/types/resources/TarResource.java
+++ b/src/main/org/apache/tools/ant/types/resources/TarResource.java
@@ -171,9 +171,7 @@ public class TarResource extends ArchiveResource {
log(e.getMessage(), Project.MSG_DEBUG);
throw new BuildException(e);
} finally {
- if (i != null) {
- FileUtils.close(i);
- }
+ FileUtils.close(i);
}
setEntry(null);
}