Uploaded image for project: 'Velocity Tools'
  1. Velocity Tools
  2. VELTOOLS-148

LinkTool.addAllParameters causes "ignored" parameters to pollute parent link objects

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.x
    • Component/s: VelocityView
    • Labels:
      None
    • Environment:
      Velocity 1.7, Velocity-Tools 2.0

      Description

      The following code will not perform as expected with $link represents an instance of view.tools.LinkTool:

      #set($forward = $link.setRelative('/foo').addQueryData('bar', 'baz'))
      one = $forward.addAllParameters()<br />
      two = $forward.addAllParameters()<br />

      The "addQueryData" appears to be required in order to make this fail.

      The addAllParameters method calls view.LinkTool.addRequestParamsExcept which calls view.LinkTool.addRequestParams which calls generic.LinkTool.duplicate() in order to duplicate the LinkTool before calling view.tools.setParam repeatedly on it.

      generic.LinkTool.duplicate clones the LinkTool object including the view.tools.LinkTool's reference to the "parametersToIgnore" field. The "child" instances of this LinkTool will then have their "ignores" list bleed-into the parent (and also other siblings) and the ultimate effect is that LinkTool objects derived from that common root will be unable to call addAllParameters() because all parameters will have been added to that ignores list after the first invocation.

      The obvious solution seems to be that view.tools.LinkTool needs to override the duplicate(boolean) method in order to clone the ignores list.

        Activity

        Hide
        chris@christopherschultz.net Christopher Schultz added a comment -

        Fixed in r1151642:

        New view.tools.LinkTool.duplicate(boolean) method.
        New unit test.

        Show
        chris@christopherschultz.net Christopher Schultz added a comment - Fixed in r1151642: New view.tools.LinkTool.duplicate(boolean) method. New unit test.

          People

          • Assignee:
            Unassigned
            Reporter:
            chris@christopherschultz.net Christopher Schultz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development