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

IP address & port w/o scheme in endpoint ⇒ URISyntaxException/IllegalArgumentException from EndpointToRegion.guessRegionOrRegionNameForEndpoint #2255

Closed
jglick opened this issue Mar 6, 2020 · 4 comments · Fixed by #2256
Labels
bug This issue is a bug.

Comments

@jglick
Copy link
Contributor

jglick commented Mar 6, 2020

Describe the bug

If you pass a custom endpoint in the format 127.0.0.1:1234 to the SDK, the client builder will fail.

Expected Behavior

Should behave similarly to if a hostname such as localhost is used, or if an IP address is used without an explicit port, or if a full URL with scheme is passed.

Current Behavior

You get an error such as

java.lang.IllegalArgumentException: Illegal character in scheme name at index 0: 127.0.0.1:38835
	at java.base/java.net.URI.create(URI.java:883)
	at com.amazonaws.regions.EndpointToRegion.guessRegionOrRegionNameForEndpoint(EndpointToRegion.java:71)
	at com.amazonaws.regions.EndpointToRegion.guessRegionNameForEndpoint(EndpointToRegion.java:41)
	at com.amazonaws.AmazonWebServiceClient.setEndpoint(AmazonWebServiceClient.java:323)
	at com.amazonaws.services.s3.AmazonS3Client.setEndpoint(AmazonS3Client.java:725)
	at com.amazonaws.client.builder.AwsClientBuilder.setRegion(AwsClientBuilder.java:453)
	at com.amazonaws.client.builder.AwsClientBuilder.configureMutableProperties(AwsClientBuilder.java:424)
	at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
	at …
Caused by: java.net.URISyntaxException: Illegal character in scheme name at index 0: 127.0.0.1:38835
	at java.base/java.net.URI$Parser.fail(URI.java:2913)
	at java.base/java.net.URI$Parser.checkChars(URI.java:3084)
	at java.base/java.net.URI$Parser.checkChar(URI.java:3094)
	at java.base/java.net.URI$Parser.parse(URI.java:3109)
	at java.base/java.net.URI.<init>(URI.java:600)
	at java.base/java.net.URI.create(URI.java:881)
	... 23 more

Steps to Reproduce

Reproduced in jenkinsci/artifact-manager-s3-plugin#112.

Possible Solution

PR forthcoming.

Context

Broke integration testing of the Jenkins plugin to store artifacts in S3 against a MinIO mock server running in a local Docker container.
The test passed against 1.11.700 and failed against 1.11.723, with the introduction of EndpointToRegion.

Your Environment

  • AWS Java SDK version used: 1.11.700 vs. 1.11.723
  • JDK version used: 8 or 11
  • Operating System and version: various Linux
@jglick jglick added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 6, 2020
@debora-ito
Copy link
Member

@jglick can you share a code snippet where your getAmazonS3ClientBuilder() gets called? Or a self-contained code sample?

I was not able to reproduce by your bug description, the client builder in my tests does not fail.

@debora-ito debora-ito added response-requested Waiting on additional info or feedback. Will move to "closing-soon" in 5 days. and removed needs-triage This issue or PR still needs to be triaged. labels Mar 11, 2020
@jglick
Copy link
Contributor Author

jglick commented Mar 11, 2020

@debora-ito I think #2256 should cover it. If you want something in a much bigger but more realistic context, I could work up instructions on running the test in jenkinsci/artifact-manager-s3-plugin@46898c5 or you can just look at a failure on CI (already quoted above).

@debora-ito
Copy link
Member

I could work up instructions on running the test in jenkinsci/artifact-manager-s3-plugin@46898c5

Yes please, I'm hoping to reproduce the problem. A minimal working example would also be good.

@jglick
Copy link
Contributor Author

jglick commented Mar 16, 2020

A minimal working example

Again, that is best seen in #2256 which reproduces the error as well as offering the fix. To see the bug as it was discovered in the Jenkins plugin, save this to a Dockerfile in the current directory and docker build .:

FROM maven:3.6.3-jdk-8
RUN git clone https://github.com/jenkinsci/artifact-manager-s3-plugin /src
WORKDIR /src

# 1.11.700:
RUN git checkout c46511b15788a5965fd084c4c2295d853aec5e1c^^
RUN mvn -ntp test -Dtest=S3BlobStoreConfigTest\#createS3Bucket
# 1.11.723 with workaround:
RUN git checkout c46511b15788a5965fd084c4c2295d853aec5e1c
RUN mvn -ntp test -Dtest=S3BlobStoreConfigTest\#createS3Bucket
# 1.11.723 without workaround:
RUN git checkout c46511b15788a5965fd084c4c2295d853aec5e1c^
RUN mvn -ntp test -Dtest=S3BlobStoreConfigTest\#createS3Bucket

which demonstrates a test passing before the update, breaking after the update, and passing again when a full URL with scheme is used (not in that order).

@debora-ito debora-ito added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed response-requested Waiting on additional info or feedback. Will move to "closing-soon" in 5 days. labels Mar 19, 2020
@debora-ito debora-ito removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Mar 24, 2020
TommyWind added a commit to TommyWind/aws-sdk-java that referenced this issue Mar 25, 2020
TommyWind added a commit to TommyWind/aws-sdk-java that referenced this issue Mar 25, 2020
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.
Projects
None yet
2 participants