diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPartialViewContext.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPartialViewContext.java index ba7f7f2a..bc0ff70e 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPartialViewContext.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowPartialViewContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2011 the original author or authors. + * Copyright 2004-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package org.springframework.faces.webflow; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -55,7 +56,7 @@ public class FlowPartialViewContext extends PartialViewContextWrapper { RequestContext requestContext = RequestContextHolder.getRequestContext(); String[] fragmentIds = (String[]) requestContext.getFlashScope().get(View.RENDER_FRAGMENTS_ATTRIBUTE); if (fragmentIds != null && fragmentIds.length > 0) { - return Arrays.asList(fragmentIds); + return new ArrayList(Arrays.asList(fragmentIds)); } } return getWrapped().getRenderIds(); diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowPartialViewContextTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowPartialViewContextTests.java index a31185ff..e8102221 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowPartialViewContextTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowPartialViewContextTests.java @@ -16,6 +16,7 @@ import org.springframework.webflow.test.MockRequestContext; public class FlowPartialViewContextTests extends TestCase { + @SuppressWarnings("unchecked") public void testReturnFragmentIds() throws Exception { String[] fragmentIds = new String[] { "foo", "bar" }; @@ -46,4 +47,18 @@ public class FlowPartialViewContextTests extends TestCase { assertEquals(renderIds, context.getRenderIds()); } + @SuppressWarnings("unchecked") + public void testReturnFragmentIdsMutable() throws Exception { + String[] fragmentIds = new String[] { "foo", "bar" }; + + RequestContext requestContext = new MockRequestContext(); + requestContext.getFlashScope().asMap().put(View.RENDER_FRAGMENTS_ATTRIBUTE, fragmentIds); + RequestContextHolder.setRequestContext(requestContext); + + Collection renderIds = new FlowPartialViewContext(null).getRenderIds(); + renderIds.add("baz"); + + assertEquals(Arrays.asList("foo", "bar", "baz"), renderIds); + } + } \ No newline at end of file