portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r391372 - /portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java
Date Tue, 04 Apr 2006 17:27:40 GMT
Author: taylor
Date: Tue Apr  4 10:27:38 2006
New Revision: 391372

URL: http://svn.apache.org/viewcvs?rev=391372&view=rev
Log:
concurrent mod fix

Modified:
    portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java

Modified: portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java?rev=391372&r1=391371&r2=391372&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java
(original)
+++ portals/jetspeed-2/trunk/components/file-cache/src/java/org/apache/jetspeed/cache/file/FileCache.java
Tue Apr  4 10:27:38 2006
@@ -16,6 +16,7 @@
 
 package org.apache.jetspeed.cache.file;
 
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Map;
@@ -396,29 +397,33 @@
                     try
                     {
                         int count = 0;
-                        for (Iterator it = FileCache.this.cache.values().iterator(); it.hasNext();
)
+                        Collection values = Collections.synchronizedCollection(FileCache.this.cache.values());
+                        synchronized (values)
                         {
-                            FileCacheEntry entry = (FileCacheEntry) it.next();
-                            Date modified = new Date(entry.getFile().lastModified());
-    
-                            if (modified.after(entry.getLastModified()))
-                            {                            
-                                for (Iterator lit = FileCache.this.listeners.iterator();
lit.hasNext(); )
-                                {
-                                    FileCacheEventListener listener = 
-                                        (FileCacheEventListener) lit.next();
-                                    try
+                            for (Iterator it = values.iterator(); it.hasNext(); )
+                            {
+                                FileCacheEntry entry = (FileCacheEntry) it.next();
+                                Date modified = new Date(entry.getFile().lastModified());
+        
+                                if (modified.after(entry.getLastModified()))
+                                {                            
+                                    for (Iterator lit = FileCache.this.listeners.iterator();
lit.hasNext(); )
                                     {
-                                        listener.refresh(entry);
+                                        FileCacheEventListener listener = 
+                                            (FileCacheEventListener) lit.next();
+                                        try
+                                        {
+                                            listener.refresh(entry);
+                                        }
+                                        catch (Exception e1)
+                                        {
+                                            log.warn("Unable to refresh cached document:
 "+e1.toString(), e1);
+                                        }                                    
+                                        entry.setLastModified(modified);
                                     }
-                                    catch (Exception e1)
-                                    {
-                                        log.warn("Unable to refresh cached document:  "+e1.toString(),
e1);
-                                    }                                    
-                                    entry.setLastModified(modified);
                                 }
+                                count++;
                             }
-                            count++;
                         }
                         if (count > FileCache.this.getMaxSize())
                         {



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


Mime
View raw message