You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by pl...@apache.org on 2003/04/24 21:28:54 UTC

cvs commit: maven/src/java/org/apache/maven/plugin PluginCacheManager.java

plynch      2003/04/24 12:28:54

  Modified:    src/java/org/apache/maven/plugin PluginCacheManager.java
  Log:
  o resolve issue  MAVEN-418 indexOf() != equals()
    A namespace URI that was part of the string of another namespace uri was treated as equal to that larger uri string.
  o added some debug logging
  
  Revision  Changes    Path
  1.10      +50 -22    maven/src/java/org/apache/maven/plugin/PluginCacheManager.java
  
  Index: PluginCacheManager.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/plugin/PluginCacheManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PluginCacheManager.java	26 Jan 2003 00:00:40 -0000	1.9
  +++ PluginCacheManager.java	24 Apr 2003 19:28:54 -0000	1.10
  @@ -62,11 +62,14 @@
   import java.util.Set;
   import java.util.HashSet;
   import java.util.Properties;
  +import java.util.StringTokenizer;
   
   import javax.xml.parsers.SAXParser;
   import javax.xml.parsers.SAXParserFactory;
   
   import org.apache.commons.lang.StringUtils;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   import org.xml.sax.Attributes;
   import org.xml.sax.InputSource;
  @@ -78,6 +81,10 @@
   public class PluginCacheManager
       extends DefaultHandler
   {
  +    /** Log. */
  +    private static final Log log =
  +        LogFactory.getLog( PluginCacheManager.class );
  +
       /** Plug-in cache */
       public static final String PLUGINS_CACHE = "plugins.cache";
   
  @@ -454,25 +461,33 @@
               && uri.equals( "" ) == false )
           {
               dynaTagLibDecls.add( uri );
  +            String commaSeperatedList = pluginDynaTagDepsCache.getProperty( pluginName );
   
  -            String p = pluginDynaTagDepsCache.getProperty( pluginName );
  -
  -
  -            if ( p != null )
  +            if ( commaSeperatedList != null )
               {
  -                // Prevent duplicate uri entries from being added.
  -                if ( p.indexOf( uri ) >= 0 )
  +                // Prevent duplicate uri entries from being added
  +                // iterate over the comma seperated list and check each one
  +                // independently
  +                StringTokenizer tokens =
  +                    new StringTokenizer(commaSeperatedList, ",");
  +                while ( tokens.hasMoreTokens() )
                   {
  -                    return;
  +                    if ( tokens.nextToken().equals(uri) )
  +                    {
  +                        return;
  +                    }
                   }
  -
  -                p += "," + uri;
  +                commaSeperatedList += ',' + uri;
               }
               else
               {
  -                p = uri;
  +                commaSeperatedList = uri;
  +            }
  +            if ( log.isDebugEnabled() )
  +            {
  +                log.debug("Caching Taglib Uri --> " + uri);
               }
  -            pluginDynaTagDepsCache.setProperty( pluginName, p );
  +            pluginDynaTagDepsCache.setProperty( pluginName, commaSeperatedList );
           }
       }
   
  @@ -544,16 +559,18 @@
               && uri.equals( "jelly:define" ) )
           {
               String tagLibUri = attributes.getValue( "uri" );
  -            dynaTagLibCache.setProperty( tagLibUri, pluginScriptDirectory );
   
  -            // We don't need to set a dependency if the dyna tag lib is in
  -            // the same jelly script where it's used.
  +            if ( log.isDebugEnabled() )
  +            {
  +                log.debug("Caching Taglib Uri --> " + tagLibUri);
  +            }
  +
  +            dynaTagLibCache.setProperty( tagLibUri, pluginScriptDirectory );
               if ( dynaTagLibDecls.contains( tagLibUri ) )
               {
                   String prop = (String) pluginDynaTagDepsCache.get( pluginName );
                   int tl = tagLibUri.length();
   
  -                // If there is only one dependency then just remove the whole entry.
                   if ( prop.indexOf( "," ) < 0 )
                   {
                       pluginDynaTagDepsCache.remove( pluginName );
  @@ -576,6 +593,10 @@
                           // The last entry
                           prop = prop.substring( 0, prop.length() - tl - 1 );
                       }
  +                    if ( log.isDebugEnabled() )
  +                    {
  +                        log.debug("Caching Taglib Dependency --> " + prop);
  +                    }
                       pluginDynaTagDepsCache.put( pluginName, prop );
                   }
               }
  @@ -600,12 +621,19 @@
           {
               return newEntry;
           }
  -        else if ( csvProperty.indexOf( newEntry ) < 0 )
  +        else
           {
  -            csvProperty += "," + newEntry;
  +            StringTokenizer st = new StringTokenizer(csvProperty, ",");
  +            while ( st.hasMoreTokens() )
  +            {
  +                if ( st.nextToken().equals(newEntry) )
  +                {
  +                    return csvProperty;
  +                }
  +            }
           }
  -
  -        return csvProperty;
  +        // not already there so append and return
  +        return csvProperty += ',' + newEntry;
       }
   
   
  @@ -640,12 +668,12 @@
       }
   
       /**
  -     * Description of the Method
  +     * Print parse error to Sytem.err
        */
       private final void printParseError( String type, SAXParseException spe )
       {
           System.err.println( type + " [line " + spe.getLineNumber() +
  -                            ", row " + spe.getColumnNumber() + "]: " +
  -                            spe.getMessage() );
  +                   ", row " + spe.getColumnNumber() + "]: " +
  +                   spe.getMessage() );
       }
   }
  
  
  

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