Coder Social home page Coder Social logo

Re-using ObjectMapper from spring-boot for EntityViewAwareMappingJackson2HttpMessageConverter leads to issues about blaze-persistence HOT 3 CLOSED

EugenMayer avatar EugenMayer commented on July 18, 2024
Re-using ObjectMapper from spring-boot for EntityViewAwareMappingJackson2HttpMessageConverter leads to issues

from blaze-persistence.

Comments (3)

EugenMayer avatar EugenMayer commented on July 18, 2024

This one is interesting, cloning the ObjectMapper will make IdView support in DTOs disappear again.

The point is, if BPs deserializer is not added on the OM of spring boot, spring boot will not be abler to deserialize things like

public class SomeDTO {
   public UserIdView user;
}

The be frank:

  • using a clone of OM, will make the deserialization of SomeDTO not work
  • NOT using a clone will make the deserialization SomeDTO , but will break some serialization

from blaze-persistence.

EugenMayer avatar EugenMayer commented on July 18, 2024

After reading up what INFER_PROPERTY_MUTATORS actually does, it seems like disabling it is actually rather a good practice after all.

To fix the issue for us, we had to add setters to our ProblemResponse.

I'am not sure where it leaves us, since there are arguments in both directions

  1. clone within BP so no surprising changes like the above happen to the OM for any other deserialization (side effect)
  2. ensuring the educate the user of the integration about this side effect, and let the user decide to clone or not

Wit 1. BP loses the support to deserialize any IdViews in DTOs (while it would have the support), with 2., if uncloned, the support for the former still works.

So it is kind of surprising on each strategy, but since doing 1. cannot be reverted and thus the user cannot opt in for deserialization support, but .2 lets the user decide himself to clone (lose it, less side effects), or not (deserialization support).

So considering there is no right or wrong in having less side effects or support for des., i would tend to go with 2., so depending on external clone if needed. It is flexible and can cover all cases - and it is what is implemented now.
The only thing that needs consideration is, documentation and education about the side effect

from blaze-persistence.

EugenMayer avatar EugenMayer commented on July 18, 2024

Thank you for the discussion and clarification @beikov - we know understand that what happened here was actually 'using a side-effect' of a non-clone OM which we ourself used to create a custom EntityViewAwareMappingJackson2HttpMessageConverter ( see #1899). So BP already clones the OM just fine for the MVC integration.

In addition, the support for deserializing EVs in DTOs was yet never intended, thus #1898 tries to discuss it's implementation.

Closing this issue as invalid / miss understanding. Thank you @beikov for your patience :)

from blaze-persistence.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.