ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Definer.java
Date Fri, 28 May 2004 08:21:04 GMT
peterreilly    2004/05/28 01:21:04

  Modified:    src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH
                        Definer.java
  Log:
  sync
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.44.2.8  +26 -1     ant/src/main/org/apache/tools/ant/taskdefs/Definer.java
  
  Index: Definer.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Definer.java,v
  retrieving revision 1.44.2.7
  retrieving revision 1.44.2.8
  diff -u -r1.44.2.7 -r1.44.2.8
  --- Definer.java	15 Mar 2004 18:03:56 -0000	1.44.2.7
  +++ Definer.java	28 May 2004 08:21:04 -0000	1.44.2.8
  @@ -21,7 +21,9 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.net.URL;
  +import java.util.ArrayList;
   import java.util.Enumeration;
  +import java.util.List;
   import java.util.Locale;
   import java.util.NoSuchElementException;
   import java.util.Properties;
  @@ -41,6 +43,15 @@
    * @since Ant 1.4
    */
   public abstract class Definer extends DefBase {
  +    private static class ResourceStack extends ThreadLocal {
  +        public Object initialValue() {
  +            return new ArrayList();
  +        }
  +        List getStack() {
  +            return (List) get();
  +        }
  +    }
  +    private static ResourceStack resourceStack = new ResourceStack();
       private String name;
       private String classname;
       private File file;
  @@ -179,6 +190,9 @@
               Enumeration/*<URL>*/ urls = null;
               if (file != null) {
                   final URL url = fileToURL();
  +                if (url == null) {
  +                    return;
  +                }
                   urls = new Enumeration() {
                       private boolean more = true;
                       public boolean hasMoreElements() {
  @@ -209,7 +223,18 @@
                       loadProperties(al, url);
                       break;
                   } else {
  -                    loadAntlib(al, url);
  +                    if (resourceStack.getStack().contains(url)) {
  +                        log("Warning: Attempting to recursively load " + url
  +                            + " at " + getLocation(),
  +                            Project.MSG_WARN);
  +                    } else {
  +                        try {
  +                            resourceStack.getStack().add(url);
  +                            loadAntlib(al, url);
  +                        } finally {
  +                            resourceStack.getStack().remove(url);
  +                        }
  +                    }
                   }
               }
           }
  
  
  

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


Mime
View raw message