Skip to content

HDDS-15950. Fix NPE in S3 lifecycle GET for date-based expiration#10850

Merged
ChenSammi merged 1 commit into
apache:masterfrom
priyeshkaratha:HDDS-15950
Jul 24, 2026
Merged

HDDS-15950. Fix NPE in S3 lifecycle GET for date-based expiration#10850
ChenSammi merged 1 commit into
apache:masterfrom
priyeshkaratha:HDDS-15950

Conversation

@priyeshkaratha

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

When converting an Ozone lifecycle configuration back to the S3 response model, convertFromOzoneExpiration and
convertFromOzoneAbortIncompleteMultipartUpload called getDays() and getDaysAfterInitiation() directly in a > 0 comparison. These accessors return boxed Integer values that are null for date-based rules (which
have a Date but no Days), so unboxing threw a NullPointerException on a GET of the lifecycle configuration.

This adds a null check before the > 0 comparison 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

@priyeshkaratha
priyeshkaratha marked this pull request as ready for review July 23, 2026 16:44
@priyeshkaratha
priyeshkaratha requested a review from ChenSammi July 23, 2026 16:44
@ChenSammi
ChenSammi requested a review from Copilot July 24, 2026 09:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 > 0 comparisons in lifecycle conversion for Expiration and AbortIncompleteMultipartUpload.
  • 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 ChenSammi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @priyeshkaratha , LGTM.

@ChenSammi
ChenSammi merged commit ed072a9 into apache:master Jul 24, 2026
59 checks passed
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.

3 participants