ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Ant.java RecorderEntry.java
Date Wed, 23 Jun 2004 14:08:26 GMT
bodewig     2004/06/23 07:08:26

  Modified:    src/main/org/apache/tools/ant/taskdefs Ant.java
                        RecorderEntry.java
  Log:
  Preliminary fix for 8689
  
  Revision  Changes    Path
  1.101     +26 -4     ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -r1.100 -r1.101
  --- Ant.java	8 Apr 2004 14:58:19 -0000	1.100
  +++ Ant.java	23 Jun 2004 14:08:26 -0000	1.101
  @@ -24,9 +24,11 @@
   import java.lang.reflect.Method;
   import java.util.Enumeration;
   import java.util.Hashtable;
  +import java.util.Iterator;
   import java.util.Vector;
   import java.util.Set;
   import java.util.HashSet;
  +import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.BuildListener;
   import org.apache.tools.ant.DefaultLogger;
  @@ -147,10 +149,9 @@
       private void initializeProject() {
           newProject.setInputHandler(getProject().getInputHandler());
   
  -        Vector listeners = getProject().getBuildListeners();
  -        final int count = listeners.size();
  -        for (int i = 0; i < count; i++) {
  -            newProject.addBuildListener((BuildListener) listeners.elementAt(i));
  +        Iterator iter = getBuildListeners();
  +        while (iter.hasNext()) {
  +            newProject.addBuildListener((BuildListener) iter.next());
           }
   
           if (output != null) {
  @@ -390,6 +391,20 @@
               }
           } finally {
               // help the gc
  +            Iterator iter = getBuildListeners();
  +            while (iter.hasNext()) {
  +                newProject.removeBuildListener((BuildListener) iter.next());
  +            }
  +            iter = newProject.getBuildListeners().iterator();
  +            while (iter.hasNext()) {
  +                Object o = iter.next();
  +                if (o instanceof RecorderEntry) {
  +                    ((RecorderEntry) o).close();
  +                } else if (o instanceof AntClassLoader) {
  +                    ((AntClassLoader) o).cleanup();
  +                }
  +            }
  +            
               newProject = null;
               Enumeration e = properties.elements();
               while (e.hasMoreElements()) {
  @@ -644,6 +659,13 @@
        */
       public void addPropertyset(PropertySet ps) {
           propertySets.addElement(ps);
  +    }
  +
  +    /**
  +     * @since Ant 1.6.2
  +     */
  +    private Iterator getBuildListeners() {
  +        return getProject().getBuildListeners().iterator();
       }
   
       /**
  
  
  
  1.17      +9 -2      ant/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java
  
  Index: RecorderEntry.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/RecorderEntry.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- RecorderEntry.java	9 Mar 2004 16:48:06 -0000	1.16
  +++ RecorderEntry.java	23 Jun 2004 14:08:26 -0000	1.17
  @@ -99,8 +99,7 @@
                    + StringUtils.LINE_SEP);
               error.printStackTrace(out);
           }
  -        out.flush();
  -        out.close();
  +        close();
       }
   
   
  @@ -207,6 +206,14 @@
                    + (seconds % 60 == 1 ? "" : "s");
           }
   
  +    }
  +
  +    /**
  +     * @since 1.6.2
  +     */
  +    public void close() {
  +        out.flush();
  +        out.close();
       }
   }
   
  
  
  

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


Mime
View raw message