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

Null Check for Endpoint Scheme does not work in AWS SDK 2.x S3ClientBuilder #5831

Open
1 task
adityajee opened this issue Jan 28, 2025 · 0 comments
Open
1 task
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@adityajee
Copy link

Describe the bug

We are using a NetApp Grid Storage with the endpoint webscalerdemo.netapp.com, which we passed to the S3ClientBuilder in AWS SDK 1.x (aws-java-sdk-core-1.12.134). In SDK 1.x, the endpoint defaulted to https://, as highlighted in the class documentation.

Image

However, after switching to AWS SDK 2.x (sdk-core-2.25.26), we observed that using the same endpoint in the S3ClientBuilder now requires the scheme (https://) to be explicitly provided. Otherwise, an NPE is thrown with the following message:

The URI scheme of endpointOverride cannot be null

Image

This behavior is inconsistent with the S3AsyncClientBuilder in SDK 2.x, where it is not mandatory to explicitly provide the scheme, as documented here: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/client-configuration.html#client-config-other-diffs. We also use an AsyncClient and did not see any issue without the scheme.

The main issue is, even if the scheme is intended to be mandatory, the check implemented in the SDK does not work as expected. When the endpoint is provided without the scheme, a RuntimeException is thrown with the following stack trace:

Caused by: java.lang.RuntimeException: java.net.URISyntaxException: Expected scheme-specific part at index 24: webscalerdemo.netapp.com:
        at software.amazon.awssdk.utils.FunctionalUtils.asRuntimeException(FunctionalUtils.java:185) 
        at software.amazon.awssdk.utils.FunctionalUtils.lambda$safeSupplier$4(FunctionalUtils.java:110) 
        at software.amazon.awssdk.utils.FunctionalUtils.invokeSafely(FunctionalUtils.java:136) 

The root cause appears to be that calling endpointOverride.getScheme() on webscalerdemo.netapp.com incorrectly returns the host (webscalerdemo.netapp.com) instead of the scheme, leading to the above error.

Regression Issue

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

Expected Behavior

  • Consistent handling of endpoint schemes across both S3ClientBuilder and S3AsyncClientBuilder in SDK 2.x.
  • Proper validation of the endpoint to avoid unexpected runtime exceptions like java.net.URISyntaxException.

Current Behavior

We are getting URISyntaxException at run time.

Reproduction Steps

Create an S3 Client with SDK 2.x and pass the endpoint URL without a scheme, the expectation would be to get an NPE in the client initialization but you will get a RuntimeException when you run the program and try to connect.

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

sdk-core-2.25.26

JDK version used

openjdk version "1.8.0_302"

Operating System and version

Rocky Linux 9.5 (Blue Onyx), Kernel: Linux 5.14.0-427.42.1.el9_4.x86_6

@adityajee adityajee added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 28, 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