Velocity
  1. Velocity
  2. VELOCITY-683

When passing literals other than strings to macro calls, setting new values the formal parameters does not propagate the changes outside the local scope

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.5, 1.6, 1.6.1
    • Fix Version/s: None
    • Component/s: Engine
    • Labels:
      None

      Description

      With this macro definition:

      #macro(setValueToEmpty $value)
      #set($value = '')
      #end

      While the following works well:

      #set($value = 'abc')
      #setValueToEmpty('abc') => $value == ''

      this fails:

      #set($value = 'abc')
      #setValueToEmpty(3) => $value == 'abc'

      This is caused by the fact that in org.apache.velocity.context.ProxyVMContext#addVMProxyArg if the parameter is a constant (which somehow doesn't include strings), then a local variable is created with the node's value as its value. For string literals, the actual node is placed in the proxy map, which allows setting a new value for it.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Sergiu Dumitriu
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development