Neil Griffin created PLUTO-654:
----------------------------------

             Summary: The initParams variable in FilterImpl.java does not 
preserve the order in which init-params are added
                 Key: PLUTO-654
                 URL: https://issues.apache.org/jira/browse/PLUTO-654
             Project: Pluto
          Issue Type: Bug
          Components: portlet container
            Reporter: Neil Griffin
            Assignee: Neil Griffin
             Fix For: 3.0.0


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:

{code:xml|title=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>
{code}

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:

{code:java|title=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")) {
        ...
    }
}
{code}

The problem is that FilterImpl.java defines the initParams as java.util.HashMap 
which does not guarantee order:
{code:java|title=FilterImpl.java}
public class FilterImpl implements Filter {
    ...
    private final Map<String, InitParam> initParams = new HashMap<String, 
InitParam>();
{code}

In order for this test case to pass on all operating systems and JVMs, the 
initParams variable should be java.util.LinkedHashMap.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to