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

Convert ByteBuffer to SdkBytes #5798

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zoewangg
Copy link
Contributor

Motivation and Context

Similar to #5791 Java SDK v1 uses ByteBuffer to represent binary data while Java SDK v2 uses SdkBytes, so changing the method name is not sufficient for ByteBuffer setters and users will get compilation error.

v1

        MessageAttributeValue messageAttributeValue = new MessageAttributeValue()
            .withBinaryValue(buffer);

to
v2

        MessageAttributeValue messageAttributeValue = MessageAttributeValue.builder()
            .binaryValue(SdkBytes.fromByteBuffer(buffer))
            .build();

Modifications

Convert ByteBuffer to SdkBytes for POJO setters

Testing

Added end to end tests
Unit tests are not possible for JavaTemplate since it can't recognize the types.

Screenshots (if appropriate)

Types of changes

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

Checklist

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

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

@zoewangg zoewangg requested a review from a team as a code owner January 15, 2025 19:42
@zoewangg zoewangg force-pushed the zoewang/ByteBufferToSdkBytes branch from cac5f3d to 0eed4fa Compare January 15, 2025 23:49
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.v2migration.internal.utils.SdkTypeUtils;

@SdkInternalApi
Copy link
Contributor

@Fred1155 Fred1155 Jan 16, 2025

Choose a reason for hiding this comment

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

This class should be in internal package 👀

Copy link
Contributor Author

@zoewangg zoewangg Jan 16, 2025

Choose a reason for hiding this comment

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

We don't actually expect customers to consume those classes directly, and they are used indirectly when users run OpenRewrite command, so technically those SDK annotations are not needed (and those recipe classes are not part of the SDK). I can remove them in a separate PR to avoid confusion

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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