velocity-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurens van der Klis <>
Subject Upgrade documentation
Date Tue, 09 Mar 2021 09:02:00 GMT

I just did a migration of velocity 1.6 engine to 2.2. on a system that 
runs a lot of untethered velocity code from various sources. I ran into 
a few compatibilty quirks that may be worth mentioning in the 
documentation. Perhaps I missed some of them in which case I should have 
looked better. Here they are:

  * In at least 1.6 the variable $true could be used as the right side
    (value) in a #set, in a conditional statement #if and passed as a
    method argument. In these cases it was regarded as boolean true.
    Some code relied on this quirk or did not notice mistyping true with
    $true. It was obviously a quirk because $true could not actually be
    given a value or 'printed', this would result in an error. This
    problem is easily fixable by overriding VelocityContext.get to catch
    these oddities.
  * References by name such as the one below do not work anymore if the
    $map implements the java Map interface indirectly.

    #set($ = 'bar')

    The reason is the MapSetExecutor doesn't check the interfaces
    implementation of supers.

  * Obscure and fairly irrelevant: #set(${$foo} = 'bar') did not throw
    an exception

That's it!


Laurens van der Klis

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message