Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deep copy instead of shallow copy in mappers #360

Merged
merged 1 commit into from
Feb 20, 2023

Conversation

ArtDu
Copy link
Contributor

@ArtDu ArtDu commented Feb 17, 2023

I haven't forgotten about:

  • Tests
  • Changelog
  • Documentation
  • Commit messages comply with the guideline
  • Cleanup the code for review. See checklist

Related issues:
Closes #166

@ArtDu ArtDu force-pushed the default-msgpack-mapper/true-copy branch from a45c752 to c896e82 Compare February 17, 2023 13:30
@ArtDu ArtDu requested a review from Elishtar February 17, 2023 14:47
this();
this.valueConverters.putAll(mapper.valueConverters);
this.objectConverters.putAll(mapper.objectConverters);
this.valueConverters = mapper.valueConverters.entrySet().stream()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's a good idea on its own, it will lead to large memory consumption growth. Remember that we are currently creating a mapper stack on each request.

Did this change come out of a recently encountered bug? I was worried about that after we made the last mappers refactoring, see my comment #300 (review). Maybe let's think about proper mapper caching this time?

Raw idea: we should define a "tagging" API for mappers (e.g. a hashcode for the whole stack) that we can use for caching the other mappers. Using such tag (hashcode) can allow caching mappers without space schema involved, but it will require each converter and mapper to provide a unique tag (hashcode).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this change come out of a recently encountered bug?

It's problem in springdata, because there we use registerValueConverter per request there. We should also think about how to separate custom mappers from default ones besides caching

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added your thoughts in #117

And also created a ticket about my separation idea #361

@ArtDu ArtDu merged commit 415aa88 into master Feb 20, 2023
@ArtDu ArtDu deleted the default-msgpack-mapper/true-copy branch February 20, 2023 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No way to create a modifiable copy of DefaultMessagePackMapper. Now the copy affects original object
3 participants