Closed ren-zhijun-oracle closed 9 years ago
@javaserverfaces Commented Reported by VsevolodGolovanov
@javaserverfaces Commented @manfredriem said: Applied to 2.3 trunk,
svn commit -m "Fixes https://java.net/jira/browse/JAVASERVERFACES-3739, ViewScopeContextManager: incorrect synchronization" Sending jsf-ri/src/main/java/com/sun/faces/application/view/ViewScopeContextManager.java Transmitting file data . Committed revision 14433.
@javaserverfaces Commented File: changebundle.txt Attached By: @manfredriem
@javaserverfaces Commented This issue was imported from java.net JIRA JAVASERVERFACES-3739
@javaserverfaces Commented Marked as fixed on Tuesday, February 24th 2015, 8:42:39 am
1.
if (activeViewScopeContexts == null && create) {
synchronized (session) {
activeViewScopeContexts = new ConcurrentHashMap<>();
sessionMap.put(ACTIVE_VIEW_CONTEXTS, activeViewScopeContexts);
}
}
It synchronizes on the session object. As mentioned before in https://github.com/eclipse-ee4j/mojarra/issues/3738 the session object is a different instance in each request at least with Undertow. See also https://github.com/jakartaee/servlet/issues/122.
(Just leaving a note here, because it's not important enough to be properly reported, and https://github.com/eclipse-ee4j/mojarra/issues/3738 was dismissed anyway.)
It warrants a fix. Please create a new issue.
com.sun.faces.application.view.ViewScopeContextManager.getContextMap(FacesContext, boolean):
There are 2 problems here:
The synchronizing and checking block is incorrect. It should be either a straightforward:``` synchronized (lock) { if (activeViewScopeContexts == null && create) { activeViewScopeContexts = new ConcurrentHashMap<Object, Map<String, ViewScopeContextObject>>(); sessionMap.put(ACTIVE_VIEW_CONTEXTS, activeViewScopeContexts); } }
if (activeViewScopeContexts == null && create) { synchronized (lock) { activeViewScopeContexts = sessionMap.get(ACTIVE_VIEW_CONTEXTS); if (activeViewScopeContexts == null) { activeViewScopeContexts = new ConcurrentHashMap<Object, Map<String, ViewScopeContextObject>>(); sessionMap.put(ACTIVE_VIEW_CONTEXTS, activeViewScopeContexts); } } }