You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:29:51 UTC

[myfaces-trinidad] 07/33: TRINIDAD-2134 NullPointerException in StateManagerImpl._calculateTokenStateSaving

This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 2.0.0.x-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit f861a563201a39f2f18ffd49d0de9df4049b6f17
Author: Scott Bryan <so...@apache.org>
AuthorDate: Tue May 8 23:27:39 2012 +0000

    TRINIDAD-2134 NullPointerException in StateManagerImpl._calculateTokenStateSaving
---
 .../trinidadinternal/application/StateManagerImpl.java  | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
index cb30296..17deb6d 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
@@ -967,13 +967,20 @@ public class StateManagerImpl extends StateManagerWrapper
       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();
+    // 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 (viewRoot != null && RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(viewRoot.getRenderKitId()))
+    if (context != null)
     {
-      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 = 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

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.