myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfreed...@apache.org
Subject svn commit: r982809 - in /myfaces/portlet-bridge/core/trunk: api/src/main/java/javax/portlet/faces/ impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/ impl/src/main/java/org/apache/myfaces/portlet/faces/util/
Date Thu, 05 Aug 2010 22:24:45 GMT
Author: mfreedman
Date: Thu Aug  5 22:24:45 2010
New Revision: 982809

URL: http://svn.apache.org/viewvc?rev=982809&view=rev
Log:
PORTLETBRIDGE-165: Bridge explicit scope removal doesn't cause its attributes to be notified
but should
PORTLETBRIDGE-164: Bridge shouldn't notify (bridge) request scope attributes that they are
being destroyed if only updating the scope at the end of a request
PORTLETBRIDGE-160: QueryString.numParameters throws NullPointerException
PORTLETBRIDGE-159: Race condition in GenericFacesPortlet: mFacesBridge 

Modified:
    myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
    myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
    myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java

Modified: myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java?rev=982809&r1=982808&r2=982809&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
(original)
+++ myfaces/portlet-bridge/core/trunk/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
Thu Aug  5 22:24:45 2010
@@ -167,7 +167,9 @@ public class GenericFacesPortlet extends
     getPortletContext().setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "."
+ 
                                      Bridge.DEFAULT_VIEWID_MAP, defaultViewIdMap);
 
-    // Don't instanciate/initialize the bridge yet. Do it on first use
+    // Initialize the bridge as the double lock mechanism used for lazy instantiation doesn't
(always) work in Java even if 
+    // declared a volitle -- and the bridge is likely to be used anyway -- so why worry about
it
+    initBridge();
   }
 
   /**
@@ -530,9 +532,6 @@ public class GenericFacesPortlet extends
   private void initBridgeRequest(PortletRequest request, 
                                  PortletResponse response) throws PortletException
   {
-    initBridge();
-
-
     // Now do any per request initialization
     // I nthis case look to see if the request is encoded (usually 
     // from a NonFaces view response) with the specific Faces
@@ -559,13 +558,10 @@ public class GenericFacesPortlet extends
       try
       {
         // ensure we only ever create/init one bridge per portlet
-        synchronized(mLock)
+        if (mFacesBridge == null)
         {
-          if (mFacesBridge == null)
-          {
-            mFacesBridge = mFacesBridgeClass.newInstance();
-            mFacesBridge.init(getPortletConfig());
-          }
+          mFacesBridge = mFacesBridgeClass.newInstance();
+          mFacesBridge.init(getPortletConfig());
         }
       }
       catch (Exception e)

Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=982809&r1=982808&r2=982809&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
(original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
Thu Aug  5 22:24:45 2010
@@ -39,6 +39,8 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
+import java.util.Vector;
+
 import javax.el.ELContext;
 import javax.el.ELContextEvent;
 import javax.el.ELContextListener;
@@ -1603,15 +1605,28 @@ public class BridgeImpl
 
       if (requestScopeMap != null)
       {
-      	Iterator<String> iterator = requestScopeMap.keySet().iterator();
-      	while (iterator.hasNext())
-      	{
+        Vector<String> scopesToRemove = (Vector<String>) new Vector(5);
+
+        Iterator<String> iterator = requestScopeMap.keySet().iterator();
+        while (iterator.hasNext())
+        {
           String scopeId = iterator.next();
           if (scopeId != null && scopeId.startsWith(scopePrefix))
           {
-          	iterator.remove();
+            // don't remove from iterator -- rather directly from the Map
+            // So the Maps.remove is called which invoked notifyPredestroy()
+            scopesToRemove.add(scopeId);
           }
-      	}
+        }
+        iterator = scopesToRemove.iterator();
+        while (iterator.hasNext())
+        {
+          String scopeId = iterator.next();
+          if (scopeId != null)
+          {
+            requestScopeMap.remove(scopeId);
+          }
+        }
       }
     }
   }
@@ -1763,12 +1778,9 @@ public class BridgeImpl
 
     public Map<String,Object> put(String key, Map<String, Object> value)
     {
-      Map<String,Object> o = super.put(key, value);
-      // notify attributes maintained in this object (map) they are going away
-      // Method in the outer BridgeImpl class
-      if (o != null)
-        notifyPreDestroy(o);
-      return o;
+      // Don't notify PreDestroy here.  New entry should be a duplicate/replacement for old
entry
+      // containing the same elements (minus any added/removed in this request)
+      return super.put(key, value);
     }
 
   }

Modified: myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java?rev=982809&r1=982808&r2=982809&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java
(original)
+++ myfaces/portlet-bridge/core/trunk/impl/src/main/java/org/apache/myfaces/portlet/faces/util/QueryString.java
Thu Aug  5 22:24:45 2010
@@ -168,7 +168,7 @@ public final class QueryString
   
   public int numParameters()
   {
-    return mParameterMap.size();
+    return (mParameterMap != null) ? mParameterMap.size() : 0;
   }
 
   public String getParameter(String name)



Mime
View raw message