Skip to content

Validate number length when coercing String to double - #6179

Merged
cowtowncoder merged 3 commits into
FasterXML:3.1from
aysha-afrah26:double-fplength-limit
Sep 1, 2026
Merged

Validate number length when coercing String to double#6179
cowtowncoder merged 3 commits into
FasterXML:3.1from
aysha-afrah26:double-fplength-limit

Conversation

@aysha-afrah26

Copy link
Copy Markdown
Contributor

When a JSON string is coerced to a double, the value goes through StdDeserializer._parseDoublePrimitive, which hands the text straight to the double parser. Its sibling _parseFloatPrimitive, right above it, first checks NumberInput.looksLikeValidNumber and then calls streamReadConstraints().validateFPLength() so the configured maxNumberLength limit applies before parsing, but the double variant skips both. The effect is that float[] rejects an over-length numeric string while double[], OptionalDouble, and the general String-to-double coercion accept it, so a length limit the user configures is not honored on those paths. I noticed it while comparing the two primitive helpers, since every integer-family helper in the same class already validates length the same way. The fix applies the same pre-validation to the double path so both behave alike. Added a test in the deser/dos package covering double[], alongside float[] which already enforces the limit.

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.44% 📈 +0.010%
Branches branches 74.76% 📈 +0.000%

Coverage data generated from JaCoCo test results

Comment thread src/main/java/tools/jackson/databind/deser/std/StdDeserializer.java
@cowtowncoder cowtowncoder changed the title validate number length when coercing String to double Validate number length when coercing String to double Aug 31, 2026
Comment thread src/main/java/tools/jackson/databind/deser/std/StdDeserializer.java
Comment on lines +14 to +16
// Number-length constraint (StreamReadConstraints.maxNumberLength) must be enforced
// when coercing a String to `double` the same way it already is for `float`.
public class DoubleFPLengthConstraintTest

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.

Adding issue related-comments like

// [databind#6179] ... remaning description

..... this is convential.

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.

Speaking of which, no issue open?
It would be great if you could open an issue @aysha-afrah26 👍

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.44% 📈 +0.010%
Branches branches 74.77% 📈 +0.010%

Coverage data generated from JaCoCo test results

@gitar-bot

gitar-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Adds validation of number length when coercing String to double, matching the behavior already implemented for float and all integer-family helpers. This ensures the configured maxNumberLength limit is consistently enforced across double[], OptionalDouble, and general String-to-double coercion paths. No issues found.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

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

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.44% 📈 +0.010%
Branches branches 74.77% 📈 +0.010%

Coverage data generated from JaCoCo test results

@cowtowncoder
cowtowncoder merged commit d16ef91 into FasterXML:3.1 Sep 1, 2026
7 checks passed
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.

4 participants