You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bs...@apache.org on 2010/05/01 00:41:52 UTC

svn commit: r939857 - /myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java

Author: bsullivan
Date: Fri Apr 30 22:41:52 2010
New Revision: 939857

URL: http://svn.apache.org/viewvc?rev=939857&view=rev
Log:
Fix part where this accidentally disabled the original point of clearing the UIViewRoot cache

Modified:
    myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java

Modified: myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java?rev=939857&r1=939856&r2=939857&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java (original)
+++ myfaces/trinidad/branches/1.2.12.3-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java Fri Apr 30 22:41:52 2010
@@ -320,16 +320,14 @@ public class StateManagerImpl extends St
       String token;
       ExternalContext extContext = context.getExternalContext();
 
-
       if (applicationViewCache == null)
       {
         assert(!dontSave);
         TokenCache cache = _getViewCache(context);
         assert(cache != null);
 
-        Map<String, Object> sessionMap = extContext.getSessionMap();
-
-        RequestContext trinContext = RequestContext.getCurrentInstance();
+        Map<String, Object> sessionMap  = extContext.getSessionMap();
+        RequestContext      trinContext = RequestContext.getCurrentInstance();
 
         // get view cache key with "." separator suffix to separate the SubKeyMap keys
         String subkey = _getViewCacheKey(extContext, trinContext, _SUBKEY_SEPARATOR);
@@ -346,29 +344,9 @@ public class StateManagerImpl extends St
             // Save the view root into the page state as a transient
             // if this feature has not been disabled
             _useViewRootCache(context) ? root : null);
-
-        // clear out all of the previous PageStates' UIViewRoots and add this page
-        // state as an active page state.  This is necessary to avoid UIViewRoots
-        // laying around if the user navigates off of a page using a GET
-        synchronized(extContext.getSession(true))
-        {
-         // get the per-window key for the active page state.  We only store the token rather than
-         // the view state itself here in order to keep fail-over Serialization from Serializing this
-         // state twice, once where it appears here and the second time in the token map itself
-         // See Trinidad-1779
-         String activePageStateKey = _getActivePageTokenKey(extContext, trinContext);
-         String activeToken = (String)sessionMap.get(activePageStateKey);
-         
-         if (activeToken != null)
-         {
-           PageState activePageState = stateMap.get(activeToken);
-        
-           if (activePageState != null)
-             activePageState.clearViewRootState();
-         }
-        }
         
         String requestToken = _getRequestTokenForResponse(context);
+        
         // If we have a cached token that we want to reuse,
         // and that token hasn't disappeared from the cache already
         // (unlikely, but not impossible), use the stateMap directly
@@ -394,6 +372,34 @@ public class StateManagerImpl extends St
                                     stateMap,
                                     pinnedToken);
         }
+
+        // clear out all of the previous PageStates' UIViewRoots and add this page
+        // state as an active page state.  This is necessary to avoid UIViewRoots
+        // laying around if the user navigates off of a page using a GET
+        synchronized(extContext.getSession(true))
+        {
+          // get the per-window key for the active page state.  We only store the token rather than
+          // the view state itself here in order to keep fail-over Serialization from Serializing this
+          // state twice, once where it appears here and the second time in the token map itself
+          // See Trinidad-1779
+          String activePageStateKey = _getActivePageTokenKey(extContext, trinContext);
+          String activeToken = (String)sessionMap.get(activePageStateKey);
+          
+          // we only need to clear out the state if we're actually changing pages and thus tokens.
+          // Since we have already updated the state for 
+          if (!token.equals(activeToken))
+          {
+            if (activeToken != null)
+            {
+              PageState activePageState = stateMap.get(activeToken);
+        
+              if (activePageState != null)
+                activePageState.clearViewRootState();
+            }
+
+            sessionMap.put(activePageStateKey, token);
+          }
+        }
       }
       // If we got the "applicationViewCache", we're using it.
       else