| @@ -27,6 +27,7 @@ import java.util.ArrayList; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.List; | import java.util.List; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.tools.ant.util.LoaderUtils; | import org.apache.tools.ant.util.LoaderUtils; | ||||
| /** | /** | ||||
| @@ -159,11 +160,7 @@ public class ArgumentProcessorRegistry { | |||||
| return getProcessor(processorClassName); | return getProcessor(processorClassName); | ||||
| } | } | ||||
| } finally { | } finally { | ||||
| try { | |||||
| isr.close(); | |||||
| } catch (IOException e) { | |||||
| // ignore | |||||
| } | |||||
| FileUtils.close(isr); | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -293,9 +293,7 @@ public class DefaultLogger implements BuildLogger { | |||||
| // shouldn't be possible | // shouldn't be possible | ||||
| message.append(label).append(event.getMessage()); | message.append(label).append(event.getMessage()); | ||||
| } finally { | } finally { | ||||
| if (r != null) { | |||||
| FileUtils.close(r); | |||||
| } | |||||
| FileUtils.close(r); | |||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -23,6 +23,7 @@ import java.io.IOException; | |||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.util.WeakHashMap; | import java.util.WeakHashMap; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * Logs content written by a thread and forwards the buffers onto the | * Logs content written by a thread and forwards the buffers onto the | ||||
| @@ -113,11 +114,7 @@ public class DemuxOutputStream extends OutputStream { | |||||
| private void resetBufferInfo() { | private void resetBufferInfo() { | ||||
| Thread current = Thread.currentThread(); | Thread current = Thread.currentThread(); | ||||
| BufferInfo bufferInfo = (BufferInfo) buffers.get(current); | 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.buffer = new ByteArrayOutputStream(); | ||||
| bufferInfo.crSeen = false; | bufferInfo.crSeen = false; | ||||
| } | } | ||||
| @@ -25,6 +25,7 @@ import java.util.Properties; | |||||
| import org.apache.tools.ant.DefaultLogger; | import org.apache.tools.ant.DefaultLogger; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * Uses ANSI Color Code Sequences to colorize messages | * Uses ANSI Color Code Sequences to colorize messages | ||||
| @@ -193,13 +194,7 @@ public class AnsiColorLogger extends DefaultLogger { | |||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| //Ignore - we will use the defaults. | //Ignore - we will use the defaults. | ||||
| } finally { | } finally { | ||||
| if (in != null) { | |||||
| try { | |||||
| in.close(); | |||||
| } catch (IOException e) { | |||||
| //Ignore - We do not want this to stop the build. | |||||
| } | |||||
| } | |||||
| FileUtils.close(in); | |||||
| } | } | ||||
| } | } | ||||
| @@ -456,11 +456,7 @@ public class Ant extends Task { | |||||
| } | } | ||||
| if (output != null && out != null) { | if (output != null && out != null) { | ||||
| try { | |||||
| out.close(); | |||||
| } catch (final Exception ex) { | |||||
| //ignore | |||||
| } | |||||
| FileUtils.close(out); | |||||
| } | } | ||||
| dir = savedDir; | dir = savedDir; | ||||
| antFile = savedAntFile; | antFile = savedAntFile; | ||||
| @@ -123,13 +123,7 @@ public class CVSPass extends Task { | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new BuildException(e); | throw new BuildException(e); | ||||
| } finally { | } finally { | ||||
| if (reader != null) { | |||||
| try { | |||||
| reader.close(); | |||||
| } catch (IOException e) { | |||||
| // ignore | |||||
| } | |||||
| } | |||||
| FileUtils.close(reader); | |||||
| FileUtils.close(writer); | FileUtils.close(writer); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1823,12 +1823,8 @@ public class Javadoc extends Task { | |||||
| out.logFlush(); | out.logFlush(); | ||||
| err.logFlush(); | err.logFlush(); | ||||
| try { | |||||
| out.close(); | |||||
| err.close(); | |||||
| } catch (final IOException e) { | |||||
| // ignore | |||||
| } | |||||
| FileUtils.close(out); | |||||
| FileUtils.close(err); | |||||
| } | } | ||||
| } | } | ||||
| @@ -625,13 +625,7 @@ public class Property extends Task { | |||||
| } catch (IOException ex) { | } catch (IOException ex) { | ||||
| throw new BuildException(ex, getLocation()); | throw new BuildException(ex, getLocation()); | ||||
| } finally { | } finally { | ||||
| if (is != null) { | |||||
| try { | |||||
| is.close(); | |||||
| } catch (IOException e) { | |||||
| // ignore | |||||
| } | |||||
| } | |||||
| FileUtils.close(is); | |||||
| if (cleanup && cL != null) { | if (cleanup && cL != null) { | ||||
| ((AntClassLoader) cL).cleanup(); | ((AntClassLoader) cL).cleanup(); | ||||
| } | } | ||||
| @@ -22,6 +22,8 @@ import java.io.IOException; | |||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * Copies standard output and error of subprocesses to standard output and | * Copies standard output and error of subprocesses to standard output and | ||||
| * error of the parent process. | * error of the parent process. | ||||
| @@ -119,11 +121,7 @@ public class PumpStreamHandler implements ExecuteStreamHandler { | |||||
| if (input != null) { | if (input != null) { | ||||
| inputThread = createPump(input, os, true, nonBlockingRead); | inputThread = createPump(input, os, true, nonBlockingRead); | ||||
| } else { | } else { | ||||
| try { | |||||
| os.close(); | |||||
| } catch (IOException e) { | |||||
| //ignore | |||||
| } | |||||
| FileUtils.close(os); | |||||
| } | } | ||||
| } | } | ||||
| @@ -39,6 +39,7 @@ import org.apache.tools.ant.Task; | |||||
| import org.apache.tools.ant.filters.util.ChainReaderHelper; | import org.apache.tools.ant.filters.util.ChainReaderHelper; | ||||
| import org.apache.tools.ant.types.FilterChain; | import org.apache.tools.ant.types.FilterChain; | ||||
| import org.apache.tools.ant.util.ConcatFileInputStream; | 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.KeepAliveOutputStream; | ||||
| import org.apache.tools.ant.util.LazyFileOutputStream; | import org.apache.tools.ant.util.LazyFileOutputStream; | ||||
| import org.apache.tools.ant.util.LeadPipeInputStream; | import org.apache.tools.ant.util.LeadPipeInputStream; | ||||
| @@ -983,22 +984,10 @@ public class Redirector { | |||||
| */ | */ | ||||
| public void setProperties() { | public void setProperties() { | ||||
| synchronized (outMutex) { | synchronized (outMutex) { | ||||
| if (baos != null) { | |||||
| try { | |||||
| baos.close(); | |||||
| } catch (final IOException eyeOhEx) { | |||||
| // Ignore exception | |||||
| } | |||||
| } | |||||
| FileUtils.close(baos); | |||||
| } | } | ||||
| synchronized (errMutex) { | synchronized (errMutex) { | ||||
| if (errorBaos != null) { | |||||
| try { | |||||
| errorBaos.close(); | |||||
| } catch (final IOException eyeOhEx) { | |||||
| // Ignore exception | |||||
| } | |||||
| } | |||||
| FileUtils.close(errorBaos); | |||||
| } | } | ||||
| } | } | ||||
| @@ -362,13 +362,7 @@ public class EchoProperties extends Task { | |||||
| log(ioe.getMessage(), Project.MSG_INFO); | log(ioe.getMessage(), Project.MSG_INFO); | ||||
| } | } | ||||
| } finally { | } finally { | ||||
| if (os != null) { | |||||
| try { | |||||
| os.close(); | |||||
| } catch (IOException ex) { | |||||
| //ignore | |||||
| } | |||||
| } | |||||
| FileUtils.close(os); | |||||
| } | } | ||||
| } | } | ||||
| @@ -40,6 +40,7 @@ import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.tools.ant.util.depend.DependencyAnalyzer; | import org.apache.tools.ant.util.depend.DependencyAnalyzer; | ||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| import org.xml.sax.SAXException; | import org.xml.sax.SAXException; | ||||
| @@ -353,13 +354,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
| + "-" + ioe.getMessage(), Project.MSG_WARN); | + "-" + ioe.getMessage(), Project.MSG_WARN); | ||||
| } finally { | } finally { | ||||
| // Close up the file input stream for the class file | // 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(); | ejbFiles = handler.getFiles(); | ||||
| } finally { | } finally { | ||||
| if (descriptorStream != null) { | |||||
| try { | |||||
| descriptorStream.close(); | |||||
| } catch (IOException closeException) { | |||||
| // ignore | |||||
| } | |||||
| } | |||||
| FileUtils.close(descriptorStream); | |||||
| } | } | ||||
| return ejbFiles; | return ejbFiles; | ||||
| @@ -858,13 +847,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
| + ioe.getMessage(); | + ioe.getMessage(); | ||||
| throw new BuildException(msg, ioe); | throw new BuildException(msg, ioe); | ||||
| } finally { | } finally { | ||||
| if (jarStream != null) { | |||||
| try { | |||||
| jarStream.close(); | |||||
| } catch (IOException closeException) { | |||||
| // ignore | |||||
| } | |||||
| } | |||||
| FileUtils.close(jarStream); | |||||
| } | } | ||||
| } // end of writeJar | } // end of writeJar | ||||
| @@ -42,6 +42,8 @@ import org.xml.sax.HandlerBase; | |||||
| import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
| import org.xml.sax.SAXException; | import org.xml.sax.SAXException; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * Compiles EJB stubs and skeletons for the iPlanet Application | * Compiles EJB stubs and skeletons for the iPlanet Application | ||||
| * Server (iAS). The class will read a standard EJB descriptor (as well as an | * Server (iAS). The class will read a standard EJB descriptor (as well as an | ||||
| @@ -1483,11 +1485,7 @@ public class IPlanetEjbc { | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } finally { | } finally { | ||||
| try { | |||||
| reader.close(); | |||||
| } catch (IOException e) { | |||||
| // Do nothing | |||||
| } | |||||
| FileUtils.close(reader); | |||||
| } | } | ||||
| } | } | ||||
| } // End of RedirectOutput inner class | } // End of RedirectOutput inner class | ||||
| @@ -29,6 +29,7 @@ import org.apache.tools.ant.BuildException; | |||||
| import org.apache.tools.ant.MagicNames; | import org.apache.tools.ant.MagicNames; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * Generates a manifest that declares all the dependencies. | * Generates a manifest that declares all the dependencies. | ||||
| @@ -219,13 +220,7 @@ public final class JarLibManifestTask extends Task { | |||||
| manifest.write(output); | manifest.write(output); | ||||
| output.flush(); | output.flush(); | ||||
| } finally { | } finally { | ||||
| if (null != output) { | |||||
| try { | |||||
| output.close(); | |||||
| } catch (IOException e) { | |||||
| // ignore | |||||
| } | |||||
| } | |||||
| FileUtils.close(output); | |||||
| } | } | ||||
| } | } | ||||
| @@ -312,13 +312,7 @@ public class jlink { | |||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| //do nothing | //do nothing | ||||
| } finally { | } finally { | ||||
| if (input != null) { | |||||
| try { | |||||
| input.close(); | |||||
| } catch (IOException e) { | |||||
| //do nothing | |||||
| } | |||||
| } | |||||
| FileUtils.close(input); | |||||
| } | } | ||||
| } | } | ||||
| System.out.println("From " + file.getPath() + " and prefix " + prefix | System.out.println("From " + file.getPath() + " and prefix " + prefix | ||||
| @@ -26,6 +26,7 @@ import junit.framework.AssertionFailedError; | |||||
| import junit.framework.Test; | import junit.framework.Test; | ||||
| import org.apache.tools.ant.BuildException; | 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. | * Prints short summary output of the test to Ant's logging system. | ||||
| @@ -202,11 +203,7 @@ public class SummaryJUnitResultFormatter | |||||
| writeOutputLine(sb.toString().getBytes()); | writeOutputLine(sb.toString().getBytes()); | ||||
| } finally { | } finally { | ||||
| if (out != System.out && out != System.err) { | if (out != System.out && out != System.err) { | ||||
| try { | |||||
| out.close(); | |||||
| } catch (IOException e) { | |||||
| // ignore | |||||
| } | |||||
| FileUtils.close(out); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1564,13 +1564,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||||
| transferred++; | transferred++; | ||||
| } | } | ||||
| } finally { | } 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 { | } finally { | ||||
| if (outstream != null) { | |||||
| try { | |||||
| outstream.close(); | |||||
| } catch (IOException ex) { | |||||
| // ignore it | |||||
| } | |||||
| } | |||||
| FileUtils.close(outstream); | |||||
| } | } | ||||
| } | } | ||||
| @@ -171,9 +171,7 @@ public class TarResource extends ArchiveResource { | |||||
| log(e.getMessage(), Project.MSG_DEBUG); | log(e.getMessage(), Project.MSG_DEBUG); | ||||
| throw new BuildException(e); | throw new BuildException(e); | ||||
| } finally { | } finally { | ||||
| if (i != null) { | |||||
| FileUtils.close(i); | |||||
| } | |||||
| FileUtils.close(i); | |||||
| } | } | ||||
| setEntry(null); | setEntry(null); | ||||
| } | } | ||||
| @@ -201,7 +201,6 @@ public class DefaultCompilerAdapterTest { | |||||
| javac.setProject(prj); | javac.setProject(prj); | ||||
| final Commandline[] cmd = new Commandline[1]; | final Commandline[] cmd = new Commandline[1]; | ||||
| final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() { | final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() { | ||||
| @Override | |||||
| public boolean execute() throws BuildException { | public boolean execute() throws BuildException { | ||||
| cmd[0] = setupModernJavacCommand(); | cmd[0] = setupModernJavacCommand(); | ||||
| return true; | return true; | ||||
| @@ -258,7 +257,6 @@ public class DefaultCompilerAdapterTest { | |||||
| javac.setProject(prj); | javac.setProject(prj); | ||||
| final Commandline[] cmd = new Commandline[1]; | final Commandline[] cmd = new Commandline[1]; | ||||
| final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() { | final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() { | ||||
| @Override | |||||
| public boolean execute() throws BuildException { | public boolean execute() throws BuildException { | ||||
| cmd[0] = setupModernJavacCommand(); | cmd[0] = setupModernJavacCommand(); | ||||
| return true; | return true; | ||||
| @@ -322,7 +320,6 @@ public class DefaultCompilerAdapterTest { | |||||
| final LogCapturingJavac javac = new LogCapturingJavac(); | final LogCapturingJavac javac = new LogCapturingJavac(); | ||||
| javac.setProject(prj); | javac.setProject(prj); | ||||
| final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() { | final DefaultCompilerAdapter impl = new DefaultCompilerAdapter() { | ||||
| @Override | |||||
| public boolean execute() throws BuildException { | public boolean execute() throws BuildException { | ||||
| setupModernJavacCommand(); | setupModernJavacCommand(); | ||||
| return true; | return true; | ||||