DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37374>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37374





------- Additional Comments From [EMAIL PROTECTED]  2005-11-06 18:57 -------
Index:
D:/cygwin/home/fdutton/workspaces/tools/commons-vfs/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
===================================================================
---
D:/cygwin/home/fdutton/workspaces/tools/commons-vfs/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
(revision 331113)
+++
D:/cygwin/home/fdutton/workspaces/tools/commons-vfs/src/java/org/apache/commons/vfs/provider/AbstractFileProvider.java
(working copy)
@@ -15,6 +15,10 @@
  */
 package org.apache.commons.vfs.provider;
 
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystem;
@@ -23,10 +27,6 @@
 import org.apache.commons.vfs.FileSystemOptions;
 import org.apache.commons.vfs.provider.local.GenericFileNameParser;
 
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
 /**
  * A partial [EMAIL PROTECTED] FileProvider} implementation.  Takes care of 
managing the
  * file systems created by the provider.
@@ -60,18 +60,15 @@
      * FileSystem object.
      */
     // private final Map fileSystems = new HashMap();
-    private final Map fileSystems = new TreeMap();
+    private final Map fileSystems = Collections.synchronizedMap(new TreeMap());
 
     /**
      * Closes the file systems created by this provider.
      */
     public void close()
     {
-        synchronized (fileSystems)
-        {
-            fileSystems.clear();
-            super.close();
-        }
+        fileSystems.clear();
+        super.close();
     }
 
     /**
@@ -91,15 +88,12 @@
     protected void addFileSystem(final Comparable key, final FileSystem fs)
         throws FileSystemException
     {
-        synchronized (fileSystems)
-        {
-            // Add to the cache
-            addComponent(fs);
+        // Add to the cache
+        addComponent(fs);
 
-            FileSystemKey treeKey = new FileSystemKey(key,
fs.getFileSystemOptions());
-            ((AbstractFileSystem) fs).setCacheKey(treeKey);
-            fileSystems.put(treeKey, fs);
-        }
+        FileSystemKey treeKey = new FileSystemKey(key, 
fs.getFileSystemOptions());
+        ((AbstractFileSystem) fs).setCacheKey(treeKey);
+        fileSystems.put(treeKey, fs);
     }
 
     /**
@@ -109,12 +103,8 @@
      */
     protected FileSystem findFileSystem(final Comparable key, final
FileSystemOptions fileSystemProps)
     {
-        synchronized (fileSystems)
-        {
-            FileSystemKey treeKey = new FileSystemKey(key, fileSystemProps);
-
-            return (FileSystem) fileSystems.get(treeKey);
-        }
+        FileSystemKey treeKey = new FileSystemKey(key, fileSystemProps);
+        return (FileSystem) fileSystems.get(treeKey);
     }
 
     public FileSystemConfigBuilder getConfigBuilder()
@@ -124,30 +114,24 @@
 
     public void freeUnusedResources()
     {
-        synchronized (fileSystems)
+        Object[] item = fileSystems.values().toArray();
+        for (int i = 0; i < item.length; ++i)
         {
-            Iterator iterFileSystems = fileSystems.values().iterator();
-            while (iterFileSystems.hasNext())
+            AbstractFileSystem fs = (AbstractFileSystem) item[i];
+            if (fs.isReleaseable())
             {
-                AbstractFileSystem fs = (AbstractFileSystem)
iterFileSystems.next();
-                if (fs.isReleaseable())
-                {
-                    fs.closeCommunicationLink();
-                }
+                fs.closeCommunicationLink();
             }
         }
     }
 
     public void closeFileSystem(final FileSystem filesystem)
     {
-        synchronized (fileSystems)
-        {
-            AbstractFileSystem fs = (AbstractFileSystem) filesystem;
+        AbstractFileSystem fs = (AbstractFileSystem) filesystem;
 
-            fileSystems.remove(fs.getCacheKey());
-            removeComponent(fileSystems);
-            fs.close();
-        }
+        fileSystems.remove(fs.getCacheKey());
+        removeComponent(fs /*fileSystems*/);
+        fs.close();
     }
 
     /**


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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

Reply via email to