Fix combined @JsonKey and @JsonValue on getters - #6241
Conversation
@JsonKey and @JsonValue on getters
CI failed: 7 test errors in jackson-databind caused by a Mockito initialization failure on Java 21; unrelated to the PR changes.Overview1 log analysis revealed a Mockito plugin initialization failure affecting Java 21 across 7 tests, resulting in a build failure. The issues are unrelated to the PR changes. FailuresMockito Initialization Error on Java 21 (confidence: high)
Summary
Code Review ✅ Approved🟡 Medium risk Fixes combined Tip Comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Fixes #6240.
A getter annotated with both
@JsonKeyand@JsonValueis currently registered only as a key accessor, so serializing it as a value fails withInvalidDefinitionException.Collect both annotations independently while keeping key-only getters out of regular properties and preserving the existing
@JsonAnyGetterhandling. Add regression tests for root values, map keys and values, and disabled annotations.Verified with
./mvnw -B -ntp verifyon Java 21: 4,856 tests passed. Byte Buddy was loaded throughJAVA_TOOL_OPTIONS=-javaagent:<byte-buddy-agent-1.15.10.jar>because dynamic agent attachment fails on the local JDK. The new root-value and map-value tests fail against the original code.