Skip to content

Fix DurationAttributeConverter negative fractional durations#7067

Open
arnabnandy7 wants to merge 3 commits into
aws:masterfrom
arnabnandy7:fix/duration-converter-nanos
Open

Fix DurationAttributeConverter negative fractional durations#7067
arnabnandy7 wants to merge 3 commits into
aws:masterfrom
arnabnandy7:fix/duration-converter-nanos

Conversation

@arnabnandy7

Copy link
Copy Markdown

Motivation and Context

Fixes #7060

DurationAttributeConverter incorrectly serialized negative fractional durations because Java represents them with negative seconds and positive nanos. For example, Duration.ofMillis(-1) was serialized as -1.999000000 instead of -0.001000000.

Modifications

Updated DurationAttributeConverter to correctly serialize negative fractional Duration values using their mathematical signed decimal representation.

Also updated parsing logic so number strings like -0.001000000 are converted back to negative durations instead of positive ones.

Added regression tests for:

  • Negative fractional serialization
  • Negative fractional parsing
  • No-padding negative fractional parsing
  • Duration round trips

Testing

Ran:

mvn -Dtest=DurationAttributeConverterTest test

Screenshots (if appropriate)

N/A

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

@arnabnandy7 arnabnandy7 requested a review from a team as a code owner June 23, 2026 19:58
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.

DynamoDB Enhanced - DurationAttributeConverter incorrectly converts negative durations with nanosecond offsets

1 participant