Skip to content

Fix combined @JsonKey and @JsonValue on getters - #6241

Merged
cowtowncoder merged 3 commits into
FasterXML:2.xfrom
kimsanhaa:fix/json-key-value-getter-6240
Sep 25, 2026
Merged

cowtowncoder merged 3 commits into
FasterXML:2.xfrom
kimsanhaa:fix/json-key-value-getter-6240

Conversation

@kimsanhaa

Copy link
Copy Markdown
Contributor

Fixes #6240.

A getter annotated with both @JsonKey and @JsonValue is currently registered only as a key accessor, so serializing it as a value fails with InvalidDefinitionException.

Collect both annotations independently while keeping key-only getters out of regular properties and preserving the existing @JsonAnyGetter handling. Add regression tests for root values, map keys and values, and disabled annotations.

Verified with ./mvnw -B -ntp verify on Java 21: 4,856 tests passed. Byte Buddy was loaded through JAVA_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.

@cowtowncoder cowtowncoder added the cla-received PR already covered by CLA (optional label) label Sep 25, 2026
@cowtowncoder cowtowncoder changed the title Fix combined @JsonKey and @JsonValue on getters Fix combined @JsonKey and @JsonValue on getters Sep 25, 2026
@gitar-bot

gitar-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
CI failed: 7 test errors in jackson-databind caused by a Mockito initialization failure on Java 21; unrelated to the PR changes.

Overview

1 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.

Failures

Mockito Initialization Error on Java 21 (confidence: high)

  • Type: tooling
  • Affected jobs: 108267266348
  • Related to change: no
  • Root cause: Mockito failed to initialize its MockMaker plugin on Java 21, throwing an IllegalStateException during test execution.
  • Suggested fix: Upgrade Mockito and Byte Buddy dependencies to versions fully compatible with Java 21.

Summary

  • Change-related failures: 0
  • Infrastructure/flaky failures: 1 (Mockito initialization error on Java 21 causing test failures)
  • Recommended action: Update the test dependencies to ensure Java 21 compatibility for Mockito.
Code Review ✅ Approved

🟡 Medium risk

Fixes combined @JsonKey and @JsonValue annotations on getters by collecting both independently while preserving key-only getter and @JsonAnyGetter handling. Comprehensive regression tests added for root values, map keys and values, and disabled annotations; all 4,856 existing tests pass.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@cowtowncoder cowtowncoder added this to the 2.23.0 milestone Sep 25, 2026
@cowtowncoder
cowtowncoder merged commit a95ad4f into FasterXML:2.x Sep 25, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-received PR already covered by CLA (optional label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants