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

JsonAnySetter handling changed recently? #4795

Closed
1 task done
alesj opened this issue Nov 12, 2024 · 7 comments
Closed
1 task done

JsonAnySetter handling changed recently? #4795

alesj opened this issue Nov 12, 2024 · 7 comments
Labels
duplicate Duplicate of an existing (usually earlier) issue

Comments

@alesj
Copy link

alesj commented Nov 12, 2024

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

This used to work for me (in 2.17.2):

    record AnyTester(Map<String, Object> p) {
        AnyTester {
            if (p == null) {
                p = new LinkedHashMap<>();
            }
        }

        @JsonAnySetter
        public void setAnyUnknownProperty(String key, Object value) {
            p.put(key, value);
        }
    }

    @Test
    public void testAnyTester() throws Exception {
        AnyTester at = OBJECT_MAPPER.readValue("{\"foo\":\"bar\"}", AnyTester.class);
        Assertions.assertEquals("bar", at.p().get("foo"));
    }

Now there is no foo=bar entry in the p map.

Version Information

2.18.1

Reproduction

Just run the test above.

Expected behavior

p should have foo=bar entry.

Additional context

No response

@alesj alesj added the to-evaluate Issue that has been received but not yet evaluated label Nov 12, 2024
@JooHyukKim
Copy link
Member

Might be related to #4639 could you try 2.18.2 (latest)?

@alesj
Copy link
Author

alesj commented Nov 12, 2024

@JooHyukKim where can I find 2.18.2 ?
(https://central.sonatype.com/search?q=jackson-databind)

@alesj
Copy link
Author

alesj commented Nov 12, 2024

@JooHyukKim where can I find 2.18.2 ? (https://central.sonatype.com/search?q=jackson-databind)

Ah, OK ... I guess I should just build the current repo (which points to 2.19.0-SNAPSHOT ... which confused me)

@JooHyukKim
Copy link
Member

Ah yes, sorry I should've mentioned that.
Thanks @alesj !

@alesj
Copy link
Author

alesj commented Nov 12, 2024

@JooHyukKim yup, that seems to fix it, tnx!
(the test is now passing ...)

Closing the issue now, as fixed by the #4639

@alesj alesj closed this as completed Nov 12, 2024
@JooHyukKim
Copy link
Member

Phew! Awesome. Thank you for reporting @alesj !

@cowtowncoder cowtowncoder added duplicate Duplicate of an existing (usually earlier) issue and removed to-evaluate Issue that has been received but not yet evaluated labels Nov 12, 2024
@cowtowncoder
Copy link
Member

Marking as duplicate of #4639. Thank you for verifying @alesj .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Duplicate of an existing (usually earlier) issue
Projects
None yet
Development

No branches or pull requests

3 participants