Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implement new
SerializationFeature.IGNORE_FAILURE_TO_ORDER_MAP_ENTRIES_BY_INCOMPARABLE_KEYS
#4778Implement new
SerializationFeature.IGNORE_FAILURE_TO_ORDER_MAP_ENTRIES_BY_INCOMPARABLE_KEYS
#4778Changes from 2 commits
420ae68
1faca12
5f3c1d1
7b8aa71
a5017e6
2d1e5f4
7b95e2d
6ff6bab
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the try-catching only just got bigger :-(
Without try-catching like we do here or finding some other way, this feature will only be un-deterministic.
If we look at below test testSerializationSuccessWhenDisabledWithMixedTypes() case, you can see this feature is so easy to violate what the name FAIL_ON_ORDER_MAP_BY_INCOMPARABLE_KEY itself imposes.
I am also thinking without figuring out how to handle the case with incomparable key in the middle, we might be better off not push through this feature 🤔
Lemme know how you see @cowtowncoder ! 🙏🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial reaction:
So I don't think we really must solve all cases; especially when trying to do that leads to awkward and brittle reliance on JDK-thrown exceptions, which are basically side-effects of type casts.
But let me have a look at PR see if that changes my mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to.
You are right on saying "what can be supported" or not. Mixed-type case would be a painful case to handle from maintenance point of view, and also actual usage wouldn't be much reasonable either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus, if we change our mind, we can always add catch block -- or, even if we choose to, scan the whole keySet() to check type -- as a follow-up improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think that if we went this route and recognized failure, we should convert that into
JsonMappingException
(one of sub-types ideally) -- and not passClassCastException
.However: I have bigger concerns about catch-approach, will add different note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this one: this is serialization, not deserialization test. Will move.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ughh how did I miss that 😂 thank you!