We just went through this earlier in the week, and we are going to wait
until after 1.3.
This is basically a specific case of the
#set($foo = $somethingNotInContext )
problem, where the previous value of $foo is left in the context.
So yes, if/when we decide to do it, this will be along the lines of the fix,
and will be applied universally.
geir
On 2/16/02 11:29 PM, "Paulo Gaspar" <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
> After coding a Context using the AbstractContext I noticed
> that on #foreach cycles null values were being replaced by
> the previous non-null value.
>
> After trying to find the problem at my (aham! flawless) code
> and a bit of navigation trough Velocity code, my top suspect
> was this bit at the AbstractContext class:
>
> public Object put(String key, Object value)
> {
> /*
> * don't even continue if key or value is null
> */
>
> if (key == null)
> {
> return null;
> }
> else if (value == null)
> {
> return null;
> }
>
> return internalPut(key, value);
> }
>
> See? When the value is null it does NOTHING, which means
> that the previous non null value remains for that key!!!
> (Argh, not even a RuntimeException!)
>
>
> Since this might be used with some kind of Map also
> allergic to null values, I propose to fix it by replacing
> this (do-nothing-on-null-value) bit:
>
> else if (value == null)
> {
> return null;
> }
>
> ...with this (remove-key-on-null-value) one:
>
> else if (value == null)
> {
> return internalRemove(key);
> // was: return null;
> }
>
> Leaving that "was" comment to give a clue to some potential
> victim of the change.
>
>
> IMHO, the current behavior is not acceptable since it does
> produce output that does not match its original data and
> this is the most reliable fix I can think of.
>
> Better ideas someone?
> (This kind of core class scares me a bit.)
>
>
> The patch is attached.
>
>
> Have fun,
> Paulo Gaspar
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
--
Geir Magnusson Jr. [EMAIL PROTECTED]
System and Software Consulting
Be a giant. Take giant steps. Do giant things...
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>