Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListNextBatchOfObjectsRequest does not retain RequestCredentialsProvider #3101

Open
1 task done
jodastephen opened this issue Mar 20, 2024 · 1 comment
Open
1 task done
Labels
bug This issue is a bug. p3 This is a minor priority issue

Comments

@jodastephen
Copy link

Upcoming End-of-Support

  • I acknowledge the upcoming end-of-support for AWS SDK for Java v1 was announced, and migration to AWS SDK for Java v2 is recommended.

Describe the bug

The method AmazonS3Client::listNextBatchOfObjects(ListNextBatchOfObjectsRequest) takes a standard request object that contains the property RequestCredentialsProvider (inherited from AmazonWebServiceRequest). However, the implementation uses the method ListNextBatchOfObjectsRequest::toListObjectsRequest() which does not copy the credentials provider (and other properties) to the ListObjectsRequest. As a result, our code failed to have the correct credentials to query S3.

Expected Behavior

The code should copy the request credentials across. The class ListNextBatchOfVersionsRequest does this correctly.

Current Behavior

This is the broken code in ListNextBatchOfObjectsRequest:

    public ListObjectsRequest toListObjectsRequest() {
        return new ListObjectsRequest(previousObjectListing.getBucketName(),
                previousObjectListing.getPrefix(),
                previousObjectListing.getNextMarker(),
                previousObjectListing.getDelimiter(),
                Integer.valueOf(previousObjectListing.getMaxKeys()))
                .withEncodingType(previousObjectListing.getEncodingType());
    }

This is the correct kind of code in ListNextBatchOfVersionsRequest, note how the extra properties are copied across:

    public ListVersionsRequest toListVersionsRequest() {
        ListVersionsRequest result = new ListVersionsRequest(previousVersionListing.getBucketName(),
                                                             previousVersionListing.getPrefix(),
                                                             previousVersionListing.getNextKeyMarker(),
                                                             previousVersionListing.getNextVersionIdMarker(),
                                                             previousVersionListing.getDelimiter(),
                                                             previousVersionListing.getMaxKeys())
            .withEncodingType(previousVersionListing.getEncodingType())
            .withRequestCredentialsProvider(getRequestCredentialsProvider())
            .withGeneralProgressListener(getGeneralProgressListener())
            .withRequestMetricCollector(getRequestMetricCollector());

        Integer sdkClientExecutionTimeout = getSdkClientExecutionTimeout();
        if (sdkClientExecutionTimeout != null) {
            result.setSdkClientExecutionTimeout(sdkClientExecutionTimeout);
        }

        Integer sdkRequestTimeout = getSdkRequestTimeout();
        if (sdkClientExecutionTimeout != null) {
            result.setSdkRequestTimeout(sdkRequestTimeout);
        }

        return result;
    }

Reproduction Steps

No need for SSCCE. Information above is sufficient.

Possible Solution

No response

Additional Information/Context

The git repo shows the code is still broken
https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/model/ListNextBatchOfObjectsRequest.java#L74

AWS Java SDK version used

1.12.609

JDK version used

8

Operating System and version

Windows 11

@jodastephen jodastephen added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2024
@debora-ito
Copy link
Member

@jodastephen bug acknowledged. But we probably won't fix it before maintenance mode phase.

The recommendation here is to use Java SDK v2 built-in Paginators -
https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/s3/S3Client.html#listObjectsV2Paginator(java.util.function.Consumer)

@debora-ito debora-ito removed the needs-triage This issue or PR still needs to be triaged. label Mar 29, 2024
@debora-ito debora-ito added the p3 This is a minor priority issue label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

2 participants