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
Change
MapperFeature.SORT_PROPERTIES_ALPHABETICALLY
default to true (3.x) #4572Change
MapperFeature.SORT_PROPERTIES_ALPHABETICALLY
default to true (3.x) #4572Changes from 2 commits
f879990
8995e93
354820b
c0e7cea
bd055ce
b9044bd
2d3f4a8
c66d2fa
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.
Ok, this seems wrong: since Constructor is:
order should remain "c", "a" (creator parameters), "b", given that
MapperFeature.SORT_CREATOR_PROPERTIES_FIRST
is left enabled (default state).So something is wrong... not sure if same is true for 2.x.
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.
Ohhhhh. No, actually, I am wrong. Code in
POJOPropertiesCollector
says:that is, ALL Creator properties should be sorted before all non-Creator properties (unless explicit order dictates otherwise).
So in that sense this works as expected.
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.
However: this brings up another question, mentioned elsewhere: should ordering of Record properties be ordered by declaration order because it:
I think I better file a separate issue for that; not strictly related to this PR, but something worth considering.
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 haven't had time to look at the sorting functionality wrt creator-properties yet, but my first intuition was wondering...
But it seems like
record
constructors , by its nature, is considered creators or similar. I think I do need to (and will) learn more about records.Thank you for the explanation tho @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.
So, Records are handled quite similar to POJOs with 2.18, in that their Constructors are selected either from explicit annotation, or, if none, by selection so-called "Canonical" constructor (one that has all record fields in order).
But ordering of properties is then done separately across set of properties, not considering Creator (constructor or factory method).
(and of course actual Creator is not used for serialization anyway, nor are CreatorProperty instances -- but
POJOPropertiesCollector
has information on whether logical property has a creator-parameter binding).I think sorting is handled by
POJOPropertiesCollector
and could keep creator-bound properties in order they were added (which is declaration order).I hope 2.18 code, esp. in
POJOPropertiesCollector
, is easier to follow through than before refactoring. There is still some later processing inBasicDeserializerFactory
, but more of logic is now in PPC.