velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. B. Rainsberger" <>
Subject Unmodifiable Map in VM
Date Mon, 02 Sep 2002 16:47:37 GMT

I searched the archives and could not find a response to this one. I
hope someone has some insight for me on this issue.

It appears that Velocity does not correctly handle unmodifiable
collections passed into the context. To explain, I have placed a map
into the context that has been wrapped with
"Collections.unmodifiableMap(Map)". Calling "keySet()" on this Map does
not answer the set of keys. Instead, Velocity reacts as though
"keySet()" is not part of the map's interface -- it answers the literal
string "map.keySet()". 

Clearly, Collections.unmodifiableMap answers a Map object, so that
object understands the method "keySet". Is this a bug? An intentional
feature? I prefer not to put writable collections onto the VM and I
likewise prefer not to create a clone of my Map to ensure that
problems/changes on the macro have no harmful effects.

I am using the version of Velocity included in Turbine 2.1. I prefer
not to upgrade at this point unless someone knows that this problem (if
it is a defect) is fixed.

J. B. Rainsberger,
President, Diaspar Software Services
Let's write software that people understand.
telephone: +1 416 791-8603
All correspondence (c) 2002 Diaspar Software Services.
If you want to use it, just ask; don't steal.

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