commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1029807 - in /commons/proper/vfs/trunk: core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java src/changes/changes.xml
Date Mon, 01 Nov 2010 19:46:54 GMT
Author: rgoers
Date: Mon Nov  1 19:46:54 2010
New Revision: 1029807

URL: http://svn.apache.org/viewvc?rev=1029807&view=rev
Log:
Apply fix for VFS-324. Clear cache in RamFileSystem and RamFileData

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java
    commons/proper/vfs/trunk/src/changes/changes.xml

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java?rev=1029807&r1=1029806&r2=1029807&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileData.java
Mon Nov  1 19:46:54 2010
@@ -63,6 +63,7 @@ class RamFileData implements Serializabl
     public RamFileData(FileName name)
     {
         super();
+        this.children = Collections.synchronizedCollection(new ArrayList());
         this.clear();
         if (name == null)
         {
@@ -130,7 +131,7 @@ class RamFileData implements Serializabl
         this.buffer = new byte[0];
         updateLastModified();
         this.type = FileType.IMAGINARY;
-        this.children = Collections.synchronizedCollection(new ArrayList());
+        this.children.clear();
         this.name = null;
     }
 

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java?rev=1029807&r1=1029806&r2=1029807&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java
(original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/ram/RamFileSystem.java
Mon Nov  1 19:46:54 2010
@@ -44,7 +44,7 @@ public class RamFileSystem extends Abstr
     /**
      * Cache of RAM File Data
      */
-    private Map cache;
+    private final Map cache;
 
     /**
      * @param rootName The root file name.
@@ -95,16 +95,19 @@ public class RamFileSystem extends Abstr
             return null;
         }
         Collection children = data.getChildren();
+        String[] names;
 
-        String[] names = new String[children.size()];
+        synchronized(children) {
+            names = new String[children.size()];
 
-        int pos = 0;
-        Iterator iter = children.iterator();
-        while (iter.hasNext())
-        {
-            RamFileData childData = (RamFileData) iter.next();
-            names[pos] = childData.getName().getBaseName();
-            pos++;
+            int pos = 0;
+            Iterator iter = children.iterator();
+            while (iter.hasNext())
+            {
+                RamFileData childData = (RamFileData) iter.next();
+                names[pos] = childData.getName().getBaseName();
+                pos++;
+            }
         }
 
         return names;
@@ -293,11 +296,13 @@ public class RamFileSystem extends Abstr
     int size()
     {
         int size = 0;
-        Iterator iter = cache.values().iterator();
-        while (iter.hasNext())
-        {
-            RamFileData data = (RamFileData) iter.next();
-            size += data.size();
+        synchronized(cache) {
+            Iterator iter = cache.values().iterator();
+            while (iter.hasNext())
+            {
+                RamFileData data = (RamFileData) iter.next();
+                size += data.size();
+            }
         }
         return size;
     }
@@ -307,7 +312,7 @@ public class RamFileSystem extends Abstr
      */
     public void close()
     {
-        this.cache = null;
+        this.cache.clear();
         super.close();
     }
 }

Modified: commons/proper/vfs/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1029807&r1=1029806&r2=1029807&view=diff
==============================================================================
--- commons/proper/vfs/trunk/src/changes/changes.xml (original)
+++ commons/proper/vfs/trunk/src/changes/changes.xml Mon Nov  1 19:46:54 2010
@@ -23,6 +23,9 @@
 
   <body>
     <release version="2.0" date="in SVN" description="">
+       <action dev="rgoers" type="fix" issue="VFS-324" due-to="sebb">
+        Clear the cache in RamFileSystem and the children in RamFileData.
+      </action>
       <action dev="sebb" type="fix" issue="VFS-319" due-to="sebb">
         Typo in FtpsFileSystemConfigBuilder.setFtpsType
       </action>



Mime
View raw message