Skip to content

Conversation

JooHyukKim
Copy link
Member

No description provided.

@JooHyukKim JooHyukKim changed the base branch from 2.x to 2.19 October 13, 2025 15:25
@JooHyukKim JooHyukKim marked this pull request as draft October 13, 2025 15:29
Comment on lines +22 to +23
@JsonProperty(value = "additionalProperties")
private Map<String, Object> hidden;
Copy link
Member Author

Choose a reason for hiding this comment

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

Modified to hidden, so we get better view of what's actually conflicting --@JsonProperty(value = "additionalProperties")

Comment on lines -280 to -293
@Test
public void testPrivateAnyGetterSorted() throws Exception {
PrivateAnyGetterPojoSorted pojo = new PrivateAnyGetterPojoSorted();
pojo.add("secondProperty", 2);
String json = MAPPER.writeValueAsString(pojo);

assertEquals(a2q("{" +
"'firstProperty':1," +
"'secondProperty':2," + // private accesor, wont' work here
"'thirdProperty':3," +
"'forthProperty':4}"),
json);
}

Copy link
Member Author

@JooHyukKim JooHyukKim Oct 13, 2025

Choose a reason for hiding this comment

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

(I deleted so we have better visibility on subject matter)
@cowtowncoder May I ask for a bit of help on what the correct behavior should be?

So this one is now failing.
@JsonPropertyOrder specified via line 131 does work now.
Now it serializes into...

{
    "firstProperty":1,"
    secondProperties":{"secondProperty":2}, // <---- as configured
    "thirdProperty":3,
    "forthProperty":4,
    "secondProperty":2
}

... this, but I can't figure out why there is trailing "secondProperty":2 at the end.

Moreover, I am more confused because it the ordering like above should've worked even before since we have

public Map<String, Object> getSecondProperties() {
...

declared at line 133.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know for sure, but my guess is that the change broke linkage between

        @JsonAnyGetter
        private Map<String, Object> secondProperties = new HashMap<>();```

and

    public Map<String, Object> getSecondProperties() {
        return super.secondProperties;

so that "extra" one is for `@JsonAnyGetter` annotated field.

This whole set of tests and set up is very complicated and quite hard to reason about, unfortunately.

BeanPropertyWriter prop = props.get(i);
// Either any-getter as field...
if (Objects.equals(prop.getName(), anyGetter.getName())
if (Objects.equals(prop.getMember().getName(), anyGetter.getName())
Copy link
Member

@cowtowncoder cowtowncoder Oct 13, 2025

Choose a reason for hiding this comment

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

I am not sure about this one: why is the change necessary/correct?
At least requires a comment on why we are looking at method/field name of concrete accessor, instead of processed property name.

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.

2 participants