fix(dynamodb-enhanced): Fix NPE in ConverterUtils and EnhancedType for null and wildcard types#6745
Open
abhu85 wants to merge 1 commit intoaws:masterfrom
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two NullPointerException bugs in the DynamoDB Enhanced Client:
Issue NullPointerException in DefaultAttributeConverterProvider when validating null Double values #6639:
ConverterUtils.validateDouble()andvalidateFloat()throw NPE when the input isnulldue to auto-unboxing before the null check.Issue NPE when calling hashCode() on wildcard DynamoDB EnhancedType #5890:
EnhancedType.hashCode()andequals()throw NPE when dealing with wildcard types likeList<?>, whererawClassisnull.Root Cause
Issue #6639
The
validateDoubleandvalidateFloatmethods usedDouble.isNaN(input)andDouble.isFinite(input)which auto-unbox theDouble/Floatwrapper to a primitive, causing NPE when input isnull.Issue #5890
For wildcard types (e.g.,
List<?>),EnhancedTypestoresrawClass = null. ThehashCode()method calledrawClass.hashCode()andequals()calledrawClass.equals()without null checks.Changes
validateDouble()andvalidateFloat()rawClassin bothhashCode()andequals()methodshashCode()andequals()Test Plan
ConverterUtilsTesttests passEnhancedTypeTesttests pass (including 2 new tests)Test Commands
Fixes #6639
Fixes #5890