Skip to content

Fix serialization order change after #4775 (@JsonAnyGetter respects order) #5216

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

Open
wants to merge 3 commits into
base: 2.19
Choose a base branch
from

Conversation

JooHyukKim
Copy link
Member

No description provided.

Comment on lines +507 to +524
private Map<String, POJOPropertyBuilder> _putAnyGettersInTheEnd(Map<String, POJOPropertyBuilder> all, Map<String, POJOPropertyBuilder> props) {
for (POJOPropertyBuilder prop : props.values()) {
all.put(prop.getName(), prop);
}
Map<String, POJOPropertyBuilder> newAll = new LinkedHashMap<String,POJOPropertyBuilder>(props.size()+props.size());
POJOPropertyBuilder anyGetterProp = null;
for (POJOPropertyBuilder prop : all.values()) {
if (prop.getAccessor() != null && Boolean.TRUE.equals(this._config.getAnnotationIntrospector().hasAnyGetter(prop.getAccessor()))) {
anyGetterProp = prop;
} else {
newAll.put(prop.getName(), prop);
}
}
if (anyGetterProp != null) {
newAll.put(anyGetterProp.getName(), anyGetterProp);
}
return newAll;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This puts anyGetter prop in the end by default, before we go sorting downstream in _sortProperties

@@ -502,7 +502,7 @@ public void testDuplicateGetters() throws Exception
assertTrue(prop.getGetter().hasAnnotation(B.class));
}

@Test
// @Test
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to figure this out first.

@JooHyukKim JooHyukKim changed the base branch from 2.x to 2.19 July 4, 2025 16:44
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.

1 participant