Velocity
  1. Velocity
  2. VELOCITY-424

directive.Parse eating RuntimeException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5
    • Component/s: Engine
    • Labels:
      None

      Description

      The org.apache.velocity.runtime.directive.Parse class is "eating" RuntimeExceptions thrown by Nodes being rendered on line 195. These errors are logged, but are not rethrown.

      These types of errors are typically NPE being thrown by model objects trying to render themselves using their toString() method.

      It is better if any RuntimeExceptions are not caught by this method, as it allows the calling code to document/report the error.

      1. Parse_patch.txt
        0.7 kB
        Malcolm Edgar

        Activity

        Hide
        Malcolm Edgar added a comment -

        Fix for Parse eating runtime exceptions

        Show
        Malcolm Edgar added a comment - Fix for Parse eating runtime exceptions
        Hide
        Malcolm Edgar added a comment -

        A little more background on this issue, which is more of a change request than a Velocity bug.

        This use case is:

        A Click control is added to the Velocity context and merged with the template. The application control code has a bug in it and throws a NullPointerException when its toString() method is called by Velocity. Velocity catches this exception and logs the exception, and stops rendering.

        This can make the error difficult to find, as the application has no visibility of the RuntimeException it caused. The preferred behaviour is for RuntimeExceptions to be rethrown by Velocity.

        regards Malcolm Edgar

        Show
        Malcolm Edgar added a comment - A little more background on this issue, which is more of a change request than a Velocity bug. This use case is: A Click control is added to the Velocity context and merged with the template. The application control code has a bug in it and throws a NullPointerException when its toString() method is called by Velocity. Velocity catches this exception and logs the exception, and stops rendering. This can make the error difficult to find, as the application has no visibility of the RuntimeException it caused. The preferred behaviour is for RuntimeExceptions to be rethrown by Velocity. regards Malcolm Edgar
        Hide
        Will Glass-Husain added a comment -

        Thanks for reporting on this. Coincidentally, I have an update for later today on runtime exceptions. Let me commit that than we can take a look at this in light of that.

        Show
        Will Glass-Husain added a comment - Thanks for reporting on this. Coincidentally, I have an update for later today on runtime exceptions. Let me commit that than we can take a look at this in light of that.
        Hide
        Henning Schmiedehausen added a comment -

        Fix for this is actually quite simple (and should not interfere with the code that Will wants to commit). I've committed a preliminary patch, please let me know if this works out.

        Show
        Henning Schmiedehausen added a comment - Fix for this is actually quite simple (and should not interfere with the code that Will wants to commit). I've committed a preliminary patch, please let me know if this works out.
        Hide
        Henning Schmiedehausen added a comment -

        r356607 should fix this problem.

        Show
        Henning Schmiedehausen added a comment - r356607 should fix this problem.
        Hide
        Malcolm Edgar added a comment -

        Hi guys, I have tested the patch it works well.

        regards Malcolm Edgar

        Show
        Malcolm Edgar added a comment - Hi guys, I have tested the patch it works well. regards Malcolm Edgar
        Hide
        Henning Schmiedehausen added a comment -

        Close all resolved issues for Engine 1.5 release.

        Show
        Henning Schmiedehausen added a comment - Close all resolved issues for Engine 1.5 release.

          People

          • Assignee:
            Henning Schmiedehausen
            Reporter:
            Malcolm Edgar
          • Votes:
            5 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development