-
Notifications
You must be signed in to change notification settings - Fork 890
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
Change response types for POJOs that map one to many #6024
base: master
Are you sure you want to change the base?
Conversation
@@ -253,7 +253,7 @@ private void singleBucketArgMethods(S3Client s3, String bucket) { | |||
s3.getBucketPolicy(GetBucketPolicyRequest.builder().bucket(bucket) | |||
.build()); | |||
s3.getBucketLocation(GetBucketLocationRequest.builder().bucket(bucket) | |||
.build()); | |||
.build()).locationConstraint().toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update it to return a variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its covered it in S3RequestConstructor
Line 264 in 157dd10
String region = s3.getBucketLocation(GetBucketLocationRequest.builder().bucket(bucketName) |
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
|
||
/** | ||
* This recipe is forked from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we follow https://github.com/aws/aws-sdk-java-v2/blob/master/http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/nrs/HandlerSubscriber.java#L33 (provide time and link to the exact commit)
|
Motivation and Context
There are a handful of POJOs in v1 that map to two types in v2. For instance, v1
AccessControlList
is used as input tosetObjectAcl()
, and also returned as response fromgetObjectAcl()
.In v2,
AccessControlPolicy
is used as input, whileGetObjectAclResponse
is returned as the response.Modifications
Forked
ChangeMethodInvocationReturnType
recipe from OpenRewrite. It is a newer recipe so requires OR version bump, which introduces breaking changes with existing SDK recipes.https://github.com/openrewrite/rewrite/blob/main/rewrite-java/src/main/java/org/openrewrite/java/ChangeMethodInvocationReturnType.java
Using this recipe to correctly change response types based on the method, returning the following responses:
Additional changes:
AmazonS3Exception
toS3Exception
BucketLoggingConfiguration
toBucketLoggingStatus
CannedAccessControlList
toObjectCannedACL
BucketCannedACL
orObjectCannedACL
BucketName
withBucket
in getter methods (already in place for setters)getBucketLocation()
to appendlocationConstraint().toString()
as v1 returns the String regionTesting
Added end to end tests