Velocity
  1. Velocity
  2. VELOCITY-629

Error message for set directive reports wrong line number

    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

      Given the following template:

        1. ##
          #set($list = [1])
          #set($x = "$list.get(1)")

      The MethodInvocationException that report this error reads:

      Invocation of method 'get' in class java.util.ArrayList threw exception java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at /foo.vm[line 1, column 7]

      Which contains an incorrect line number.

      1. fix629_3.patch
        7 kB
        Byron Foster
      2. Velocity629TestCase.java
        2 kB
        Nathan Bubna

        Activity

        Hide
        Nathan Bubna added a comment -

        Hmm. It's not #set that's the issue, i think. That line/col is relative to the start of the string literal. So, the MIE message creator doesn't realize that it was inside of a string literal at the time.

        Show
        Nathan Bubna added a comment - Hmm. It's not #set that's the issue, i think. That line/col is relative to the start of the string literal. So, the MIE message creator doesn't realize that it was inside of a string literal at the time.
        Hide
        Byron Foster added a comment -

        Here is a swipe at it, This patch goes through the tokens of the string literal and adjusts column and line numbers.

        Show
        Byron Foster added a comment - Here is a swipe at it, This patch goes through the tokens of the string literal and adjusts column and line numbers.
        Hide
        Byron Foster added a comment -

        Oops, forgot comments on the last patch

        Show
        Byron Foster added a comment - Oops, forgot comments on the last patch
        Hide
        Nathan Bubna added a comment -

        Unfortunately, the patch doesn't account for multi-line string literals. Here's an updated version of your test to show that.

        Show
        Nathan Bubna added a comment - Unfortunately, the patch doesn't account for multi-line string literals. Here's an updated version of your test to show that.
        Hide
        Byron Foster added a comment -

        Doh! thanks for supplying the improved TestCase.

        I also snuck in an improvement to the exception message for VELOCITY-627 so that the reported column number is on the offending #foreach parameter. and updated the 627 test case.

        Show
        Byron Foster added a comment - Doh! thanks for supplying the improved TestCase. I also snuck in an improvement to the exception message for VELOCITY-627 so that the reported column number is on the offending #foreach parameter. and updated the 627 test case.

          People

          • Assignee:
            Unassigned
            Reporter:
            Byron Foster
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development