Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The FilterImpl.java class contains an in-memory representation of the filter configuration found in the portlet.xml descriptor. Here is an example from the TCK:
portlet.xml
<filter> <filter-name>AddlFilterTests_SPEC2_20_Filter1</filter-name> <filter-class>javax.portlet.tck.portlets.AddlFilterTests_SPEC2_20_Filter</filter-class> <lifecycle>ACTION_PHASE</lifecycle> <lifecycle>EVENT_PHASE</lifecycle> <lifecycle>RESOURCE_PHASE</lifecycle> <init-param> <name>tr2</name> <value>true</value> </init-param> <init-param> <name>tr3</name> <value>true</value> </init-param> </filter>
The following TCK test case assumes that the "tr2" and "tr3" init-params appear in the order in which they appear in the portlet.xml descriptor:
AddlFilterTests_SPEC2_20_Filter.java
/* TestCase: V2AddlFilterTests_SPEC2_20_Action_filter11 */ /* Details: "For multiple filter declarations for a single filter */ /* class, the filter instance must receive only initialization */ /* parameters defined in the filter declaration" */ if (portletNameAction != null && portletNameAction.equals("AddlFilterTests_SPEC2_20_Action") && filterName.equals("AddlFilterTests_SPEC2_20_Filter1")) { Enumeration<String> initParams = config.getInitParameterNames(); if (initParams.nextElement().equals("tr2") && initParams.nextElement().equals("tr3")) { ... } }
The problem is that FilterImpl.java defines the initParams as java.util.HashMap which does not guarantee order:
FilterImpl.java
public class FilterImpl implements Filter { ... private final Map<String, InitParam> initParams = new HashMap<String, InitParam>();
In order for this test case to pass on all operating systems and JVMs, the initParams variable should be java.util.LinkedHashMap.