Skip to content

Honor @JsonValue accessor format with explicit serializers - #6269

Open
jin-sungdae wants to merge 1 commit into
FasterXML:3.xfrom
jin-sungdae:codex/jsonvalue-explicit-serializer-context
Open

jin-sungdae wants to merge 1 commit into
FasterXML:3.xfrom
jin-sungdae:codex/jsonvalue-explicit-serializer-context

Conversation

@jin-sungdae

Copy link
Copy Markdown

When a @jsonvalue accessor has both an explicit serializer and @jsonformat, the accessor's format is ignored. For example:

static class Value {
    @JsonValue
    @JsonSerialize(using = JavaUtilDateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM", timezone = "UTC")
    public Date value = new Date(0L);
}

On current 3.x, serializing this value produces "1970-01-01T00:00:00.000Z" instead of "1970-01".

#6076 added an accessor-backed BeanProperty for dynamically or statically resolved @jsonvalue serializers, but the already-supplied serializer branch still contextualizes against only the enclosing property (or null at the root). Use the same _accessorProperty helper in that branch, preserving the existing enclosing-property precedence.

This is a follow-up to #4762 / #6076 and targets 3.x, where that helper is available. It does not introduce another annotation-merging implementation or change public APIs.

Regression coverage:

  • Explicit serializer on a @jsonvalue field.
  • Explicit serializer on a @jsonvalue method.
  • Nested wrapper without an enclosing format override.
  • Enclosing format override retaining precedence.

Validation on Microsoft OpenJDK 17.0.15 / Maven 3.9.9:

  • Before the fix: the new test class runs 4 tests, with 3 failures; the enclosing-override control already passes.
  • Focused run: 28 tests, 0 failures/errors/skips.
  • mvn -B -ntp clean verify: BUILD SUCCESS; 7,475 tests, 0 failures, 0 errors, 1 skipped.
  • git diff --check passes.

Prepared with AI assistance. The failure reproduction and verification commands above were executed locally.

@gitar-bot

gitar-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk

Fixes @JsonValue accessor format being ignored when an explicit serializer is also present by using the same accessor-property helper for already-supplied serializers. Comprehensive regression coverage validates the fix across field and method accessors, nested wrappers, and enclosing format precedence. No issues found.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

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 the cla-needed PR looks good (although may also require code review), but CLA needed from submitter label Oct 6, 2026
@cowtowncoder

Copy link
Copy Markdown
Member

Thank you for submitting this PR; I'll review it as soon as I have time.

One thing needed before merging is CLA (if not yet sent); see https://github.com/FasterXML/jackson/blob/main/CONTRIBUTING.md#paperwork for details.

Looking forward to merging the pr !

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 82.48% 📉 -0.010%
Branches branches 76.32% 📉 -0.030%

Coverage data generated from JaCoCo test results

@cowtowncoder cowtowncoder changed the title Honor @JsonValue accessor format with explicit serializers Honor @JsonValue accessor format with explicit serializers Oct 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-needed PR looks good (although may also require code review), but CLA needed from submitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants