-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
2.18Issues planned at 2.18 or laterIssues planned at 2.18 or laterRecordIssue related to JDK17 java.lang.Record supportIssue related to JDK17 java.lang.Record support
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
@JsonIgnore on a Record component is ignored when the corresponding accessor method is overridden.
Version Information
Since 2.15.0.
Reproduction
record RecordWithJsonIgnore(int id, @JsonIgnore String name) {
@Override
public String name() {
return name;
}
}
RecordWithJsonIgnore deser = new ObjectMapper().readValue("{\"id\":123,\"name\":\"Bob\"}", RecordWithJsonIgnore.class);
// failed with:
// org.opentest4j.AssertionFailedError:
// Expected :RecordWithJsonIgnore[id=123, name=null]
// Actual :RecordWithJsonIgnore[id=123, name=Bob]
assertEquals(new RecordWithJsonIgnore(123, null), deser);Expected behavior
No response
Additional context
There are typically 3 places to get an annotation info from:
| Where | For this scenario |
|---|---|
| Constructor parameter | Can't have @JsonIgnore info because @JsonIgnore's @Target does not include ElementType.PARAMETER UPDATE: Forgot to mention that the hardcoded prop.addCtor(..., false) in POJOPropertiesCollector also needs to be changed for this to work. |
| Accessor method | When overridden, @JsonIgnore will not be "inherited" from original method |
| Field | #3737 removed field info for deserialization, so it can't contribute the @JsonIgnore info |
Metadata
Metadata
Assignees
Labels
2.18Issues planned at 2.18 or laterIssues planned at 2.18 or laterRecordIssue related to JDK17 java.lang.Record supportIssue related to JDK17 java.lang.Record support