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

Enable setting multipart to true/false by defining it as a custom client context parameter #4899

Closed
wants to merge 5 commits into from

Conversation

anirudh9391
Copy link
Contributor

Multipart upload can be set as a client configuration parameter and is accessible at the time of instantiation. This allows classes that instantiate the S3AsyncClient to validate this parameter.

Modifications

1)Incorporated multiPartEnabled as a custom client configuration parameter by defining it in customization.config. The codegen module generates getter and setter methods for this parameter.
2) By default, set multipartEnabled = true in the S3AsyncClient
3) Removed code that sets multiPart Enabled on the client directly

Testing

Unit Tests to validate that

  1. Disabling multiPart code path logs warnings
  2. Default S3AsyncClient has multiPartEnabled = true by default.
  3. Setting MultiPartEnabled = true does not log warnings

Screenshots (if appropriate)

Types of changes

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • [ x] I have read the CONTRIBUTING document
  • [ x] Local run of mvn install succeeds
  • [ x] 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
  • [x ] I have added tests to cover my changes
  • [ x] 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

  • [ x] I confirm that this pull request can be released under the Apache 2 license

@anirudh9391 anirudh9391 requested a review from a team as a code owner February 8, 2024 10:24
@@ -68,7 +64,7 @@ private static Supplier<S3AsyncClient> defaultS3AsyncClient() {
if (crtInClasspath()) {
return S3AsyncClient::crtCreate;
}
return S3AsyncClient::create;
return S3AsyncClient::createWithMultipartEnabled;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return S3AsyncClient::createWithMultipartEnabled;
return () -> S3AsyncClient.builder().multipartEnabled(true).build();

Could we avoid creating the new static method createWithMultipartEnabled on the client and just use this instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah i contemplated using this, just thought it might be neater to create a new one. Sure, i can change it to this, it makes sense to have one lesser static method to have to test

Comment on lines 232 to 239
},
{
"methodName": "createWithMultipartEnabled",
"clientType": "async",
"instanceType": "software.amazon.awssdk.services.s3.S3AsyncClient",
"returnType": "software.amazon.awssdk.services.s3.S3AsyncClient",
"statement": "builder().multipartEnabled(true).build()",
"javaDoc": "Create a {@link S3AsyncClient} with multi-part operations enabled"
Copy link
Contributor

Choose a reason for hiding this comment

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

see other comment about static method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. I can change this

Comment on lines -36 to -37
public static final AttributeMap.Key<Boolean> MULTIPART_ENABLED_KEY =
new AttributeMap.Key<Boolean>(Boolean.class){};
Copy link
Contributor

@L-Applin L-Applin Feb 8, 2024

Choose a reason for hiding this comment

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

If we dont need it anymore, we should also remove it from customization.config: "contextParamEnabledKey": "S3AsyncClientDecorator.MULTIPART_ENABLED_KEY" ln245

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah okay. I missed that one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it

@anirudh9391 anirudh9391 changed the base branch from master to feature/master/s3mpu February 8, 2024 18:50
@anirudh9391 anirudh9391 changed the base branch from feature/master/s3mpu to master February 8, 2024 18:52
@anirudh9391 anirudh9391 changed the base branch from master to feature/master/s3mpu February 8, 2024 20:18
@anirudh9391 anirudh9391 changed the base branch from feature/master/s3mpu to master February 8, 2024 20:22
@anirudh9391 anirudh9391 changed the base branch from master to feature/master/s3mpu February 8, 2024 20:24
@anirudh9391 anirudh9391 changed the base branch from feature/master/s3mpu to master February 8, 2024 20:24
@anirudh9391 anirudh9391 changed the base branch from master to feature/master/s3mpu February 8, 2024 20:31
@anirudh9391 anirudh9391 changed the base branch from feature/master/s3mpu to master February 8, 2024 20:38
Copy link

sonarcloud bot commented Feb 8, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
57.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@anirudh9391 anirudh9391 closed this Feb 8, 2024
@anirudh9391 anirudh9391 deleted the anirudkr-multipart branch February 8, 2024 21:19
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.

2 participants