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/30 20:58:11 UTC

svn commit: r1163333 - /myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java

Author: gcrawford
Date: Tue Aug 30 18:58:11 2011
New Revision: 1163333

URL: http://svn.apache.org/viewvc?rev=1163333&view=rev
Log:
TRINIDAD-2134 NullPointerException in StateManagerImpl._calculateTokenStateSaving

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

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java?rev=1163333&r1=1163332&r2=1163333&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java Tue Aug 30 18:58:11 2011
@@ -1000,13 +1000,20 @@ public class StateManagerImpl extends St
       return false;
     }
 
-    // is vanilla JSF used? No Trinidad render-kit-id give? If so, we need to return FALSE,
-    // since we want to save the ENTIRE state on the client...
-    UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
-
-    if (viewRoot != null && RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(viewRoot.getRenderKitId()))
-    {
-      return false;
+    // In certain situations this method is called from a filter and there's no facesContext, so 
+    // make sure to check for a null context
+    FacesContext context = FacesContext.getCurrentInstance();
+
+    if (context != null)
+    {
+      // is vanilla JSF used? No Trinidad render-kit-id give? If so, we need to return FALSE,
+      // since we want to save the ENTIRE state on the client...
+      UIViewRoot viewRoot = context.getViewRoot();
+      
+      if (viewRoot != null && RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(viewRoot.getRenderKitId()))
+      {
+        return false;
+      }
     }
 
     // Last missing option: state-saving is "CLIENT" and the client-state-method uses