Velocity
  1. Velocity
  2. VELOCITY-615

Inconsistent macro bahaviour in cached and non-cached modes

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6.1, 1.7
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Windows XP, Tomcat 6.x, JVM 1.6

      Description

      Here's the scenario; we have a framework that allows us to reload the Velocity runtime so that we can tinker with caching etc at runtime. We normally run development with template caching turned off and deliver to the client with caching turned on.

      There is a problem with inline macros (probably macro libraries too, not sure) whereby they will behave differently once they are compiled and cached then when they are interpreted at runtime. It is all to do with the re-assignment of parameter variables within the macro.

      Here is a very simple example;

      #macro(tmpMacro $FieldNames)
      #set($FieldNames="ingredient." + $FieldNames.replaceAll(",",",ingredient."))
      .....
      #end

      #tmpMacro("one,two,three")

      This works fine when the template is not cached - as soon as you turn on caching, the macro becomes unreliable.
      My original prognosis was that we were upsetting the variable types by converting strings into lists but as you can see, that isn't the case in this example. The problem is solved by changing the assignment to;

      #set($Names="ingredient." + $FieldNames.replaceAll(",",",ingredient."))

      I can appreciate that maybe this type of "re-assignment" of parameters might be an issue, but the real problem is the inconsistency between the cached and non-cached behaviours.

        Issue Links

          Activity

          Steve O'Hara created issue -
          Nathan Bubna made changes -
          Field Original Value New Value
          Fix Version/s 1.6 [ 12310290 ]
          Resolution Cannot Reproduce [ 5 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Steve O'Hara made changes -
          Status Resolved [ 5 ] Reopened [ 4 ]
          Resolution Cannot Reproduce [ 5 ]
          Nathan Bubna made changes -
          Fix Version/s 1.6 [ 12310290 ]
          Resolution Fixed [ 1 ]
          Fix Version/s 1.7 [ 12313453 ]
          Status Reopened [ 4 ] Resolved [ 5 ]
          Fix Version/s 1.6.1 [ 12313544 ]
          Sergiu Dumitriu made changes -
          Link This issue is related to VELOCITY-681 [ VELOCITY-681 ]
          Mark Thomas made changes -
          Workflow jira [ 12442338 ] Default workflow, editable Closed status [ 12551614 ]
          Mark Thomas made changes -
          Workflow Default workflow, editable Closed status [ 12551614 ] jira [ 12552498 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Steve O'Hara
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development