Minor fix in FlowPartialViewContext
The fix ensures that getRenderIds returns a mutable collection as stated in the contract for the method in PartialViewContext. Issues: SWF-1480
This commit is contained in:
@@ -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<String>(Arrays.asList(fragmentIds));
|
||||
}
|
||||
}
|
||||
return getWrapped().getRenderIds();
|
||||
|
||||
@@ -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<String> renderIds = new FlowPartialViewContext(null).getRenderIds();
|
||||
renderIds.add("baz");
|
||||
|
||||
assertEquals(Arrays.asList("foo", "bar", "baz"), renderIds);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user