ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Filter.java SendEmail.java
Date Thu, 05 Oct 2000 07:48:38 GMT
bodewig     00/10/05 00:48:38

  Modified:    src/main/org/apache/tools/ant/taskdefs Filter.java
                        SendEmail.java
  Log:
  Make sure files are getting closed.
  Submitted by:	Nico Seessle <nico@seessle.de>
  
  Revision  Changes    Path
  1.6       +9 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Filter.java
  
  Index: Filter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Filter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Filter.java	2000/09/27 08:12:17	1.5
  +++ Filter.java	2000/10/05 07:48:37	1.6
  @@ -106,9 +106,11 @@
       
       protected void readFilters() throws BuildException {
           log("Reading filters from " + filtersFile, Project.MSG_VERBOSE);
  +        FileInputStream in = null;
           try {
               Properties props = new Properties();
  -            props.load(new FileInputStream(filtersFile));
  +            in = new FileInputStream(filtersFile);
  +            props.load(in);
   
               Project proj = getProject();
   
  @@ -120,6 +122,12 @@
               }
           } catch (Exception e) {
               throw new BuildException("Could not read filters from file: " + filtersFile);
  +        } finally {
  +            if (in != null) {
  +                try {
  +                    in.close();
  +                } catch (java.io.IOException ioex) {}
  +            }
           }
       }
   }
  
  
  
  1.2       +13 -6     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SendEmail.java
  
  Index: SendEmail.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SendEmail.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SendEmail.java	2000/08/30 14:15:45	1.1
  +++ SendEmail.java	2000/10/05 07:48:37	1.2
  @@ -216,11 +216,18 @@
                           int length;
                           byte[] buf = new byte[bufsize];
   
  -                        BufferedInputStream in = new BufferedInputStream(
  -                            new FileInputStream(file), bufsize);
  -
  -                        while ((length = in.read(buf, 0, bufsize)) != -1) {
  -                            out.write(buf, 0, length);
  +                        BufferedInputStream in = null;
  +                        try {
  +                            in = new BufferedInputStream(
  +                                new FileInputStream(file), bufsize);
  +    
  +                            while ((length = in.read(buf, 0, bufsize)) != -1) {
  +                                out.write(buf, 0, length);
  +                            }
  +                        } finally {
  +                            if (in != null) {
  +                                in.close();
  +                            }
                           }
   
                       } else {
  @@ -242,4 +249,4 @@
           }
       }
   
  -}
  \ No newline at end of file
  +}
  
  
  

Mime
View raw message