aws / aws/aws-sdk-java-v2

AWS v2 SDK not working without https proxy specified

Open
#2,983 24 comments 0 reactions 1 assignee Claimed by @debora-ito View on GitHub
bug needs-discussion p3 proxy
Dominant language
Java
Stars
2.6k
Forks
1k
Avg merge
2d 9h
Merged PRs (30d)
51

Description

### Describe the issue

configure proxy pathway as what is inside the IF statement below is working fine.
if (isProxyDefined) {
httpClient = ApacheHttpClient.builder()
.proxyConfiguration(ProxyConfiguration.builder()
.useSystemPropertyValues(false)
.endpoint(URI.create((new StringBuffer().append("http://")
.append(envHttpsProxyHost)
.append(":")
.append(envHttpsProxyPort)).toString()))
.build())
.build();
} else {
httpClient = ApacheHttpClient.builder()
.build();
}

I recently try to deploy the software to an environment without proxy needed, and I confirm it is getting inside the ELSE statement. But I am consistently getting the following stack trace. Why is the sdk giving a "java.lang.NumberFormatException" trying to look for a port that is not defined anyway? Is there another API call I should be using instead for a no proxy environment?

java.lang.NumberFormatException: For input string: ""
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:662)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at java.base/java.util.Optional.map(Optional.java:265)
at software.amazon.awssdk.http.apache.ProxyConfiguration.resolvePort(ProxyConfiguration.java:199)
at software.amazon.awssdk.http.apache.ProxyConfiguration.(ProxyConfiguration.java:66)
at software.amazon.awssdk.http.apache.ProxyConfiguration.(ProxyConfiguration.java:38)
at software.amazon.awssdk.http.apache.ProxyConfiguration$DefaultClientProxyConfigurationBuilder.build(ProxyConfiguration.java:407)
at software.amazon.awssdk.http.apache.ProxyConfiguration$DefaultClientProxyConfigurationBuilder.build(ProxyConfiguration.java:298)
at software.amazon.awssdk.http.apache.ApacheHttpClient$DefaultBuilder.(ApacheHttpClient.java:427)
at software.amazon.awssdk.http.apache.ApacheHttpClient$DefaultBuilder.(ApacheHttpClient.java:425)
at software.amazon.awssdk.http.apache.ApacheHttpClient.builder(ApacheHttpClient.java:133)
at

As you can see, this issue is coming from software.amazon.awssdk.http.apache.ProxyConfiguration.

### Steps to Reproduce

Make a STS call in an environment that have no proxy set up.

StsClient getStsClient(AwsBasicCredentials awsCreds) {
return StsClient.builder()
.credentialsProvider(StaticCredentialsProvider.create(awsCreds))
.region(Region.of(awsS3BucketRegion))
.build();
}

OR

StsClient getStsClient(AwsBasicCredentials awsCreds) {
return StsClient.builder()
.credentialsProvider(StaticCredentialsProvider.create(awsCreds))
.region(Region.of(awsS3BucketRegion))
.httpClient(ApacheHttpClient.builder().build())
.build();
}

### Current behavior

get runtime exception: java.lang.NumberFormatException: For input string: ""
detail stack is in the description

### AWS Java SDK version used

2.14.18, I also tried 2.17.115

### JDK version used

openjdk-11-5-5

### Operating System and version

debian:10.3-slim

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.