Skip to content

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

Open
@adityajee

Description

@adityajee

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

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closing-soonThis issue will close in 4 days unless further comments are made.p2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 10 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions