ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional PropertyFile.java
Date Wed, 25 Oct 2000 12:05:15 GMT
conor       00/10/25 05:05:07

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional
                        PropertyFile.java
  Log:
  Make sure files get closed even when there is an exception.
  
  Revision  Changes    Path
  1.2       +9 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
  
  Index: PropertyFile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PropertyFile.java	2000/10/25 11:59:52	1.1
  +++ PropertyFile.java	2000/10/25 12:05:06	1.2
  @@ -245,10 +245,10 @@
       */
       private void writeFile() throws BuildException 
       {
  +        BufferedOutputStream bos = null;
           try 
           {
  -            BufferedOutputStream bos = new BufferedOutputStream(
  -                                         new FileOutputStream(m_propertyfile));
  +            bos = new BufferedOutputStream(new FileOutputStream(m_propertyfile));
   
               // Write the message if we have one.
               if (m_comment != null) 
  @@ -275,11 +275,17 @@
                   bos.write(NEWLINE.getBytes());
                   bos.flush();
               }
  -            bos.close();
           }
           catch (IOException ioe) 
           {
               throw new BuildException(ioe.toString());
  +        }
  +        finally {
  +            if (bos != null) {
  +                try {
  +                    bos.close();
  +                } catch (IOException ioex) {}
  +            }
           }
       }
   
  
  
  

Mime
View raw message