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

Java S3 SDK deleteObjects return 302 #3178

Open
1 of 2 tasks
Dawanyezhi opened this issue Mar 12, 2025 · 0 comments
Open
1 of 2 tasks

Java S3 SDK deleteObjects return 302 #3178

Dawanyezhi opened this issue Mar 12, 2025 · 0 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@Dawanyezhi
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

I am using AWS Java S3 SDK, the SDK version is 2.27.21, when implementing upload, download, and delete, the client has the same configuration information, uploading, downloading, and deleting have no problem, but when calling deleteObjects, 302 is returned. The request ID is null and the code is as follows:
List deleteObjects = fileKeys.stream().map(fileKey -> ObjectIdentifier.builder().key(fileKey).build())
.collect(Collectors.toList());
Delete batchDelete = Delete.builder().objects(deleteObjects).build();
DeleteObjectsRequest batchDeleteRequest = DeleteObjectsRequest.builder()
.bucket(bucketName).delete(batchDelete)
.build();
DeleteObjectsResponse response = s3Client.deleteObjects(batchDeleteRequest);
What is the reason why only deleteObjects return 302, and the single deleteObject is fine

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

delete success

Current Behavior

throw Exception:software.amazon.awssdk.services.s3.model.S3Exception: (Service: S3, Status Code: 302, Request ID: null)

Reproduction Steps

this.s3Client = S3Client.builder()
.credentialsProvider(credentials)
.region(region)
.httpClient(sdkHttpClient)
.build();
List deleteObjects = fileKeys.stream().map(fileKey -> ObjectIdentifier.builder().key(fileKey).build())
.collect(Collectors.toList());
Delete batchDelete = Delete.builder().objects(deleteObjects).build();
DeleteObjectsRequest batchDeleteRequest = DeleteObjectsRequest.builder()
.bucket(bucketName).delete(batchDelete)
.build();
DeleteObjectsResponse response = s3Client.deleteObjects(batchDeleteRequest);

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

2.27.21

JDK version used

8

Operating System and version

mac

@Dawanyezhi Dawanyezhi added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 12, 2025
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. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant