Velocity
  1. Velocity
  2. VELOCITY-642

Array arguments in method calls are wrapped with an extra array

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6-beta1
    • Fix Version/s: 1.6
    • Component/s: Engine
    • Labels:
      None

      Description

      Velocity 1.6 b2 wraps array arguments of method calls with an extra array causing the calls to fail and making this version incompatible with previous versions.

      A simple template, like this, demonstrates the behavior:

      #set ($_array = [ 1, 2, 3 ])
      $test.arrayTest($_array.toArray())

      Depending on the signature of test.arrayTest() , the template prints:

      public String arrayTest(Object[] array)
      {
      return java.util.Arrays.deepToString((Object[]) array);
      }

      [[1, 2, 3]]

      public String arrayTest(Object... array)
      {
      return java.util.Arrays.deepToString(array);
      }

      [[1, 2, 3]]

      public String arrayTest(Object array)
      {
      return java.util.Arrays.deepToString((Object[]) array);
      }

      [1, 2, 3]

      Actually, I noticed later that the argument doesn't have to be an array, this version of Velocity seems to wrap any argument into an array if the method expects an array. So maybe this is a feature and not a bug, but it should detect already correct array arguments and leave them intact to keep existing templates working.

      – Ilkka

        Activity

        Ilkka Priha created issue -
        Hide
        Nathan Bubna added a comment -

        Yeah, this was a bug in the new vararg support. It was a case overlooked in the unit tests, but very easily fixed. I'll post a new 1.6-dev build with the fix in it in a few minutes. That'll be here:

        http://people.apache.org/~nbubna/velocity/engine/1.6-dev/

        Thanks for catching this, Ilkka!

        Show
        Nathan Bubna added a comment - Yeah, this was a bug in the new vararg support. It was a case overlooked in the unit tests, but very easily fixed. I'll post a new 1.6-dev build with the fix in it in a few minutes. That'll be here: http://people.apache.org/~nbubna/velocity/engine/1.6-dev/ Thanks for catching this, Ilkka!
        Nathan Bubna made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.6 [ 12310290 ]
        Mark Thomas made changes -
        Workflow jira [ 12445684 ] Default workflow, editable Closed status [ 12551538 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12551538 ] jira [ 12552424 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        1h 26m 1 Nathan Bubna 05/Nov/08 21:31

          People

          • Assignee:
            Unassigned
            Reporter:
            Ilkka Priha
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development