Skip to content

Fix #6469: handle non-finite numbers in POJONode decimal accessors - #6470

Open
Marti2203 wants to merge 1 commit into
FasterXML:3.xfrom
Marti2203:pojonode-decimal-opt-nan
Open

Marti2203 wants to merge 1 commit into
FasterXML:3.xfrom
Marti2203:pojonode-decimal-opt-nan

Conversation

@Marti2203

Copy link
Copy Markdown
Contributor

Fixes #6469.

For a POJONode wrapping NaN or an infinity, _extractAsBigDecimal() returns null; asDecimalOpt() passed it to Optional.of() and threw NullPointerException, and asDecimal() / asDecimal(defaultValue) returned null. They now behave like NumericFPNode for NaN: Optional.empty(), the default value, and _reportBigDecimalConversionNaNFail("asDecimal()").

Adds POJONodeTest.testDecimalAccessorsForNonFinite(), which fails without the change. The full 3.x test suite passes; release notes and credits updated.

This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually.

…ccessors

`_extractAsBigDecimal()` returns `null` for NaN and infinities, which
`asDecimalOpt()` passed to `Optional.of()` (NPE) and `asDecimal()` /
`asDecimal(defaultValue)` returned. Return `Optional.empty()`, the default
value, and a NaN conversion failure, as `NumericFPNode` does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gitar-bot

gitar-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Changing POJONode decimal accessors for NaN and infinities alters caller-visible results; callers may get empty, fallback, or a conversion exception instead of null/NPE.

Fixes POJONode decimal accessors so NaN and infinite values no longer throw NullPointerException in asDecimalOpt() and no longer return null from asDecimal(), matching NumericFPNode behavior with Optional.empty(), the default value, and the NaN conversion failure. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

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

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

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 83.38% 📈 +0.000%
Branches branches 77.82% 📈 +0.020%

Coverage data generated from JaCoCo test results

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

POJONode.asDecimalOpt() throws NPE for a wrapped NaN (and asDecimal() variants return null)

1 participant