portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r1599238 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/caches/ components/jetspeed-portal/src/test/java/org/apache/jetspeed/decoration/ jetspeed-api/src/main/java/org/apache/j...
Date Mon, 02 Jun 2014 15:17:47 GMT
Author: taylor
Date: Mon Jun  2 15:17:47 2014
New Revision: 1599238

URL: http://svn.apache.org/r1599238
Log:
JS2-1294: Fix for race condition occuring in SessionPathResolverCache since the internal cache
is initialized with a non-threadsave HashMap. Contribution from Joachim Mueller.

Removed:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/caches/HashMapPathResolverCache.java
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/decoration/TestDecorations.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java?rev=1599238&r1=1599237&r2=1599238&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java
Mon Jun  2 15:17:47 2014
@@ -16,35 +16,54 @@
  */
 package org.apache.jetspeed.decoration.caches;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpSession;
-
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.decoration.PathResolverCache;
 
+import javax.servlet.http.HttpSession;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 /**
  * Extends the 
  * 
  * @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a>
  *
  */
-public class SessionPathResolverCache extends HashMapPathResolverCache implements PathResolverCache
+public class SessionPathResolverCache implements PathResolverCache
 {
-    public SessionPathResolverCache(HttpSession session)
+    
+	private Map<String,String> cache = null;
+	
+	public SessionPathResolverCache(HttpSession session)
     {
-        cache = (Map) session.getAttribute(PortalReservedParameters.RESOVLER_CACHE_ATTR);
-        
+        cache = (Map) session.getAttribute(PortalReservedParameters.RESOLVER_CACHE_ATTR);
         if(cache == null)
         {
-            cache = new HashMap();
-            session.setAttribute(PortalReservedParameters.RESOVLER_CACHE_ATTR, cache);
+            cache = new ConcurrentHashMap<String, String>();
+            session.setAttribute(PortalReservedParameters.RESOLVER_CACHE_ATTR, cache);
         }
     }
     
-    public void clear()
-    {
+	@Override
+	public void clear() {
         cache.clear();
     }
+
+	@Override
+	public void addPath(String key, String path) {
+        cache.put(key, path);
+		
+	}
+
+	@Override
+	public String getPath(String key) {
+        return cache.get(key);
+	}
+
+	@Override
+	public String removePath(String key) {
+        return cache.remove(key);
+	}
+	
+
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/decoration/TestDecorations.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/decoration/TestDecorations.java?rev=1599238&r1=1599237&r2=1599238&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/decoration/TestDecorations.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/decoration/TestDecorations.java
Mon Jun  2 15:17:47 2014
@@ -16,16 +16,6 @@
  */
 package org.apache.jetspeed.decoration;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Properties;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.page.ContentPage;
@@ -36,6 +26,15 @@ import org.jmock.MockObjectTestCase;
 import org.jmock.core.Constraint;
 import org.jmock.core.InvocationMatcher;
 
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Properties;
+
 public class TestDecorations extends MockObjectTestCase
 {
     private Path testPathHtmlEn;
@@ -256,8 +255,7 @@ public class TestDecorations extends Moc
         expectAndReturn(atLeastOnce(), servletRequestMock, "getSession", sessionMock.proxy());
         expectAndReturn(atLeastOnce(), requestContextMock, "getRequest", servletRequestMock.proxy());
         
-        expectAndReturn(atLeastOnce(), sessionMock, "getAttribute", new Constraint[]{eq(PortalReservedParameters.RESOVLER_CACHE_ATTR)},
new HashMap());
-        //expectAndReturn(sessionMock, "getAttribute", PortalReservedParameters.RESOVLER_CACHE_ATTR);
+        expectAndReturn(atLeastOnce(), sessionMock, "getAttribute", new Constraint[]{eq(PortalReservedParameters.RESOLVER_CACHE_ATTR)},
new HashMap());
 
         expectAndReturn(childFragmentMock, "getDecorator", "myPortletDecoration");
 

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java?rev=1599238&r1=1599237&r2=1599238&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/PortalReservedParameters.java
Mon Jun  2 15:17:47 2014
@@ -65,7 +65,7 @@ public interface PortalReservedParameter
     public static final String PATH_ATTRIBUTE = "org.apache.jetspeed.Path";
     public static final String CONTENT_PATH_ATTRIBUTE = "org.apache.jetspeed.ContentPath";
     public static final String PARAMETER_ALREADY_DECODED_ATTRIBUTE = "org.apache.jetspeed.parameterAlreadyDecoded";
-    public static final String RESOVLER_CACHE_ATTR = "org.apache.jetspeed.resovler.cache";
+    public static final String RESOLVER_CACHE_ATTR = "org.apache.jetspeed.resolver.cache";
     public static final String PORTLET_DEFINITION_ATTRIBUTE = "org.apache.jetspeed.portlet.definition";
     public static final String PORTLET_WINDOW_ATTRIBUTE = "org.apache.jetspeed.portlet.window";
     public static final String PORTLET_FILTER_MANAGER_ATTRIBUTE = "org.apache.jetspeed.portlet.container.filterManager";



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