You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2011/08/31 22:17:22 UTC

svn commit: r1163788 - in /myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal: application/StateManagerImpl.java util/TokenCache.java util/TokenCacheDebugUtils.java

Author: gcrawford
Date: Wed Aug 31 20:17:21 2011
New Revision: 1163788

URL: http://svn.apache.org/viewvc?rev=1163788&view=rev
Log:
TRINIDAD-2131 Make it easier to debug viewExpiredExceptions

Added:
    myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCacheDebugUtils.java
      - copied, changed from r1161970, myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCacheDebugUtils.java
Modified:
    myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
    myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCache.java

Modified: myfaces/trinidad/branches/1.2.12.6.0-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.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java?rev=1163788&r1=1163787&r2=1163788&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java (original)
+++ myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java Wed Aug 31 20:17:21 2011
@@ -61,6 +61,7 @@ import org.apache.myfaces.trinidadintern
 import org.apache.myfaces.trinidadinternal.util.ObjectInputStreamResolveClass;
 import org.apache.myfaces.trinidadinternal.util.SubKeyMap;
 import org.apache.myfaces.trinidadinternal.util.TokenCache;
+import org.apache.myfaces.trinidadinternal.util.TokenCacheDebugUtils;
 
 
 /**
@@ -604,7 +605,7 @@ public class StateManagerImpl extends St
 
         // get view cache key with "." separator suffix to separate the SubKeyMap keys
         String subkey = _getViewCacheKey(extContext, trinContext, _SUBKEY_SEPARATOR);
-
+      
         Map<String, PageState> stateMap = new SubKeyMap<PageState>(
                          extContext.getSessionMap(),
                          subkey);
@@ -627,6 +628,24 @@ public class StateManagerImpl extends St
       if (viewState == null)
       {
         _LOG.severe("CANNOT_FIND_SAVED_VIEW_STATE", token);
+
+        if(TokenCacheDebugUtils.debugTokenCache())
+        {
+          // get the state map
+          String subkey = _getViewCacheKey(extContext,
+                                           RequestContext.getCurrentInstance(),
+                                           _SUBKEY_SEPARATOR);
+
+          Map<String, PageState> stateMap = new SubKeyMap<PageState>(
+                           extContext.getSessionMap(),
+                           subkey);
+          
+          // log what's currently in the state map
+          TokenCacheDebugUtils.startLog("Restore View");
+          TokenCacheDebugUtils.logCacheInfo(stateMap, null, "token '" + token + "' not found"); 
+          _LOG.severe(TokenCacheDebugUtils.getLogString());        
+        }
+        
         return null;
       }
 

Modified: myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCache.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCache.java?rev=1163788&r1=1163787&r2=1163788&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCache.java (original)
+++ myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCache.java Wed Aug 31 20:17:21 2011
@@ -26,13 +26,10 @@ import java.security.NoSuchAlgorithmExce
 import java.security.SecureRandom;
 
 import java.util.Map;
-
 import java.util.concurrent.ConcurrentHashMap;
-
 import java.util.concurrent.atomic.AtomicLong;
 
 import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
 
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
@@ -233,6 +230,21 @@ public class TokenCache implements Seria
       // NOTE: this put() has a side-effect that can result
       // in _removed being non-null afterwards
       _cache.put(token, token);
+
+      if(TokenCacheDebugUtils.debugTokenCache())
+      {
+        TokenCacheDebugUtils.startLog("Add New Entry");
+        TokenCacheDebugUtils.addTokenToViewIdMap(token);
+
+        if (pinnedToken != null)
+        {
+          TokenCacheDebugUtils.addToLog("\nPINNING " + 
+                      TokenCacheDebugUtils.getTokenToViewIdString(token) + 
+                      " to " + 
+                      TokenCacheDebugUtils.getTokenToViewIdString(pinnedToken));  
+        }
+      }
+      
       remove = _removed;
       _removed = null;
     }
@@ -241,18 +253,24 @@ public class TokenCache implements Seria
     // assert above.
     if (remove != null)
     {
-      _removeTokenIfReady(targetStore, remove);
+      _removeTokenIfReady(targetStore, remove);        
     }
     
     targetStore.put(token, value);
 
     // our contents have changed, so mark ourselves as dirty in our owner
     _dirty();
-    
+
+    if(TokenCacheDebugUtils.debugTokenCache())
+    {
+      TokenCacheDebugUtils.logCacheInfo(targetStore, _pinned, "After Additions"); 
+      _LOG.severe(TokenCacheDebugUtils.getLogString());
+      
+    }
+
     return token;
   }
 
-
   /**
    * Returns true if an entry is still available.  This
    * method has a side-effect:  by virtue of accessing the token,
@@ -289,21 +307,42 @@ public class TokenCache implements Seria
     {
       _LOG.finest("Removing token ''{0}''", token);
       // Remove it from the target store
+
+      if (TokenCacheDebugUtils.debugTokenCache())
+      {
+        TokenCacheDebugUtils.removeTokenFromViewIdMap(token);
+      }
+      
       removedValue = targetStore.remove(token);
       // Now, see if that key was pinning anything else
       String wasPinned = _pinned.remove(token);
       if (wasPinned != null)
+      {
+
+        if (TokenCacheDebugUtils.debugTokenCache())
+        {
+          TokenCacheDebugUtils.addToLog("\nREMOVING pinning of token " + token + " to " + 
+                      TokenCacheDebugUtils.getTokenToViewIdString(wasPinned));  
+        }        
+        
         // Yup, so see if we can remove that token
         _removeTokenIfReady(targetStore, wasPinned);
+      }
     }
     else
     {
+      if (TokenCacheDebugUtils.debugTokenCache())
+      {
+        TokenCacheDebugUtils.addToLog("\nNOT removing pinned token from target store " + 
+                    TokenCacheDebugUtils.getTokenToViewIdString(token) );  
+      }
+      
       _LOG.finest("Not removing pinned token ''{0}''", token);
       // TODO: is this correct?  We're not really removing
       // the target value.
       removedValue = targetStore.get(token);
     }
-    
+
     return removedValue;
   }
 
@@ -320,12 +359,23 @@ public class TokenCache implements Seria
     
     synchronized (this)
     {
+      if(TokenCacheDebugUtils.debugTokenCache())
+      {
+        TokenCacheDebugUtils.startLog("Remove Old Entry");
+      }
+      
       _LOG.finest("Removing token {0} from cache", token);
       _cache.remove(token);
       
       // TODO: should removing a value that is "pinned" take?
       // Or should it stay in memory?
       oldValue = _removeTokenIfReady(targetStore, token);
+      
+      if (TokenCacheDebugUtils.debugTokenCache())
+      {
+        TokenCacheDebugUtils.logCacheInfo(targetStore, _pinned, "After removing old entry:");
+        _LOG.severe(TokenCacheDebugUtils.getLogString());
+      }
     }
 
     // our contents have changed, so mark ourselves as dirty in our owner

Copied: myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCacheDebugUtils.java (from r1161970, myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCacheDebugUtils.java)
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCacheDebugUtils.java?p2=myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCacheDebugUtils.java&p1=myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCacheDebugUtils.java&r1=1161970&r2=1163788&rev=1163788&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCacheDebugUtils.java (original)
+++ myfaces/trinidad/branches/1.2.12.6.0-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/util/TokenCacheDebugUtils.java Wed Aug 31 20:17:21 2011
@@ -28,9 +28,35 @@ import javax.faces.context.FacesContext;
 import javax.servlet.http.HttpSession;
 
 import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.context.Window;
 import org.apache.myfaces.trinidad.context.WindowManager;
-
-
+    
+ /**
+  * ViewExpiredExceptions are fairly common, and the token cache is used for 
+  * page state tokens, but the tokens aren't really human readable. 
+  * In order to make it easier to understand what is in the cache
+  * we've added a system property for debugging purposes. When enabled
+  * we store a map of token -> viewId on the session which we use
+  * to log something more human readable.
+  * 
+  * in order to use this the tester would set the system property to:
+  * -Dorg.apache.myfaces.trinidadinternal.DEBUG_TOKEN_CACHE=true
+  * 
+  * TokenCacheDebugUtils provides methods to log human readable debugging info.
+  * 
+  * 
+  * The goal is to provide as much logging information in a single log message as possible. 
+  * In order to do this we are pushing log info into a buffer and when we're ready to log 
+  * we can get the string. To start the log call like so:
+  *        TokenCacheDebugUtils.startLog("My Custom String");
+  * 
+  * Then you can call methods like:
+  *        TokenCacheDebugUtils.logCacheInfo(stateMap, null, "hello world"); 
+  *        TokenCacheDebugUtils.addToLog("foo bar");
+  *        
+  * Then when you're ready to actually put it in the log you would do this:
+  *        _LOG.severe(TokenCacheDebugUtils.getLogString());      
+  */
 public final class TokenCacheDebugUtils 
 {
   
@@ -41,14 +67,18 @@ public final class TokenCacheDebugUtils 
    * Checks whether we are debugging the token cache.
    * No other method in TokenCacheDebugUtils should be called unless this method returns true.
    */
-  public static Boolean debugTokenCache()
+  public static boolean debugTokenCache()
   {
     return _DEBUG_TOKEN_CACHE;
   }
   
   /**
-   * Method to help with debugging, should only be called when 
-   * debugTokenCache() is true
+   * In order to provide human readable information there is a map which 
+   * has token to viewId information.
+   * 
+   * Add the token passed in and associate it in the map with the current view id. 
+   * 
+   * This method should only be called when debugTokenCache() is true
    */
   public static void addTokenToViewIdMap(String token)
   {
@@ -56,59 +86,72 @@ public final class TokenCacheDebugUtils 
       throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
     
     FacesContext context = FacesContext.getCurrentInstance();
-    Map<String,String> tokenToViewIdMap = getTokenToViewIdMap();      
+    Map<String,String> tokenToViewIdMap = _getTokenToViewIdMap(context);      
     UIViewRoot root = context.getViewRoot();
     String viewId = root.getViewId();    
     tokenToViewIdMap.put(token, viewId);
-    
-    addToRequestStringBuffer("\nADDING " +  getTokenToViewIdString(tokenToViewIdMap, token));
+
+    StringBuffer logBuffer = _getLogBuffer(context);
+    logBuffer.append("\nADDING ").append(_getTokenToViewIdString(tokenToViewIdMap, token));
   }
 
   /**
-   * Method to help with debugging, should only be called when 
-   * debugTokenCache() is true
+   * In order to provide human readable information there is a map which 
+   * has token to viewId information.
+   * 
+   * Remove the view id info from the map for the given token.
+   * 
+   * This method should only be called when debugTokenCache() is true
    */
   public static void removeTokenFromViewIdMap(String token)
   {
     if (!_DEBUG_TOKEN_CACHE)
       throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
-    
-    Map<String,String> tokenToViewIdMap = getTokenToViewIdMap();  
-    
-    addToRequestStringBuffer("\nREMOVING " + getTokenToViewIdString(tokenToViewIdMap, token));
+
+    FacesContext context = FacesContext.getCurrentInstance();
+    Map<String,String> tokenToViewIdMap = _getTokenToViewIdMap(context);  
+
+    StringBuffer logBuffer = _getLogBuffer(context);
+    logBuffer.append( "\nREMOVING ").append( _getTokenToViewIdString(tokenToViewIdMap, token));
     tokenToViewIdMap.remove(token);
   }  
 
-
   /**
-   * Method to help with debugging, should only be called when 
-   * debugTokenCache() is true
+   * Generate a string showing the token and the view id we have saved for that token
+   * 
+   * This method should only be called when debugTokenCache() is true
    */
-  public static String getTokenToViewIdString(Map<String,String> tokenToViewId, String token)
-  {  
+  public static String getTokenToViewIdString(String token)
+  {      
     if (!_DEBUG_TOKEN_CACHE)
       throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
-    
-    StringBuffer tokenBuffer = new StringBuffer();
-    tokenBuffer.append(token);
-    tokenBuffer.append(" (");
-    tokenBuffer.append(tokenToViewId.get(token));
-    tokenBuffer.append(")");
-    
-    return tokenBuffer.toString();
+    FacesContext context = FacesContext.getCurrentInstance();
+    return _getTokenToViewIdString( _getTokenToViewIdMap(context), token);
   }
 
+
   /**
-   * Method to help with debugging, should only be called when 
-   * debugTokenCache() is true
+   * 
+   * Add info about the cache to the log buffer.
+   * 
+   * For the target store map, the keys are tokens. For each token we will call 
+   * getTokenToViewIdString to show what's in the map.
+   * 
+   * For the pinned map the keys and values are tokens, for each key/value pair call 
+   * getTokenToViewIdString to show what is pinned.
+   * 
+   * This method should only be called when debugTokenCache() is true
    */
   public static <V> void logCacheInfo(Map<String, V> targetStore, Map<String, String> pinned, String logAddition)
   {  
     if (!_DEBUG_TOKEN_CACHE)
       throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
-    
-    Map<String,String> tokenToViewId = getTokenToViewIdMap();
-    StringBuffer logString = new StringBuffer();
+
+    FacesContext context = FacesContext.getCurrentInstance();
+    Map<String,String> tokenToViewId = _getTokenToViewIdMap(context);
+    // TODO - add this directly to the log buffer
+    StringBuffer logString =  _getLogBuffer(context);
+    logString.append("\n");
 
     if (logAddition != null)
     {
@@ -120,7 +163,7 @@ public final class TokenCacheDebugUtils 
     for (String targetStoreToken: targetStore.keySet()) 
     {
       logString.append("\n    ");
-      logString.append(getTokenToViewIdString(tokenToViewId, targetStoreToken));
+      logString.append(_getTokenToViewIdString(tokenToViewId, targetStoreToken));
     }  
     
     if (pinned != null)
@@ -130,49 +173,92 @@ public final class TokenCacheDebugUtils 
       for (String pinnedKeyToken: pinned.keySet()) 
       {
         logString.append("\n    ");
-        logString.append(getTokenToViewIdString(tokenToViewId, pinnedKeyToken));
+        logString.append(_getTokenToViewIdString(tokenToViewId, pinnedKeyToken));
         
         logString.append("   pinned to     ");
         String pinnedValueToken = pinned.get(pinnedKeyToken);
-        logString.append(getTokenToViewIdString(tokenToViewId, pinnedValueToken));
+        logString.append(_getTokenToViewIdString(tokenToViewId, pinnedValueToken));
       }
-    }
-    
-    addToRequestStringBuffer("\n" + logString.toString());
+    }    
   }  
 
+
   /**
-   * Method to help with debugging, should only be called when 
-   * debugTokenCache() is true
+   * Add a string to the current log buffer
+   * 
+   * This method should only be called when debugTokenCache() is true
    */
-  public static Map<String,String> getTokenToViewIdMap()
-  {
+  public static void addToLog(String addString)
+  {     
     if (!_DEBUG_TOKEN_CACHE)
       throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
     
     FacesContext context = FacesContext.getCurrentInstance();
-    Map<String,String> tokenToViewId = (Map<String, String>)context.getExternalContext().getSessionMap().get("org.apache.myfaces.trinidadinternal.util.TOKEN_FOR_VIEW_ID");
+    _getLogBuffer(context).append(addString);
+  }
+
+  /**
+   * Start a log buffer.
+   * The startString passed in will be printed, along with session id and window id information
+   * 
+   * This method should only be called when debugTokenCache() is true
+   */
+  public static void startLog(String startString)
+  {
+    if (!_DEBUG_TOKEN_CACHE)
+      throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
     
-    if (tokenToViewId == null) 
-    {
-      tokenToViewId = new ConcurrentHashMap<String, String>();
-      context.getExternalContext().getSessionMap().put("org.apache.myfaces.trinidadinternal.util.TOKEN_FOR_VIEW_ID", tokenToViewId);
-      
-    }
-    return tokenToViewId;
+    FacesContext context = FacesContext.getCurrentInstance();
+    StringBuffer logBuffer = _getLogBuffer(context, true);
+    logBuffer.append("-------------- ").append(startString).append(" ----------\n");
+    _logIdString(context);    
   }
 
+  
   /**
-   * Method to help with debugging, should only be called when 
-   * debugTokenCache() is true
+   * get the string from the log buffer.
+   * 
+   * This method should only be called when debugTokenCache() is true
    */
-  public static void logIdString()
+  public static String getLogString()
   {
     if (!_DEBUG_TOKEN_CACHE)
       throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
     
+    FacesContext context = FacesContext.getCurrentInstance();
+    return _getLogBuffer(context).toString();
+  }  
+
+  private static StringBuffer _getLogBuffer(FacesContext context)
+  { 
+    return _getLogBuffer(context, false);
+  }
+  
+  private static StringBuffer _getLogBuffer(FacesContext context, boolean startNewBuffer)
+  { 
+    Map<String, Object> requestMap = context.getExternalContext().getRequestMap();   
+    
+    StringBuffer buff = null;
+    
+    if (!startNewBuffer)
+    { 
+      buff = (StringBuffer)requestMap.get(_STRINGBUFFER_KEY);
+    }
     
-    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();    
+    if ( buff == null)
+    {
+      buff = new StringBuffer();
+      requestMap.put(_STRINGBUFFER_KEY, buff);
+    }
+    
+    return buff;
+  }  
+
+  /**
+   */
+  private static void _logIdString(FacesContext context)
+  {   
+    ExternalContext externalContext = context.getExternalContext();    
     String sessionId = "";
     Object session = externalContext.getSession(false);
     
@@ -181,85 +267,71 @@ public final class TokenCacheDebugUtils 
       sessionId = ((HttpSession)session).getId();
     }      
 
-    addToRequestStringBuffer("Session Id = " + sessionId);
+    StringBuffer buff = _getLogBuffer(context);
+    buff.append("Session Id = ").append(sessionId);
     
     WindowManager wm = RequestContext.getCurrentInstance().getWindowManager();
-    String windowId = wm.getCurrentWindow(externalContext).getId();
-    addToRequestStringBuffer("\nWindow Id = " + windowId );    
+    if (wm != null)
+    {
+      Window window = wm.getCurrentWindow(externalContext);
+      
+      if (window != null)
+      {
+        buff.append("\nWindow Id = ").append(window.getId());   
+      }
+      else
+      {
+        buff.append("\nWindow Id could not be determined, window is null" ); 
+      }
+        
+    }
+    else
+    {
+      buff.append("\nWindow Id could not be determined, window manager null" ); 
+    }
   }  
-
-  /**
-   * Method to help with debugging, should only be called when 
-   * debugTokenCache() is true
-   */
-  public static void addToRequestStringBuffer(String addString)
-  {     
-    if (!_DEBUG_TOKEN_CACHE)
-      throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
-    
-    _getRequestStringBuffer().append(addString);
-  }
   
 
   /**
-   * Method to help with debugging, should only be called when 
-   * debugTokenCache() is true
    */
-  public static void clearRequestStringBuffer()
-  {
-    if (!_DEBUG_TOKEN_CACHE)
-      throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
-    
-    Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap(); 
-    requestMap.put("org.apache.myfaces.trinidadinternal.DEBUG_TOKEN_CACHE.StringBuffer", null);
-  }
-  
-  /**
-   * Method to help with debugging, should only be called when 
-   * debugTokenCache() is true
-   */
-  public static String getRequestString()
-  {
-    if (!_DEBUG_TOKEN_CACHE)
-      throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
-    
-    return _getRequestStringBuffer().toString();
-  }  
-
-  private static StringBuffer _getRequestStringBuffer()
+  private static Map<String,String> _getTokenToViewIdMap(FacesContext context)
   {    
-    if (!_DEBUG_TOKEN_CACHE)
-      throw new UnsupportedOperationException(_UNSUPPORTED_OPERATION_MESSAGE);
-    
-    Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();   
-    StringBuffer buff = (StringBuffer)requestMap.get("org.apache.myfaces.trinidadinternal.DEBUG_TOKEN_CACHE.StringBuffer");
+    Map<String,String> tokenToViewId = (Map<String, String>)context.getExternalContext().getSessionMap().get("org.apache.myfaces.trinidadinternal.util.TOKEN_FOR_VIEW_ID");
     
-    if ( buff == null)
+    if (tokenToViewId == null) 
     {
-      buff = new StringBuffer();
-      requestMap.put("org.apache.myfaces.trinidadinternal.DEBUG_TOKEN_CACHE.StringBuffer", buff);
+      tokenToViewId = new ConcurrentHashMap<String, String>();
+      context.getExternalContext().getSessionMap().put("org.apache.myfaces.trinidadinternal.util.TOKEN_FOR_VIEW_ID", tokenToViewId);
+      
     }
-    
-    return buff;
+    return tokenToViewId;
   }  
+
+
+  /**
+   */
+  private static String _getTokenToViewIdString(Map<String,String> tokenToViewId, String token)
+  {      
+    StringBuffer tokenBuffer = new StringBuffer();
+    tokenBuffer.append(token);
+    tokenBuffer.append(" (");
+    tokenBuffer.append(tokenToViewId.get(token));
+    tokenBuffer.append(")");
+    
+    return tokenBuffer.toString();
+  }
   
   private static final String _UNSUPPORTED_OPERATION_MESSAGE =  
            "Methods in TokenCacheDebugUtils can only be called when " +
            "TokenCacheDebugUtils.debugTokenCache() returns true. " + 
            "TokenCacheDebugUtils.debugTokenCache() returns true when the system property " +
            "'org.apache.myfaces.trinidadinternal.DEBUG_TOKEN_CACHE' is true";
+
+
+  private static final String _STRINGBUFFER_KEY = TokenCacheDebugUtils.class.getName() + "#StringBuffer";
     
-  // ViewExpiredExceptions are fairly common, and the token cache is used for 
-  // page state tokens, but the tokens aren't really human readable. 
-  // In order to make it easier to understand what is in the cache
-  // we've added a system property for debugging purposes. When enabled
-  // we store a map of token -> viewId on the session which we use
-  // to log something more human readable.
-  // 
-  // in order to use this the tester would set the system property to:
-  // -Dorg.apache.myfaces.trinidadinternal.DEBUG_TOKEN_CACHE=true
 
-  static private final Boolean _DEBUG_TOKEN_CACHE;
+  static private final boolean _DEBUG_TOKEN_CACHE;
   static
   {
     String dtcProp = System.getProperty("org.apache.myfaces.trinidadinternal.DEBUG_TOKEN_CACHE");