I think it relates to the "context" variable that is frequently used in
groovy data prep scripts for the script output.

I'm not in front of a computer, but looking at it in that light may help.

Regards
Scott

On Thu, 19 Jul 2018, 09:24 Taher Alkhateeb, <[email protected]>
wrote:

> I didn't get into it before, but my first gut reaction is .. delete
> that thing! :)
>
> Anyway, it seems to have to many references, so I would advise
> investigating how it is constructed to understand what is being pulled
> in. Just begin from the container loader and work your way down with a
> debugger until you hit exactly the reason why this check was in place.
>
> I find this code a bit ugly, and I'd rather get rid of it if doesn't
> add any value (and I think it doesn't)
>
> On Wed, Jul 18, 2018 at 6:53 PM, Mathieu Lirzin
> <[email protected]> wrote:
> > Hello,
> >
> > ‘MapStack’ is a specialization of the ‘MapContext’ class which is an
> > implementation of ‘Map’ interface that has the particularity to store
> > its key-values in separate sub-maps that can mask each others.
> >
> > The whole point of ‘MapStack’ implementation is to override the Map
> > accessors to ensure that the key "context" is associated with ‘this’
> > meaning the ‘MapStack’ instance.
> >
> > --8<---------------cut here---------------start------------->8---
> >     @Override
> >     public Object get(Object key) {
> >         if ("context".equals(key)) {
> >             return this;
> >         }
> >         return super.get(key);
> >     }
> >
> >     @Override
> >     public Object get(String name, Locale locale) {
> >         if ("context".equals(name)) {
> >             return this;
> >         }
> >         return super.get(name, locale);
> >     }
> >
> >     @Override
> >     public Object put(K key, Object value) {
> >         if ("context".equals(key)) {
> >             if (value == null || this != value) {
> >                 Debug.logWarning("Putting a value in a MapStack with key
> [context] that is not this MapStack, will be hidden by the current MapStack
> self-reference: " + value, module);
> >             }
> >         }
> >         return super.put(key, value);
> >     }
> > --8<---------------cut here---------------end--------------->8---
> >
> > I don't understand the purpose of such thing.  So if someone has some
> > rationale to share, I would be grateful.
> >
> > Thanks.
> >
> > --
> > Mathieu Lirzin
> > GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37
>

Reply via email to