Skip to content

Fix NPE in DoubleAttributeConverter and FloatAttributeConverter for null input#6782

Open
S-Saranya1 wants to merge 2 commits intomasterfrom
somepal/fix-dynamoDB-enhanced-double-float-converter-npe
Open

Fix NPE in DoubleAttributeConverter and FloatAttributeConverter for null input#6782
S-Saranya1 wants to merge 2 commits intomasterfrom
somepal/fix-dynamoDB-enhanced-double-float-converter-npe

Conversation

@S-Saranya1
Copy link
Contributor

@S-Saranya1 S-Saranya1 commented Mar 11, 2026

DoubleAttributeConverter.transformFrom() and FloatAttributeConverter.transformFrom() throw a NullPointerException when called with a null input due to auto-unboxing in ConverterUtils.validateDouble()/validateFloat(). This occurs when users persist a Map<String, Double> or List containing null values.

Motivation and Context

  • Added null check in DoubleAttributeConverter.transformFrom() to return nullAttributeValue() for null input
  • Added null check in FloatAttributeConverter.transformFrom() to return nullAttributeValue() for null input
  • This follows the existing pattern used by StringAttributeConverter

Modifications

  • Added null input assertions in NumberAttributeConvertersTest for both DoubleAttributeConverter and FloatAttributeConverter
  • Existing tests continue to pass

Testing

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@S-Saranya1 S-Saranya1 requested a review from a team as a code owner March 11, 2026 22:04
@sonarqubecloud
Copy link

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.

1 participant