myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1409453 - in /myfaces/core/branches/2.0.x/impl/src: main/java/org/apache/myfaces/renderkit/ main/java/org/apache/myfaces/view/jsp/ test/java/org/apache/myfaces/renderkit/
Date Wed, 14 Nov 2012 21:53:58 GMT
Author: lu4242
Date: Wed Nov 14 21:53:57 2012
New Revision: 1409453

URL: http://svn.apache.org/viewvc?rev=1409453&view=rev
Log:
MYFACES-3638 NPE in ServerSideStateCacheImpl (include alternate fix in 2.0.x branch)

Modified:
    myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
    myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java
    myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/ServerSideStateCacheTest.java

Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java?rev=1409453&r1=1409452&r2=1409453&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
(original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
Wed Nov 14 21:53:57 2012
@@ -1410,7 +1410,7 @@ class ServerSideStateCacheImpl extends S
         {
             if (context.isProjectStage(ProjectStage.Production))
             {
-                return new IntIntSerializedViewKey(viewId.hashCode(), key);
+                return new IntIntSerializedViewKey(viewId == null ? 0 : viewId.hashCode(),
key);
             }
             else
             {
@@ -1440,7 +1440,7 @@ class ServerSideStateCacheImpl extends S
         {
             if (context.isProjectStage(ProjectStage.Production))
             {
-                return new IntByteArraySerializedViewKey(viewId.hashCode(), key);
+                return new IntByteArraySerializedViewKey(viewId == null ? 0 : viewId.hashCode(),
key);
             }
             else
             {

Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java?rev=1409453&r1=1409452&r2=1409453&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java
(original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java
Wed Nov 14 21:53:57 2012
@@ -176,6 +176,7 @@ public class JspViewDeclarationLanguage 
         if (errorResponse)
         {
             wrappedResponse.flushToWrappedResponse();
+            context.responseComplete();
             return;
         }
 
@@ -202,7 +203,8 @@ public class JspViewDeclarationLanguage 
         ResponseStateManager responseStateManager = context.getRenderKit().getResponseStateManager();
         if (StateCacheUtils.isMyFacesResponseStateManager(responseStateManager))
         {
-            if (StateCacheUtils.getMyFacesResponseStateManager(responseStateManager).isWriteStateAfterRenderViewRequired(context))
+            if (StateCacheUtils.getMyFacesResponseStateManager(responseStateManager).
+                    isWriteStateAfterRenderViewRequired(context))
             {
                 return false;
             }

Modified: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/ServerSideStateCacheTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/ServerSideStateCacheTest.java?rev=1409453&r1=1409452&r2=1409453&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/ServerSideStateCacheTest.java
(original)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/renderkit/ServerSideStateCacheTest.java
Wed Nov 14 21:53:57 2012
@@ -28,7 +28,6 @@ import javax.faces.application.StateMana
 
 import org.apache.myfaces.application.StateCache;
 import org.apache.myfaces.test.base.junit4.AbstractJsfConfigurableMultipleRequestsTestCase;
-import org.apache.myfaces.view.facelets.tag.composite.CompositeResouceWrapper;
 import org.junit.Test;
 import org.testng.Assert;
 
@@ -38,7 +37,6 @@ public class ServerSideStateCacheTest ex
     @Test
     public void testNumberOfSequentialViewsInSession() throws Exception
     {
-        
         servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.STATE_SAVING_METHOD_SERVER);
         servletContext.addInitParameter("org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION",
"5");
         servletContext.addInitParameter("org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION",
"2");
@@ -169,7 +167,36 @@ public class ServerSideStateCacheTest ex
         }
         
     }
-    
+
+    @Test
+    public void testNonExistingViewId() throws Exception
+    {
+        servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.STATE_SAVING_METHOD_SERVER);
+        servletContext.addInitParameter("org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION",
"5");
+        servletContext.addInitParameter("org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION",
"2");
+
+        // this issue only happens in projectstage Production
+        servletContext.addInitParameter("faces.PROJECT_STAGE", "Production");
+
+        try
+        {
+            // Initialization
+            setupRequest();
+
+            // we need to take a viewId which is null -> not existing.
+            facesContext.getViewRoot().setViewId(null);
+
+            StateCache stateCache = new ServerSideStateCacheImpl();
+            Object savedToken = stateCache.saveSerializedView(facesContext, 1);
+
+        }
+        finally
+        {
+            tearDownRequest();
+        }
+
+    }
+
     public void tryStateKeySerialization() throws Exception
     {
         // Initialization



Mime
View raw message