ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional EchoProperties.java
Date Tue, 28 May 2002 13:37:47 GMT
bodewig     02/05/28 06:37:47

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional Tag:
                        ANT_15_BRANCH EchoProperties.java
  Log:
  Move os.close call into execute
  
  Make it possible to deal with non-String properties (at some point we
  had them, but now that we hand out a clone in Project#getProperties
  this may have become impossible - play save).
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.8.2.1   +18 -14    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
  
  Index: EchoProperties.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- EchoProperties.java	15 Apr 2002 13:36:19 -0000	1.8
  +++ EchoProperties.java	28 May 2002 13:37:47 -0000	1.8.2.1
  @@ -105,8 +105,8 @@
   public class EchoProperties extends Task {
   
       /**
  -     *  File object pointing to the output file. If this is null, then we output
  -     *  to the project log, not to a file.
  +     *  File object pointing to the output file. If this is null, then
  +     *  we output to the project log, not to a file.
        */
       private File destfile = null;
   
  @@ -172,13 +172,14 @@
           //copy the properties file
           Hashtable allProps = project.getProperties();
   
  +        OutputStream os = null;
           try {
               if (destfile == null) {
  -                ByteArrayOutputStream baos = new ByteArrayOutputStream();
  -                saveProperties(allProps, baos);
  -                log(baos.toString(), Project.MSG_INFO);
  +                os = new ByteArrayOutputStream();
  +                saveProperties(allProps, os);
  +                log(os.toString(), Project.MSG_INFO);
               } else {
  -                OutputStream os = new FileOutputStream(this.destfile);
  +                os = new FileOutputStream(this.destfile);
                   saveProperties(allProps, os);
               }
           } catch (IOException ioe) {
  @@ -190,6 +191,13 @@
               } else {
                   log(message, Project.MSG_INFO);
               }
  +        } finally {
  +            if (os != null) {
  +                try {
  +                    os.close();                    
  +                } catch (IOException e) {
  +                }
  +            }
           }
       }
   
  @@ -209,17 +217,13 @@
           Properties props = new Properties();
           Enumeration enum = allProps.keys();
           while (enum.hasMoreElements()) {
  -            String name = (String) enum.nextElement();
  -                String value = (String) allProps.get(name);
  +            String name = enum.nextElement().toString();
  +            String value = allProps.get(name).toString();
               if (prefix == null || name.indexOf(prefix) == 0) {
                   props.put(name, value);
               }
           }
  -        try {
  -            jdkSaveProperties(props, os, "Ant properties");
  -        } finally {
  -            os.close();
  -        }
  +        jdkSaveProperties(props, os, "Ant properties");
       }
       
       
  @@ -275,7 +279,7 @@
        *@param header prepend this header to the property output
        */
       protected void jdk10SaveProperties(Properties props, OutputStream os,
  -            String header) {
  +                                       String header) {
           props.save(os, header);
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message