bodewig     2003/10/14 05:49:19

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs LoadProperties.java
  Log:
  Reuse the resolution logic of <property> inside <loadproperties>.
  
  PR: 17782
  Submitted by: Peter Reilly
  
  Revision  Changes    Path
  1.508     +7 -2      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.507
  retrieving revision 1.508
  diff -u -r1.507 -r1.508
  --- WHATSNEW  3 Oct 2003 22:37:32 -0000       1.507
  +++ WHATSNEW  14 Oct 2003 12:49:18 -0000      1.508
  @@ -14,8 +14,8 @@
   * Translate task logs a debug message specifying the number of files
     that it processed.  Bugzilla Report 13938.
   
  -Changes from Ant 1.5.4 to Ant 1.6Beta1
  -======================================
  +Changes from Ant 1.5.4 to Ant 1.6
  +=================================
   
   Changes that could break older environments:
   --------------------------------------------
  @@ -78,6 +78,11 @@
     String[]. (In java 1.5 terms it was Hashtable<String, String> and
     is now Hashtable<String, String[]>). This will affect third party code
     that extend Copy and override Copy#doFileOperations.
  +
  +* <loadproperties> didn't expand properties while <property file="..."/>
  +  does, so they were not equivalent.  This has been fixed, which means
  +  that propetries may get expanded twice if you use an
  +  <expandproperties> filterreader.  Bugzilla Report 17782.
   
   Fixed bugs:
   -----------
  
  
  
  1.20      +13 -11    
ant/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
  
  Index: LoadProperties.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- LoadProperties.java       25 Sep 2003 07:44:13 -0000      1.19
  +++ LoadProperties.java       14 Oct 2003 12:49:19 -0000      1.20
  @@ -140,6 +140,7 @@
           FileInputStream fis = null;
           BufferedInputStream bis = null;
           Reader instream = null;
  +        ByteArrayInputStream tis = null;
   
           try {
               final long len = srcFile.length();
  @@ -166,7 +167,6 @@
                       text = text + "\n";
                   }
   
  -                ByteArrayInputStream tis = null;
                   if (encoding == null) {
                       tis = new ByteArrayInputStream(text.getBytes());
                   } else {
  @@ -174,16 +174,11 @@
                   }
                   final Properties props = new Properties();
                   props.load(tis);
  -                final Enumeration e = props.keys();
  -                while (e.hasMoreElements()) {
  -                    final String key = (String) e.nextElement();
  -                    final String value = props.getProperty(key);
  -                    if (key != null && value != null
  -                            && value.trim().length() > 0) {
  -                        getProject().setNewProperty(key, value);
  -                    }
  -                }
  -                tis.close();
  +
  +                Property propertyTask = 
  +                    (Property) getProject().createTask("property");
  +                propertyTask.setTaskName(getTaskName());
  +                propertyTask.addProperties(props);
               }
   
           } catch (final IOException ioe) {
  @@ -195,6 +190,13 @@
               try {
                   if (fis != null) {
                       fis.close();
  +                }
  +            } catch (IOException ioex) {
  +                //ignore
  +            }
  +            try {
  +                if (tis != null) {
  +                    tis.close();
                   }
               } catch (IOException ioex) {
                   //ignore
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to