Skip to content

Comments

fix(dynamodb-enhanced): Fix NPE in ConverterUtils and EnhancedType for null and wildcard types#6745

Open
abhu85 wants to merge 1 commit intoaws:masterfrom
abhu85:fix/dynamodb-enhanced-null-checks-6639-5890/2026-02-20
Open

fix(dynamodb-enhanced): Fix NPE in ConverterUtils and EnhancedType for null and wildcard types#6745
abhu85 wants to merge 1 commit intoaws:masterfrom
abhu85:fix/dynamodb-enhanced-null-checks-6639-5890/2026-02-20

Conversation

@abhu85
Copy link

@abhu85 abhu85 commented Feb 20, 2026

Summary

This PR fixes two NullPointerException bugs in the DynamoDB Enhanced Client:

  1. Issue NullPointerException in DefaultAttributeConverterProvider when validating null Double values #6639: ConverterUtils.validateDouble() and validateFloat() throw NPE when the input is null due to auto-unboxing before the null check.

  2. Issue NPE when calling hashCode() on wildcard DynamoDB EnhancedType #5890: EnhancedType.hashCode() and equals() throw NPE when dealing with wildcard types like List<?>, where rawClass is null.

Root Cause

Issue #6639

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.

Issue #5890

For wildcard types (e.g., List<?>), EnhancedType stores rawClass = null. The hashCode() method called rawClass.hashCode() and equals() called rawClass.equals() without null checks.

Changes

  • ConverterUtils.java: Add early return for null input in validateDouble() and validateFloat()
  • EnhancedType.java: Add null checks for rawClass in both hashCode() and equals() methods
  • ConverterUtilsTest.java: New test class with 10 tests covering null, valid, NaN, and infinite values
  • EnhancedTypeTest.java: Add 2 tests for wildcard type handling in hashCode() and equals()

Test Plan

  • All 10 new ConverterUtilsTest tests pass
  • All 25 EnhancedTypeTest tests pass (including 2 new tests)
  • Tests verify: null input handling, valid values, NaN rejection, infinity rejection, wildcard equality

Test Commands

./mvnw test -pl services-custom/dynamodb-enhanced -Dtest=ConverterUtilsTest,EnhancedTypeTest
# Tests run: 35, Failures: 0, Errors: 0, Skipped: 0

Fixes #6639
Fixes #5890

…r null values and wildcard types

- Add null checks to ConverterUtils.validateDouble() and validateFloat() to prevent NPE when input is null
- Add null check for rawClass in EnhancedType.hashCode() and equals() to support wildcard types (List<?>)
- Add comprehensive unit tests for null handling

Fixes aws#6639
Fixes aws#5890

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@abhu85 abhu85 requested a review from a team as a code owner February 20, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant