[jboss-cvs] JBossCache/src/org/jboss/cache/loader ...

Brian Stansberry brian.stansberry at jboss.com
Mon Nov 20 14:52:57 EST 2006


  User: bstansberry
  Date: 06/11/20 14:52:57

  Modified:    src/org/jboss/cache/loader  FileCacheLoader.java
  Log:
  Minor optimizations; comments
  
  Revision  Changes    Path
  1.25      +10 -12    JBossCache/src/org/jboss/cache/loader/FileCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FileCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/FileCacheLoader.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -b -r1.24 -r1.25
  --- FileCacheLoader.java	18 Nov 2006 09:02:24 -0000	1.24
  +++ FileCacheLoader.java	20 Nov 2006 19:52:57 -0000	1.25
  @@ -25,11 +25,12 @@
    * Simple file-based CacheLoader implementation. Nodes are directories, attributes of a node is a file in the directory
    *
    * @author Bela Ban
  - * @version $Id: FileCacheLoader.java,v 1.24 2006/11/18 09:02:24 bstansberry Exp $
  + * @version $Id: FileCacheLoader.java,v 1.25 2006/11/20 19:52:57 bstansberry Exp $
    */
   public class FileCacheLoader extends AbstractCacheLoader
   {
      File root = null;
  +   String rootPath = null;
      Log log = LogFactory.getLog(getClass());
   
      private FileCacheLoaderConfig config;
  @@ -69,6 +70,7 @@
         if (location != null && location.length() > 0)
         {
            root = new File(location);
  +         rootPath = root.getAbsolutePath() + File.separator;
         }
      }
      
  @@ -83,6 +85,7 @@
         {
            String tmpLocation = System.getProperty("java.io.tmpdir", "C:\\tmp");
            root = new File(tmpLocation);
  +         rootPath = root.getAbsolutePath() + File.separator;
         }
         if (!root.exists())
         {
  @@ -322,19 +325,12 @@
   
      String getFullPath(Fqn fqn)
      {
  -      StringBuffer sb = new StringBuffer(root.getAbsolutePath() + File.separator);
  +      StringBuffer sb = new StringBuffer(rootPath);
         for (int i = 0; i < fqn.size(); i++)
         {
            Object tmp = fqn.get(i);
  -         String tmp_dir;
  -         if (tmp instanceof String)
  -         {
  -            tmp_dir = (String) tmp;
  -         }
  -         else
  -         {
  -            tmp_dir = tmp.toString();
  -         }
  +         // This is where we convert from Object to String!
  +         String tmp_dir = tmp.toString(); // returns tmp.this if it's a String         
            sb.append(tmp_dir).append(".").append(DIR_SUFFIX).append(File.separator);
         }
         return sb.toString();
  @@ -398,13 +394,15 @@
         Pattern fqnPattern = Pattern.compile("[\\\\\\/:*<>|\"?]");
   
         List elements = fqn.peekElements();
  +      // Don't assume the Fqn is composed of Strings!!
         for (Object anElement : elements)
         {
  +         // getFullPath converts Object to String via toString(), so we do too
            Matcher matcher = fqnPattern.matcher(anElement.toString());
            if (matcher.find())
            {
               log.warn("One of the Fqn ( " + fqn + " ) elements contains one of these characters: '*' '<' '>' '|' '\"' '?' '\\' '/' ':' ");
  -            log.warn("Directories containing these characters are illegal in some operative systems and could lead to portability issues");
  +            log.warn("Directories containing these characters are illegal in some operating systems and could lead to portability issues");
               return false;
            }
         }
  
  
  



More information about the jboss-cvs-commits mailing list