From 1c67a0dc08b78a780f12250287836a97bfdec095 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 20 May 2014 16:19:14 -0400 Subject: [PATCH] Revert "Prevent NPE in Mojarra when creating initial view" This reverts commit d31900e5f961828791c1e65095c3df698b327db4. The fix for SWF-1571 reported against Mojarra 2.1.8 seems to be problematic when Web Flow's ResponseStateManager is not used as reported in SWF-1630. Testing with Mojarra 2.1.20 I can no longer reproduce SWF-1571 and originally it was suspected to be a Mojarra issue. Hence this revert. Issue: SWF-1571, SWF-1630 --- .../faces/webflow/FlowResponseStateManager.java | 9 --------- .../springframework/faces/webflow/JsfViewFactory.java | 8 +------- .../faces/webflow/JsfViewFactoryTests.java | 11 ----------- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResponseStateManager.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResponseStateManager.java index 5fbacbb7..736a8065 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResponseStateManager.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowResponseStateManager.java @@ -142,13 +142,4 @@ public class FlowResponseStateManager extends ResponseStateManagerWrapper { writer.endElement("input"); } } - - /** - * Determine if the request context has existing state. - * @param context the request context - * @return {@code true} if the context has state - */ - static boolean hasState(RequestContext context) { - return (context != null) && (context.getViewScope().contains(FACES_VIEW_STATE)); - } } diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactory.java b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactory.java index a780cac9..82eba121 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactory.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/JsfViewFactory.java @@ -132,12 +132,7 @@ public class JsfViewFactory implements ViewFactory { private UIViewRoot getViewStateViewRoot(RequestContext context, FacesContext facesContext, ViewHandler viewHandler, String viewName) { - UIViewRoot viewRoot = null; - if (FlowResponseStateManager.hasState(context)) { - // Only try an initial restore if we have state (see SWF-1571) - viewRoot = viewHandler.restoreView(facesContext, viewName); - } - + UIViewRoot viewRoot = viewHandler.restoreView(facesContext, viewName); if (viewRoot != null) { if (logger.isDebugEnabled()) { logger.debug("UIViewRoot restored for '" + viewName + "'"); @@ -149,7 +144,6 @@ public class JsfViewFactory implements ViewFactory { } viewRoot = viewHandler.createView(facesContext, viewName); } - return viewRoot; } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewFactoryTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewFactoryTests.java index 463d5e14..e13bdca8 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewFactoryTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/JsfViewFactoryTests.java @@ -72,15 +72,12 @@ public class JsfViewFactoryTests extends TestCase { private final MockHttpServletResponse response = new MockHttpServletResponse(); - private LocalAttributeMap viewScope = new LocalAttributeMap(); - protected void setUp() throws Exception { configureJsf(); this.extContext.setNativeContext(this.servletContext); this.extContext.setNativeRequest(this.request); this.extContext.setNativeResponse(this.response); RequestContextHolder.setRequestContext(this.context); - EasyMock.expect(this.context.getViewScope()).andStubReturn(this.viewScope); EasyMock.expect(this.context.getFlashScope()).andStubReturn(this.flashMap); EasyMock.expect(this.context.getExternalContext()).andStubReturn(this.extContext); EasyMock.expect(this.context.getRequestParameters()).andStubReturn( @@ -151,7 +148,6 @@ public class JsfViewFactoryTests extends TestCase { EasyMock.expectLastCall().andReturn(true); EasyMock.replay(new Object[] { this.context }); - setupViewState(); View restoredView = this.factory.getView(this.context); @@ -198,7 +194,6 @@ public class JsfViewFactoryTests extends TestCase { EasyMock.expectLastCall().andReturn(true); EasyMock.replay(new Object[] { this.context }); - setupViewState(); View restoredView = this.factory.getView(this.context); @@ -234,7 +229,6 @@ public class JsfViewFactoryTests extends TestCase { EasyMock.expectLastCall().andReturn(true); EasyMock.replay(new Object[] { this.context }); - setupViewState(); View restoredView = this.factory.getView(this.context); @@ -285,7 +279,6 @@ public class JsfViewFactoryTests extends TestCase { this.context.inViewState(); EasyMock.expectLastCall().andReturn(true); - setupViewState(); EasyMock.replay(new Object[] { this.context }); this.factory.getView(this.context); @@ -296,10 +289,6 @@ public class JsfViewFactoryTests extends TestCase { .getExceptionQueuedEventContext().getException()); } - private void setupViewState() { - this.viewScope.put(FlowResponseStateManager.FACES_VIEW_STATE, "X"); - } - private class NoExecutionLifecycle extends FlowLifecycle { public NoExecutionLifecycle(Lifecycle delegate) {