Skip to content

AWS v2 SDK not working without https proxy specified #2983

Open
@xiangfei8

Description

@xiangfei8

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.<init>(ProxyConfiguration.java:66)
                at software.amazon.awssdk.http.apache.ProxyConfiguration.<init>(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.<init>(ApacheHttpClient.java:427)
                at software.amazon.awssdk.http.apache.ApacheHttpClient$DefaultBuilder.<init>(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

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.needs-discussionThis issue/PR requires more discussion with community.p3This is a minor priority issueproxyThis issue is related to a proxy configuration

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions