portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r484690 - in /portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed: page/document/proxy/NodeProxy.java portalsite/impl/PortalSiteRequestContextImpl.java
Date Fri, 08 Dec 2006 18:25:46 GMT
Author: taylor
Date: Fri Dec  8 10:25:44 2006
New Revision: 484690

URL: http://svn.apache.org/viewvc?view=rev&rev=484690
Log:
http://issues.apache.org/jira/browse/JS2-619
Non-thread safe code in PortalSiteRequestContextImpl.java
contribution from Woonsan Ko

Modified:
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java?view=diff&rev=484690&r1=484689&r2=484690
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/page/document/proxy/NodeProxy.java
Fri Dec  8 10:25:44 2006
@@ -20,6 +20,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Collections;
 
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.MenuDefinition;
@@ -177,7 +178,7 @@
             List locators = getMenuDefinitionLocators();
             if (locators != null)
             {
-                menuDefinitions = new ArrayList(locators.size());
+                menuDefinitions = Collections.synchronizedList(new ArrayList(locators.size()));
                 Iterator locatorsIter = locators.iterator();
                 while (locatorsIter.hasNext())
                 {
@@ -260,7 +261,7 @@
                     {
                         if (menuDefinitionLocators == null)
                         {
-                            menuDefinitionLocators = new ArrayList(definitions.size() * 2);
+                            menuDefinitionLocators = Collections.synchronizedList(new ArrayList(definitions.size()
* 2));
                         }
                         menuDefinitionLocators.add(new SiteViewMenuDefinitionLocator(definition,
node));
                     }
@@ -295,7 +296,7 @@
                 {
                     if (menuDefinitionLocators == null)
                     {
-                        menuDefinitionLocators = new ArrayList(locators.size() * 2);
+                        menuDefinitionLocators = Collections.synchronizedList(new ArrayList(locators.size()
* 2));
                     }
                     menuDefinitionLocators.add(locator);
                 }
@@ -326,13 +327,15 @@
         // find matching menu definition locator by name
         if ((menuDefinitionLocators != null) && (name != null))
         {
-            Iterator locatorsIter = menuDefinitionLocators.iterator();
-            while (locatorsIter.hasNext())
-            {
-                SiteViewMenuDefinitionLocator locator = (SiteViewMenuDefinitionLocator)locatorsIter.next();
-                if (name.equals(locator.getName()))
+            synchronized (menuDefinitionLocators) {
+                Iterator locatorsIter = menuDefinitionLocators.iterator();
+                while (locatorsIter.hasNext())
                 {
-                    return locator;
+                    SiteViewMenuDefinitionLocator locator = (SiteViewMenuDefinitionLocator)locatorsIter.next();
+                    if (name.equals(locator.getName()))
+                    {
+                        return locator;
+                    }
                 }
             }
         }

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java?view=diff&rev=484690&r1=484689&r2=484690
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
Fri Dec  8 10:25:44 2006
@@ -22,6 +22,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Collections;
 
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.MenuDefinition;
@@ -413,7 +414,7 @@
             if (locators != null)
             {
                 // get custom definition names
-                pageMenuDefinitionNames = new HashSet(locators.size());
+                pageMenuDefinitionNames = Collections.synchronizedSet(new HashSet(locators.size()));
                 Iterator locatorsIter = locators.iterator();
                 while (locatorsIter.hasNext())
                 {
@@ -427,7 +428,7 @@
             }
             else
             {
-                pageMenuDefinitionNames = new HashSet(0);
+                pageMenuDefinitionNames = Collections.synchronizedSet(new HashSet(0));
             }
         }
         return pageMenuDefinitionNames;
@@ -508,7 +509,7 @@
                     // cache relative menu for request
                     if (menuDefinitionLocatorCache == null)
                     {
-                        menuDefinitionLocatorCache = new HashMap(8);
+                        menuDefinitionLocatorCache = Collections.synchronizedMap(new HashMap(8));
                     }
                     menuDefinitionLocatorCache.put(locator, menu);
                 }
@@ -517,7 +518,7 @@
                     // cache absolute menu for session
                     if (sessionContext.getMenuDefinitionLocatorCache() == null)
                     {
-                        sessionContext.setMenuDefinitionLocatorCache(new HashMap(8));
+                        sessionContext.setMenuDefinitionLocatorCache(Collections.synchronizedMap(new
HashMap(8)));
                     }
                     sessionContext.getMenuDefinitionLocatorCache().put(locator, menu);
                 }



---------------------------------------------------------------------
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