You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The AbstractExpressionConverter has an init(rootContext)-method, a template method intended to be overridden by
subclasses and a finalconvert(expression)-method to seal the usage pattern of all converters.
The idea was that converters can be initialized with an initial context that differs from the one that is provided by the context supplier, and converters should be reusable.
Problem
The current design has a logical error that leads to weird behavior:
The first thing the convert(..)-method does is clearing the root-context, which does not make sense if you want to prepare a context before use.
The convert-method does not call the init(..)-method.
To properly re-use a converter you MUST call init(..) to avoid side-effects (artifacts from the previous conversion).
Proposed improvement
Keep the convert(..)-method final, but let it call the init(..)-method with the existing context so that this method can decide how to clean or reset or replace the root-context.
Don't clean the root-context in the convert(..)-method.
This way, subclasses have better control over the state management of the converter and the usage pattern of the convert(..)-method gets clarified: no two runs get intertwined anymore.
The text was updated successfully, but these errors were encountered:
The
AbstractExpressionConverter
has aninit(rootContext)
-method, a template method intended to be overridden bysubclasses and a final
convert(expression)
-method to seal the usage pattern of all converters.The idea was that converters can be initialized with an initial context that differs from the one that is provided by the context supplier, and converters should be reusable.
Problem
The current design has a logical error that leads to weird behavior:
convert(..)
-method does is clearing the root-context, which does not make sense if you want to prepare a context before use.init(..)
-method.init(..)
to avoid side-effects (artifacts from the previous conversion).Proposed improvement
convert(..)
-method final, but let it call theinit(..)
-method with the existing context so that this method can decide how to clean or reset or replace the root-context.convert(..)
-method.This way, subclasses have better control over the state management of the converter and the usage pattern of the
convert(..)
-method gets clarified: no two runs get intertwined anymore.The text was updated successfully, but these errors were encountered: