HDDS-15950. Fix NPE in S3 lifecycle GET for date-based expiration#10850
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a NullPointerException in S3 Gateway lifecycle configuration GET responses when handling date-based expiration (where Days is absent and Date is present), by guarding boxed Integer comparisons and adding coverage.
Changes:
- Add null checks before
> 0comparisons in lifecycle conversion forExpirationandAbortIncompleteMultipartUpload. - Add a unit test that PUTs a date-based expiration rule and verifies GET returns the expected date with
Days == null.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3LifecycleConfiguration.java | Prevents NPE by guarding boxed Integer fields during conversion from Ozone lifecycle model to S3 response model. |
| hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestS3LifecycleConfigurationGet.java | Adds regression coverage for date-based expiration rules being returned correctly via GET. |
Comments suppressed due to low confidence (1)
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/S3LifecycleConfiguration.java:504
getDaysAfterInitiation()is called multiple times in the condition and again when setting the value. Cache it in a local variable to avoid duplicated calls and to guarantee the checked value is the one being set.
AbortIncompleteMultipartUpload abortIncompleteMultipartUpload = new AbortIncompleteMultipartUpload();
if (ozoneAbortIncompleteMultipartUpload.getDaysAfterInitiation() != null
&& ozoneAbortIncompleteMultipartUpload.getDaysAfterInitiation() > 0) {
abortIncompleteMultipartUpload.setDaysAfterInitiation(
ozoneAbortIncompleteMultipartUpload.getDaysAfterInitiation());
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ChenSammi
approved these changes
Jul 24, 2026
ChenSammi
left a comment
Contributor
There was a problem hiding this comment.
Thanks @priyeshkaratha , LGTM.
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.
What changes were proposed in this pull request?
When converting an Ozone lifecycle configuration back to the S3 response model,
convertFromOzoneExpirationandconvertFromOzoneAbortIncompleteMultipartUploadcalledgetDays()andgetDaysAfterInitiation()directly in a> 0comparison. These accessors return boxedIntegervalues that arenullfor date-based rules (whichhave a
Datebut noDays), so unboxing threw aNullPointerExceptionon aGETof the lifecycle configuration.This adds a null check before the
> 0comparison in both methods so date-based expiration rules are returned correctly.What is the link to the Apache JIRA
HDDS-15950
How was this patch tested?
Tested using added unit test