title: S3AsyncClient throws java.lang.NullPointerException with every region endpoint?
body: <p>I am trying to upload a file to an AWS Bucket in ap-southeast-1 region, The credentials have been verified and are correct.</p>
  
  <p>The S3AsyncClientBuilder throws the null pointer exception for every region endpoint.
  (<a href="https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region" rel="nofollow noreferrer">https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region</a>)</p>
  
  <p>A related thread at github had trouble while signing the region but that was not an issue here, Once the appropriate region was specified.</p>
  
  <p><a href="https://github.com/aws/aws-sdk-java-v2/issues/448" rel="nofollow noreferrer">https://github.com/aws/aws-sdk-java-v2/issues/448</a></p>
  
  <p>Here is the class that accesses the AWS Bucket, the line has been commented for clarity. </p>
  
  <pre><code>public class ObjectUploaderInterfaceImpl implements ObjectUploaderInterface {
  
  
    private String AWS_ACCESS_KEY;
    private String AWS_SECRET_KEY;
    private S3AsyncClient s3Client; // Asynchronous Client for Non Blocking IO
    private AwsCredentialsProvider credentials;
  
    public ObjectUploaderInterfaceImpl(String awsAccessKey, String awsSecretKey) {
      this.AWS_ACCESS_KEY = awsAccessKey;
      this.AWS_SECRET_KEY = awsSecretKey;
      this.credentials = new StaticCredentialsProvider(
          new AwsCredentials(this.AWS_ACCESS_KEY, this.AWS_SECRET_KEY));
      try {
        this.s3Client = S3AsyncClient.builder()
            .credentialsProvider(this.credentials)
            .region(Region.AP_SOUTHEAST_1)
            .endpointOverride(new URI("s3-ap-southeast-1.amazonaws.com"))
            .build(); // Throws Null pointer Exception
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  
    @Override
    public CompletableFuture&lt;PutObjectResponse&gt; uploadObject(String filePath, String s3Bucket,
        String s3BucketPath) {
      CompletableFuture&lt;PutObjectResponse&gt; future;
      try {
        future = s3Client.putObject(
            PutObjectRequest.builder()
                .bucket(s3Bucket)
                .key(s3BucketPath)
                .build(),
            AsyncRequestProvider.fromFile(Paths.get(filePath))
        );
        future.whenComplete((resp, err) -&gt; {
          if (resp != null) {
            System.out.println("Response from Server : " + resp);
          } else {
            err.printStackTrace();
          }
          try {
            s3Client.close();
          } catch (Exception e) {
            System.out.println(e);
          }
  
        });
      } catch (Exception e) {
        System.out.println(e.getMessage());
        return null;
      }
      return future;
  
    }
  }
  </code></pre>
  
  <p><strong>The Exception Stack is as follows</strong> </p>
  
  <pre><code>    java.lang.NullPointerException
          at software.amazon.awssdk.config.ImmutableClientConfiguration.lambda$schemeToProtocol$3(ImmutableClientConfiguration.java:141)
          at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
          at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
          at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
          at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
          at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
          at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
          at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
          at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
          at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
          at software.amazon.awssdk.config.ImmutableClientConfiguration.schemeToProtocol(ImmutableClientConfiguration.java:141)
          at software.amazon.awssdk.config.ImmutableClientConfiguration.initializeLegacyConfiguration(ImmutableClientConfiguration.java:110)
          at software.amazon.awssdk.config.ImmutableClientConfiguration.&lt;init&gt;(ImmutableClientConfiguration.java:48)
          at software.amazon.awssdk.config.ImmutableAsyncClientConfiguration.&lt;init&gt;(ImmutableAsyncClientConfiguration.java:42)
          at software.amazon.awssdk.client.builder.DefaultClientBuilder.asyncClientConfiguration(DefaultClientBuilder.java:216)
          at software.amazon.awssdk.services.s3.DefaultS3AsyncClientBuilder.buildClient(DefaultS3AsyncClientBuilder.java:28)
          at software.amazon.awssdk.services.s3.DefaultS3AsyncClientBuilder.buildClient(DefaultS3AsyncClientBuilder.java:22)
          at software.amazon.awssdk.client.builder.DefaultClientBuilder.build(DefaultClientBuilder.java:110)
          at services.storage.Implementation.ObjectUploaderInterfaceImpl.&lt;init&gt;(ObjectUploaderInterfaceImpl.java:41)
          at services.storage.ObjectUploaderInterfaceTest.&lt;init&gt;(ObjectUploaderInterfaceTest.java:12)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  null
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  [error] Test services.storage.ObjectUploaderInterfaceTest.uploadTest failed: java.lang.NullPointerException: null, took 0.008 sec
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  </code></pre>
  
  <p>I am not sure what might cause this, there has been a little reference available in the documentation since AWS-SDK 2.0's recent release.</p>