Skip to content

Fix AtomicLongDeserializer value truncation on coerced values#5931

Merged
cowtowncoder merged 1 commit intoFasterXML:3.xfrom
dlwldnjs1009:fix/atomiclong-intvalue-truncation-3.x
Apr 20, 2026
Merged

Fix AtomicLongDeserializer value truncation on coerced values#5931
cowtowncoder merged 1 commit intoFasterXML:3.xfrom
dlwldnjs1009:fix/atomiclong-intvalue-truncation-3.x

Conversation

@dlwldnjs1009
Copy link
Copy Markdown
Contributor

@dlwldnjs1009 dlwldnjs1009 commented Apr 20, 2026

AtomicLongDeserializer converts through Long.intValue() on the _parseLong(...) path, which silently truncates coerced values above Integer.MAX_VALUE.

This changes that path to use Long.longValue() and adds regression
tests for String and floating-point inputs above Integer.MAX_VALUE.

Testing:

  • ./mvnw -q -Dtest=tools.jackson.databind.deser.jdk.JDKAtomicTypesDeserTest test

`AtomicLongDeserializer` used `Long.intValue()` on the `_parseLong(...)`
path, which truncated values above `Integer.MAX_VALUE` for coerced String
and floating-point inputs.

Use `Long.longValue()` instead and add regression tests for both cases.
@github-actions
Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.58% 📈 +0.000%
Branches branches 74.87% 📈 +0.010%

Coverage data generated from JaCoCo test results

// 12-Jun-2020, tatu: May look convoluted, but need to work correctly with
// CoercionConfig
Long L = _parseLong(p, ctxt, AtomicLong.class);
return (L == null) ? null : new AtomicLong(L.intValue());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa. Good catch!

@cowtowncoder
Copy link
Copy Markdown
Member

Will merge and then backport in 3.1.

@cowtowncoder cowtowncoder merged commit b5ace8d into FasterXML:3.x Apr 20, 2026
6 checks passed
@cowtowncoder cowtowncoder changed the title Fix AtomicLongDeserializer truncation on coerced values Fix AtomicLongDeserializer value truncation on coerced values Apr 20, 2026
cowtowncoder pushed a commit that referenced this pull request Apr 20, 2026
`AtomicLongDeserializer` used `Long.intValue()` on the `_parseLong(...)`
path, which truncated values above `Integer.MAX_VALUE` for coerced String
and floating-point inputs.

Use `Long.longValue()` instead and add regression tests for both cases.
cowtowncoder added a commit that referenced this pull request Apr 20, 2026
@dlwldnjs1009 dlwldnjs1009 deleted the fix/atomiclong-intvalue-truncation-3.x branch April 20, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants