Uploaded image for project: 'Pluto'
  1. Pluto
  2. PLUTO-654

The initParams variable in FilterImpl.java does not preserve the order in which init-params are added

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0
    • portlet container
    • 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.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            ngriffin7a Neil Griffin (Inactive)
            ngriffin7a Neil Griffin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment