You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mf...@apache.org on 2014/01/07 22:41:24 UTC
svn commit: r1556366 - in /myfaces/portlet-bridge/core/branches/PS5: ./ api/
assembly/ examples/ examples/assembly/ examples/blank/ examples/carstore/
examples/facelets-guess/ examples/guessNumber/
examples/guessNumberMojarraFilter/ examples/guessNumbe...
Author: mfreedman
Date: Tue Jan 7 21:41:23 2014
New Revision: 1556366
URL: http://svn.apache.org/r1556366
Log:
Added fix so don't get deadlocks/thread timeouts when clearing request scope.
Modified:
myfaces/portlet-bridge/core/branches/PS5/api/pom.xml
myfaces/portlet-bridge/core/branches/PS5/assembly/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/assembly/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/blank/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/carstore/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/facelets-guess/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/guessNumber/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarraFilter/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarra_v04_to_v07_Wrapper/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMyFacesFilter/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/helloDuke/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/helloDukeCoordination/pom.xml
myfaces/portlet-bridge/core/branches/PS5/examples/pom.xml
myfaces/portlet-bridge/core/branches/PS5/impl/pom.xml
myfaces/portlet-bridge/core/branches/PS5/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
myfaces/portlet-bridge/core/branches/PS5/pom.xml
Modified: myfaces/portlet-bridge/core/branches/PS5/api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/api/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/api/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/api/pom.xml Tue Jan 7 21:41:23 2014
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<distributionManagement>
Modified: myfaces/portlet-bridge/core/branches/PS5/assembly/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/assembly/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/assembly/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/assembly/pom.xml Tue Jan 7 21:41:23 2014
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<build>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/assembly/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/assembly/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/assembly/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/assembly/pom.xml Tue Jan 7 21:41:23 2014
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<build>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/blank/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/blank/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/blank/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/blank/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<dependencies>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/carstore/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/carstore/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/carstore/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/carstore/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<dependencies>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/facelets-guess/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/facelets-guess/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/facelets-guess/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/facelets-guess/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/guessNumber/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/guessNumber/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/guessNumber/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/guessNumber/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<dependencies>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarraFilter/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarraFilter/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarraFilter/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarraFilter/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<dependencies>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarra_v04_to_v07_Wrapper/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarra_v04_to_v07_Wrapper/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarra_v04_to_v07_Wrapper/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMojarra_v04_to_v07_Wrapper/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<properties>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMyFacesFilter/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMyFacesFilter/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMyFacesFilter/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/guessNumberMyFacesFilter/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<dependencies>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/helloDuke/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/helloDuke/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/helloDuke/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/helloDuke/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<dependencies>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/helloDukeCoordination/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/helloDukeCoordination/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/helloDukeCoordination/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/helloDukeCoordination/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<dependencies>
Modified: myfaces/portlet-bridge/core/branches/PS5/examples/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/examples/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/examples/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/examples/pom.xml Tue Jan 7 21:41:23 2014
@@ -7,7 +7,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<repositories>
Modified: myfaces/portlet-bridge/core/branches/PS5/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/impl/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/impl/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/impl/pom.xml Tue Jan 7 21:41:23 2014
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces.portlet-bridge</groupId>
<artifactId>portlet-bridge</artifactId>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
</parent>
<dependencies>
Modified: myfaces/portlet-bridge/core/branches/PS5/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/PS5/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Tue Jan 7 21:41:23 2014
@@ -43,6 +43,8 @@ import java.util.Set;
import java.util.Vector;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
import javax.el.ELContext;
import javax.el.ELContextEvent;
import javax.el.ELContextListener;
@@ -157,6 +159,10 @@ public class BridgeImpl
private static final String NULL_VIEW_STATE_PARAM_VALUE = "org.apache.myfaces.portlet.faces.nullViewState";
private static final String CACHED_VIEWROOT_LOCALE = "org.apache.myfaces.portlet.faces.cachedViewRootLocale";
private static final String PROCESSED_PUBLIC_PARAMS ="org.apache.myfaces.portlet.faces.processedPublicParams";
+ private static final String REQUEST_SCOPE_REMOVAL_QUEUE = "org.apache.myfaces.portlet.faces.scopeRemovalQueue";
+ // Public to ADF bridge so they can clear the scope when the consumer's context has changed
+ public static final String CLEAR_REQUEST_SCOPE = "org.apache.myfaces.portlet.faces.clearRequestScope";
+
private static final int DEFAULT_MAX_MANAGED_REQUEST_SCOPES = 100;
private Boolean mPreserveActionParams = Boolean.FALSE;
@@ -240,6 +246,13 @@ public class BridgeImpl
if (lock == null)
{
portletContext.setAttribute(REQUEST_SCOPE_LOCK, new Object());
+
+ // create the queue (for all instances) to push/hold removed
+ // request scopes through to avoid this running/blocking on the scope lock
+ ConcurrentLinkedQueue<Map<String, Object>> queue = (ConcurrentLinkedQueue<Map<String, Object>>) new ConcurrentLinkedQueue();
+ portletContext.setAttribute(REQUEST_SCOPE_REMOVAL_QUEUE, queue);
+ Thread predestroyThread = new PreDestroyNotifierThread(queue);
+ predestroyThread.start();
}
}
@@ -336,6 +349,7 @@ public class BridgeImpl
context = getFacesContext(request, response, lifecycle, null);
// in case a prior scope was managed temporarily on the session -- remove it
+ removeRequestScopes(getRequestScopeId(request));
request.getPortletSession().removeAttribute(BRIDGE_PACKAGE_PREFIX + REQUEST_SCOPE_ID_RENDER_PARAM);
// For actions we only execute the lifecycle phase
@@ -1319,6 +1333,7 @@ public class BridgeImpl
// To make up for this we call its BridgePredestroy
if (phase != null && phase != PortletPhase.RENDER_PHASE)
{
+ // Call directly because outside of Scope lock
notifyPreDestroy(srae.getValue()); // in outerclass (BridgeImpl)
}
}
@@ -1335,6 +1350,7 @@ public class BridgeImpl
// To make up for this we call its BridgePredestroy
if (phase != null && phase != PortletPhase.RENDER_PHASE)
{
+ // Call directly because outside of Scope lock
notifyPreDestroy(srae.getValue()); // in outerclass (BridgeImpl)
}
}
@@ -1775,7 +1791,7 @@ public class BridgeImpl
managedScopes = Integer.parseInt(managedScopesSetting);
}
- return new LRUMap(managedScopes);
+ return new LRUMap(managedScopes, (ConcurrentLinkedQueue<Map<String, Object>>) portletContext.getAttribute(REQUEST_SCOPE_REMOVAL_QUEUE));
}
@SuppressWarnings("unchecked")
@@ -1932,17 +1948,27 @@ public class BridgeImpl
}
}
- // Only use this scope if it matches the current request mode
+
if (scopeId != null)
{
- // Its possible we didn't detect the mode change but its the wrong scope
- // as the scope is encoded with the mode -- confirm its right
- StringBuffer sb = new StringBuffer(10);
- String modeCheck = sb.append(":").append(request.getPortletMode().toString()).append(":").toString();
- if (scopeId.indexOf(modeCheck) < 0 )
+ // Sdee if the Portlet has told us to clear this scope.
+ Boolean clearScope = (Boolean) request.getAttribute(CLEAR_REQUEST_SCOPE);
+ if (clearScope != null && clearScope.booleanValue())
+ {
+ clearBridgeRequestScopeData(scopeId);
+ }
+ else
+ // Only use this scope if it matches the current request mode
{
- // scope is for a different mode
- scopeId = null;
+ // Its possible we didn't detect the mode change but its the wrong scope
+ // as the scope is encoded with the mode -- confirm its right
+ StringBuffer sb = new StringBuffer(10);
+ String modeCheck = sb.append(":").append(request.getPortletMode().toString()).append(":").toString();
+ if (scopeId.indexOf(modeCheck) < 0 )
+ {
+ // scope is for a different mode
+ scopeId = null;
+ }
}
}
@@ -1991,6 +2017,7 @@ public class BridgeImpl
private void clearBridgeRequestScopeData(String scopeId)
{
+ // Call directly because outside of Scope lock
notifyPreDestroy(getScopeMap(scopeId));
putBridgeRequestScopeData(scopeId, Collections.EMPTY_MAP, false);
}
@@ -2779,11 +2806,13 @@ public class BridgeImpl
*/
private static final long serialVersionUID = 4372455368577337965L;
private int mMaxCapacity;
+ private ConcurrentLinkedQueue<Map<String, Object>> mQueue;
- public LRUMap(int maxCapacity)
+ public LRUMap(int maxCapacity, ConcurrentLinkedQueue<Map<String, Object>> notifyPreDestroyQueue)
{
super(maxCapacity, 1.0f, true);
mMaxCapacity = maxCapacity;
+ mQueue = notifyPreDestroyQueue;
}
@Override
@@ -2804,9 +2833,15 @@ public class BridgeImpl
dumpScopeId(key, "RemovePhase");
Map<String, Object> o = super.remove(key);
// notify attributes maintained in this object (map) they are going away
- // Method in the outer BridgeImpl class
- if (o != null)
- notifyPreDestroy(o);
+ // Done by pushing the Map to a queue that another thread is pulling from
+ if (o != null)
+ {
+ synchronized (mQueue)
+ {
+ mQueue.add(o);
+ mQueue.notifyAll();
+ }
+ }
return o;
}
@@ -2818,6 +2853,53 @@ public class BridgeImpl
}
}
+
+ private final class PreDestroyNotifierThread extends Thread
+ {
+ ConcurrentLinkedQueue <Map<String, Object>> mQueue;
+
+ public PreDestroyNotifierThread(ConcurrentLinkedQueue queue)
+ {
+ mQueue = queue;
+ }
+
+ public void run()
+ {
+ ArrayList<Map<String, Object>> scopes = (ArrayList<Map<String, Object>>) new ArrayList(10);
+ while (true)
+ {
+ synchronized(mQueue)
+ {
+ while (mQueue.isEmpty())
+ {
+ try
+ {
+ mQueue.wait();
+ }
+ catch (InterruptedException e)
+ {;}
+ }
+
+ for (Iterator<Map<String, Object>> i = mQueue.iterator(); i.hasNext();)
+ {
+ Map m = i.next();
+ if (m != Collections.EMPTY_MAP)
+ {
+ scopes.add((Map<String, Object>)m);
+ }
+ }
+ mQueue.clear();
+ }
+
+ for (Iterator<Map<String, Object>> i = scopes.iterator(); i.hasNext();)
+ {
+ Map<String, Object> m = i.next();
+ notifyPreDestroy(m);
+ }
+ scopes.clear();
+ }
+ }
+ }
// TODO: Should we store these as attributes of the ViewTree??? It would
// work as
Modified: myfaces/portlet-bridge/core/branches/PS5/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/PS5/pom.xml?rev=1556366&r1=1556365&r2=1556366&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/PS5/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/PS5/pom.xml Tue Jan 7 21:41:23 2014
@@ -24,7 +24,7 @@
<artifactId>portlet-bridge</artifactId>
<packaging>pom</packaging>
<name>MyFaces Portlet Bridge</name>
- <version>2.0.0.1-PATCH</version>
+ <version>2.0.0.1-PS5</version>
<inceptionYear>2007</inceptionYear>
<description>
Portlet Bridge for JavaServer Faces is a subproject of Apache MyFaces which provides an
@@ -194,14 +194,14 @@
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>portlet-bridge-api</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.0.0.1-PS5</version>
</dependency>
<!-- JSF Portlet Bridge Impl -->
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>portlet-bridge-impl</artifactId>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.0.0.1-PS5</version>
</dependency>
</dependencies>
</dependencyManagement>