-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
3.1RecordIssue related to JDK17 java.lang.Record supportIssue related to JDK17 java.lang.Record supporthas-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issue
Milestone
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
A JSON field:
- Not included in
@JsonIncludeProperties, or - Included in
@JsonIgnoreProperties
...will still get deserialized as a Record's component with the same name.
Version Information
Oldest I tried this with is 2.14.2, latest is 2.18.
Reproduction
For @JsonIncludeProperties
record Id2Name(int id, String name) {
}
record RecordWithJsonIncludeProperties(@JsonIncludeProperties("id") Id2Name child) {
}
RecordWithJsonIncludeProperties value = new ObjectMapper().readValue("{\"child\":{\"id\":123,\"name\":\"Bob\"}}", RecordWithJsonIncludeProperties.class);
// failed with:
// org.opentest4j.AssertionFailedError:
// Expected :RecordWithJsonIncludeProperties[child=Id2Name[id=123, name=null]]
// Actual :RecordWithJsonIncludeProperties[child=Id2Name[id=123, name=Bob]]
assertEquals(new RecordWithJsonIncludeProperties(new Id2Name(123, null)), value);For @JsonIgnoreProperties
record Id2Name(int id, String name) {
}
record RecordWithJsonIgnoreProperties(@JsonIgnoreProperties("name") Id2Name child) {
}
RecordWithJsonIgnoreProperties value = new ObjectMapper().readValue("{\"child\":{\"id\":123,\"name\":\"Bob\"}}", RecordWithJsonIgnoreProperties.class);
// failed with:
// org.opentest4j.AssertionFailedError:
// Expected :RecordWithJsonIgnoreProperties[child=Id2Name[id=123, name=null]]
// Actual :RecordWithJsonIgnoreProperties[child=Id2Name[id=123, name=Bob]]
assertEquals(new RecordWithJsonIgnoreProperties(new Id2Name(123, null)), value);Expected behavior
No response
Additional context
NOTE: I'm not personally affected by this, just something I found when testing for #4626 - I thought they have the same cause, but apparently not.
Metadata
Metadata
Assignees
Labels
3.1RecordIssue related to JDK17 java.lang.Record supportIssue related to JDK17 java.lang.Record supporthas-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issue