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
Assuming that ObjectMapper is to be made immutable by introduction of Builder-pattern, existing setup context (Module.SetupContext) will not work as is.
At minimum, setup context would need to work on matching Builder object, but the bigger question is when and how would a Module be registered. The straight-forward way seems to be to require registration through Builder object itself, but in such a way that reference to Module would be retained until builder's build() method is called.
But beyond basic builder-flow, even bigger question is that of ability to "modify" an existing mapper ("rebuild"). While it would be possible to just either try to retain settings (possibly via serializer/deserializer caches, as well as other handler chains), it seems better to actually require mapper to remember Modules registered, and re-register modules if a new copy is created.
This in turn requires full clean up of all state, or, more likely, construction of a fresh mapper instance.
Going this route will probably add some overhead compared to current usage of ObjectMapper.copy(), but should be more correct, prevent many potential problem cases, and be all around more robust.
Another potential downside is that there will now be linkage from mapper to modules (Jackson 2.x and earlier did NOT retain a reference to module). But that does not seem like a major problem; just needs to be someone Module authors need to keep in mind.
The text was updated successfully, but these errors were encountered:
(note: see #3 as background)
Assuming that
ObjectMapper
is to be made immutable by introduction of Builder-pattern, existing setup context (Module.SetupContext
) will not work as is.At minimum, setup context would need to work on matching Builder object, but the bigger question is when and how would a
Module
be registered. The straight-forward way seems to be to require registration through Builder object itself, but in such a way that reference to Module would be retained until builder'sbuild()
method is called.But beyond basic builder-flow, even bigger question is that of ability to "modify" an existing mapper ("rebuild"). While it would be possible to just either try to retain settings (possibly via serializer/deserializer caches, as well as other handler chains), it seems better to actually require mapper to remember
Module
s registered, and re-register modules if a new copy is created.This in turn requires full clean up of all state, or, more likely, construction of a fresh mapper instance.
Going this route will probably add some overhead compared to current usage of
ObjectMapper.copy()
, but should be more correct, prevent many potential problem cases, and be all around more robust.Another potential downside is that there will now be linkage from mapper to modules (Jackson 2.x and earlier did NOT retain a reference to module). But that does not seem like a major problem; just needs to be someone Module authors need to keep in mind.
The text was updated successfully, but these errors were encountered: