Velocity
  1. Velocity
  2. VELOCITY-728

NullPointerException occurs when #parse() without parameter

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.2
    • Fix Version/s: 1.7
    • Component/s: Engine
    • Labels:
      None

      Description

      Execute this template code

      #parse()

      The exception occurs
      Caused by: java.lang.NullPointerException
      at org.apache.velocity.runtime.parser.node.SimpleNode.jjtGetChild(SimpleNode.java:177)
      at org.apache.velocity.runtime.directive.Parse.render(Parse.java:131)
      at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
      at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
      at org.apache.velocity.runtime.RuntimeInstance.render(RuntimeInstance.java:1277)
      at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1216)
      at org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:294)
      ... 6 more

      1. velocity-728.patch
        3 kB
        Jarkko Viinamäki

        Activity

        Hide
        Nathan Bubna added a comment -

        Just to make sure you know, you can't use #parse without an argument identifying which file you wish to parse.

        What were you hoping/expecting to happen? A better error message? That's a fine idea, but that hardly qualifies as a "Major" bug.

        Show
        Nathan Bubna added a comment - Just to make sure you know, you can't use #parse without an argument identifying which file you wish to parse. What were you hoping/expecting to happen? A better error message? That's a fine idea, but that hardly qualifies as a "Major" bug.
        Hide
        Siri C. added a comment -

        Yes, please improve an error message.
        Because we can't find a position of error on template code.

        Show
        Siri C. added a comment - Yes, please improve an error message. Because we can't find a position of error on template code.
        Hide
        Pakornpong Pothipruk added a comment - - edited

        When I use Velocity on an RTF document, I would like Velocity to also tell me that the exception (e.g. one above) occurs on which line of my RTF document. Is that possible with the current engine?

        Show
        Pakornpong Pothipruk added a comment - - edited When I use Velocity on an RTF document, I would like Velocity to also tell me that the exception (e.g. one above) occurs on which line of my RTF document. Is that possible with the current engine?
        Hide
        Jarkko Viinamäki added a comment -

        This should fix it.

        If #parse doesn't get an argument, a VelocityException is thrown with information where the problem occurs.

        The previous code didn't obviously work and instead of throwing exceptions it just wrote things to Velocity log. This same problem is related to other directives as well (no checking whether we actually got the argument or not and no exception in case of error).

        Show
        Jarkko Viinamäki added a comment - This should fix it. If #parse doesn't get an argument, a VelocityException is thrown with information where the problem occurs. The previous code didn't obviously work and instead of throwing exceptions it just wrote things to Velocity log. This same problem is related to other directives as well (no checking whether we actually got the argument or not and no exception in case of error).
        Hide
        Nathan Bubna added a comment -

        Thanks, Jarkko. We really need to get you committing your own patches.

        Show
        Nathan Bubna added a comment - Thanks, Jarkko. We really need to get you committing your own patches.

          People

          • Assignee:
            Unassigned
            Reporter:
            Siri C.
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development