myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sobr...@apache.org
Subject svn commit: r1335827 - /myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
Date Tue, 08 May 2012 23:27:39 GMT
Author: sobryan
Date: Tue May  8 23:27:39 2012
New Revision: 1335827

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

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

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java?rev=1335827&r1=1335826&r2=1335827&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
Tue May  8 23:27:39 2012
@@ -967,13 +967,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



Mime
View raw message