<< ADD DESCRIPTION HERE http://java.net/jira/browse/JAVASERVERFACES-XXXX >> SECTION: Modified Files ---------------------------- M jsf-ri/src/main/java/com/sun/faces/renderkit/ServerSideStateHelper.java M test/servlet30/pom.xml A test/servlet30/stateSaving A test/servlet30/stateSaving/pom.xml A test/servlet30/stateSaving/viewExpiredException A test/servlet30/stateSaving/viewExpiredException/nbactions.xml A test/servlet30/stateSaving/viewExpiredException/pom.xml A test/servlet30/stateSaving/viewExpiredException/src A test/servlet30/stateSaving/viewExpiredException/src/main A test/servlet30/stateSaving/viewExpiredException/src/main/webapp A test/servlet30/stateSaving/viewExpiredException/src/main/webapp/WEB-INF A test/servlet30/stateSaving/viewExpiredException/src/main/webapp/WEB-INF/web.xml A test/servlet30/stateSaving/viewExpiredException/src/main/webapp/index.xhtml A test/servlet30/stateSaving/viewExpiredException/src/main/webapp/page2.xhtml A test/servlet30/stateSaving/viewExpiredException/src/test A test/servlet30/stateSaving/viewExpiredException/src/test/java A test/servlet30/stateSaving/viewExpiredException/src/test/java/com A test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun A test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun/faces A test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun/faces/test A test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun/faces/test/servlet30 A test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun/faces/test/servlet30/statesaving A test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun/faces/test/servlet30/statesaving/viewexpiredexception A test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun/faces/test/servlet30/statesaving/viewexpiredexception/Issue3359IT.java SECTION: Diffs ---------------------------- Index: jsf-ri/src/main/java/com/sun/faces/renderkit/ServerSideStateHelper.java =================================================================== --- jsf-ri/src/main/java/com/sun/faces/renderkit/ServerSideStateHelper.java (revision 13567) +++ jsf-ri/src/main/java/com/sun/faces/renderkit/ServerSideStateHelper.java (working copy) @@ -335,13 +335,13 @@ RequestStateManager.set(ctx, RequestStateManager.LOGICAL_VIEW_MAP, idInLogicalMap); + + Object[] restoredState = new Object[2]; Object[] state = (Object[]) actualMap.get(idInActualMap); - Object[] restoredState = new Object[2]; - - restoredState[0] = state[0]; - restoredState[1] = state[1]; - if(state != null){ + restoredState[0] = state[0]; + restoredState[1] = state[1]; + RequestStateManager.set(ctx, RequestStateManager.ACTUAL_VIEW_MAP, idInActualMap); Index: test/servlet30/pom.xml =================================================================== --- test/servlet30/pom.xml (revision 13567) +++ test/servlet30/pom.xml (working copy) @@ -74,5 +74,6 @@ multi-tenant navigation systest + stateSaving Index: test/servlet30/stateSaving/pom.xml =================================================================== --- test/servlet30/stateSaving/pom.xml (revision 0) +++ test/servlet30/stateSaving/pom.xml (working copy) @@ -0,0 +1,59 @@ + + + + + + 4.0.0 + + com.sun.faces.test.servlet30 + pom + 2.2.9-SNAPSHOT + + com.sun.faces.test.servlet30.statesaving + pom + pom + Mojarra ${project.version} - Test - Servlet 3.0 - State Saving + + viewExpiredException + + Index: test/servlet30/stateSaving/viewExpiredException/nbactions.xml =================================================================== --- test/servlet30/stateSaving/viewExpiredException/nbactions.xml (revision 0) +++ test/servlet30/stateSaving/viewExpiredException/nbactions.xml (working copy) @@ -0,0 +1,163 @@ + + + + debug.test.single + + test-compile + surefire:test + + + viewexpiredexception + once + -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} + true + true + test-viewexpiredexception + Development + client + 8080 + localhost + http://localhost:8080/test-viewexpiredexception/ + false + + + + test.single + + test-compile + surefire:test + + + test-viewexpiredexception + 8080 + localhost + http://localhost:8080/test-viewexpiredexception/ + viewexpiredexception + + + + build + + install + + + Development + false + true + client + + + + rebuild + + clean + install + + + + false + + Development + + true + + client + + + + + build-with-dependencies + also-make + + install + + + false + client + true + Development + + + + run + + package + + + false + true + true + client + Development + + + + run.single.deploy + + package + + + false + true + true + ${webpagePath} + client + Development + + + + debug.single.deploy + + package + + + false + true + true + true + ${webpagePath} + client + Development + + + Index: test/servlet30/stateSaving/viewExpiredException/pom.xml =================================================================== --- test/servlet30/stateSaving/viewExpiredException/pom.xml (revision 0) +++ test/servlet30/stateSaving/viewExpiredException/pom.xml (working copy) @@ -0,0 +1,59 @@ + + + + + 4.0.0 + + com.sun.faces.test.servlet30.statesaving + pom + 2.2.9-SNAPSHOT + + com.sun.faces.test.servlet30.statesaving + viewexpiredexception + 2.2.9-SNAPSHOT + war + Mojarra ${project.version} - Test - Servlet 3.0 - State Saving - ViewExpireException + + + test-servlet30-statesaving-viewexpiredexception + + Index: test/servlet30/stateSaving/viewExpiredException/src/main/webapp/WEB-INF/web.xml =================================================================== --- test/servlet30/stateSaving/viewExpiredException/src/main/webapp/WEB-INF/web.xml (revision 0) +++ test/servlet30/stateSaving/viewExpiredException/src/main/webapp/WEB-INF/web.xml (working copy) @@ -0,0 +1,82 @@ + + + + + + javax.faces.PROJECT_STAGE + ${webapp.projectStage} + + + javax.faces.PARTIAL_STATE_SAVING + ${webapp.partialStateSaving} + + + javax.faces.STATE_SAVING_METHOD + ${webapp.stateSavingMethod} + + + com.sun.faces.numberOfViewsInSession + 1 + + + com.sun.faces.numberOfLogicalViews + 1 + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + + 30 + + + + Faces Servlet + *.xhtml + + + index.xhtml + + Index: test/servlet30/stateSaving/viewExpiredException/src/main/webapp/index.xhtml =================================================================== --- test/servlet30/stateSaving/viewExpiredException/src/main/webapp/index.xhtml (revision 0) +++ test/servlet30/stateSaving/viewExpiredException/src/main/webapp/index.xhtml (working copy) @@ -0,0 +1,57 @@ + + + + + + + JAVASERVERFACES-3359-reproducer + + + + + + + + + Index: test/servlet30/stateSaving/viewExpiredException/src/main/webapp/page2.xhtml =================================================================== --- test/servlet30/stateSaving/viewExpiredException/src/main/webapp/page2.xhtml (revision 0) +++ test/servlet30/stateSaving/viewExpiredException/src/main/webapp/page2.xhtml (working copy) @@ -0,0 +1,16 @@ + + + + + JAVASERVERFACES-3359-reproducer + + + Go back to the index page + + This form is required for the NPE to occur
+ + +
+
+ Index: test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun/faces/test/servlet30/statesaving/viewexpiredexception/Issue3359IT.java =================================================================== --- test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun/faces/test/servlet30/statesaving/viewexpiredexception/Issue3359IT.java (revision 0) +++ test/servlet30/stateSaving/viewExpiredException/src/test/java/com/sun/faces/test/servlet30/statesaving/viewexpiredexception/Issue3359IT.java (working copy) @@ -0,0 +1,95 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package com.sun.faces.test.servlet30.statesaving.viewexpiredexception; + +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.gargoylesoftware.htmlunit.html.HtmlHiddenInput; +import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput; +import com.gargoylesoftware.htmlunit.html.HtmlAnchor; +import com.gargoylesoftware.htmlunit.html.HtmlInput; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.assertTrue; + +public class Issue3359IT { + private String webUrl; + private WebClient webClient; + + @Before + public void setUp() { + webUrl = System.getProperty("integration.url"); + webClient = new WebClient(); + webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); + } + + @After + public void tearDown() { + webClient.closeAllWindows(); + } + + @Test + public void testIssue3359Fixed() throws Exception { + HtmlPage page = webClient.getPage(webUrl); + + String savingMethod = ((HtmlInput)page.getElementById("helloForm:stateSavingMethod")).getValueAttribute(); + String origStateId = ((HtmlHiddenInput)page.getElementByName("javax.faces.ViewState")).getValueAttribute(); + + HtmlSubmitInput button = (HtmlSubmitInput) page.getElementById("helloForm:button"); + page = button.click(); + + HtmlAnchor anchor = (HtmlAnchor)page.getElementById("link"); + page = anchor.click(); + + button = (HtmlSubmitInput) page.getElementById("helloForm:button"); + HtmlHiddenInput hi = (HtmlHiddenInput)(page.getElementByName("javax.faces.ViewState")); + hi.setValueAttribute(origStateId); + page = button.click(); + + if ( "client".equalsIgnoreCase( savingMethod ) ) { + assertTrue(page.asXml().indexOf("Go back to the index page") != -1); + } else { + assertTrue(page.asXml().indexOf("ViewExpiredException") != -1); + } + } + +} SECTION: New Files ---------------------------- SEE ATTACHMENTS