Velocity
  1. Velocity
  2. VELOCITY-658

$velocityHasNext does not work in nested loops

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6, 1.6.1
    • Fix Version/s: 1.7
    • Component/s: Engine
    • Labels:
      None

      Description

      With this test case:

      assertEvalEquals("test1 (a1;a2;a3)-test2 (a1;a2;a3)-test3 (a1;a2;a3)-test4 (a1;a2;a3)",
      "#foreach ($value in $list)$value (#foreach ($val in $list2)$val#if( $velocityHasNext );#end#end)#if( $velocityHasNext )-#end#end");

      Velocity 1.6.1 (or current head) fails because the "hasNext" flag status of the outer foreach loop gets overwritten by the nested foreach loop. To fix this we need to save the status of the hasNext flag in Foreach directive just like we save the value of the counter.

      This bug is related to VELOCITY-657 but is a separate bug.

        Issue Links

          Activity

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          19h 58m 1 Jarkko Viinamäki 28/Dec/08 18:51
          Resolved Resolved Reopened Reopened
          1m 21s 1 Jarkko Viinamäki 28/Dec/08 18:52
          Reopened Reopened Resolved Resolved
          11s 1 Jarkko Viinamäki 28/Dec/08 18:53
          Mark Thomas made changes -
          Workflow Default workflow, editable Closed status [ 12551662 ] jira [ 12552538 ]
          Mark Thomas made changes -
          Workflow jira [ 12449166 ] Default workflow, editable Closed status [ 12551662 ]
          Jarkko Viinamäki made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Fix Version/s 1.7 [ 12313453 ]
          Jarkko Viinamäki made changes -
          Status Resolved [ 5 ] Reopened [ 4 ]
          Resolution Fixed [ 1 ]
          Jarkko Viinamäki made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Hide
          Jarkko Viinamäki added a comment -

          Thanks. Marking this as resolved.

          Show
          Jarkko Viinamäki added a comment - Thanks. Marking this as resolved.
          Hide
          Byron Foster added a comment -

          Applied, thanks

          Show
          Byron Foster added a comment - Applied, thanks
          Jarkko Viinamäki made changes -
          Link This issue is related to VELOCITY-657 [ VELOCITY-657 ]
          Jarkko Viinamäki made changes -
          Link This issue is related to VELOCITY-600 [ VELOCITY-600 ]
          Jarkko Viinamäki made changes -
          Field Original Value New Value
          Attachment velocity-hasNext-bug.patch [ 12396805 ]
          Hide
          Jarkko Viinamäki added a comment -

          Testcase and a patch that fixes this bug.

          Show
          Jarkko Viinamäki added a comment - Testcase and a patch that fixes this bug.
          Jarkko Viinamäki created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              Jarkko Viinamäki
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development