stevel      2002/09/10 15:21:18

  Modified:    src/main/org/apache/tools/ant Project.java
  Log:
  I'm always scared of changing the core classes, so would be more reluctant to 
commit this if it wasnt needed so much by Axis. Once committed. I'm going to do 
more soak testing.
  
  Purpose of fix: use weak references on Java1.2+ for the createdTasks list.
  We may want to think of cleaning this list up for extra leak prevention.
  
  Revision  Changes    Path
  1.116     +12 -6     jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.115
  retrieving revision 1.116
  diff -u -r1.115 -r1.116
  --- Project.java      10 Sep 2002 20:17:25 -0000      1.115
  +++ Project.java      10 Sep 2002 22:21:18 -0000      1.116
  @@ -69,6 +69,7 @@
   import org.apache.tools.ant.types.FilterSetCollection;
   import org.apache.tools.ant.util.FileUtils;
   import org.apache.tools.ant.util.JavaEnvUtils;
  +import org.apache.tools.ant.util.WeakishReference;
   
   /**
    * Central representation of an Ant project. This class defines an
  @@ -1172,7 +1173,7 @@
                   v = new Vector();
                   createdTasks.put(type, v);
               }
  -            v.addElement(task);
  +            v.addElement(WeakishReference.createReference(task));
           }
       }
   
  @@ -1189,8 +1190,13 @@
               if (v != null) {
                   Enumeration enum = v.elements();
                   while (enum.hasMoreElements()) {
  -                    Task t = (Task) enum.nextElement();
  -                    t.markInvalid();
  +                    WeakishReference ref=
  +                            (WeakishReference) enum.nextElement();
  +                    Task t = (Task) ref.get();
  +                    //being a weak ref, it may be null by this point
  +                    if(t!=null) {
  +                        t.markInvalid();
  +                    }
                   }
                   v.removeAllElements();
                   createdTasks.remove(type);
  @@ -1802,10 +1808,10 @@
                   valueAsString = value.toString();
               } catch (Throwable t) {
                   log("Caught exception (" + t.getClass().getName() +")"
  -                    + " while expanding " + name + ": " + t.getMessage(), 
  +                    + " while expanding " + name + ": " + t.getMessage(),
                       MSG_WARN);
               }
  -            log("Adding reference: " + name + " -> " + valueAsString, 
  +            log("Adding reference: " + name + " -> " + valueAsString,
                   MSG_DEBUG);
               references.put(name, value);
           }
  
  
  

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

Reply via email to