Skip to content

fix(dynamodb-enhanced): Fix NPE in ConverterUtils for null input#6761

Open
abhu85 wants to merge 1 commit intoaws:masterfrom
abhu85:fix/dynamodb-enhanced-converter-utils-npe-6639/2026-03-05
Open

fix(dynamodb-enhanced): Fix NPE in ConverterUtils for null input#6761
abhu85 wants to merge 1 commit intoaws:masterfrom
abhu85:fix/dynamodb-enhanced-converter-utils-npe-6639/2026-03-05

Conversation

@abhu85
Copy link

@abhu85 abhu85 commented Mar 5, 2026

Summary

This PR fixes a NullPointerException bug in the DynamoDB Enhanced Client where ConverterUtils.validateDouble() and validateFloat() throw NPE when the input is null due to auto-unboxing before the null check.

Root Cause

The validateDouble and validateFloat methods used Double.isNaN(input) and Double.isFinite(input) which auto-unbox the Double/Float wrapper to a primitive, causing NPE when input is null.

Changes

  • ConverterUtils.java: Add early return for null input in validateDouble() and validateFloat()
  • ConverterUtils.java: Fix Javadoc typo in validateFloat() ("double" → "float")
  • ConverterUtilsTest.java: New test class with 10 tests covering null, valid, NaN, and infinite values

Test Plan

  • All 10 new ConverterUtilsTest tests pass
  • Tests verify: null input handling, valid values, NaN rejection, infinity rejection

Test Command

./mvnw test -pl services-custom/dynamodb-enhanced -Dtest=ConverterUtilsTest

Fixes #6639


Split from #6745 per maintainer request.

- Add early return for null input in validateDouble() and validateFloat()
- Fix Javadoc typo in validateFloat() ("double" → "float")
- Add comprehensive test coverage for null, valid, NaN, and infinite values

Fixes aws#6639
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.

NullPointerException in DefaultAttributeConverterProvider when validating null Double values

1 participant