aws-sdk-java-v2
aws-sdk-java-v2 copied to clipboard
S3Utilities.parseUri(): support unencoded URI
Describe the bug
I currently have an S3 object with the S3 URI s3://test-bucket/test file with spaces
. When I attempt to create an S3Uri
object with the parseUri()
method (code), I receive the following exception:
// Code with S3 client from v2 SDK
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))
// Exception
Caused by: java.net.URISyntaxException: Illegal character in path at index 21: s3://test-bucket/test file with spaces
at java.net.URI$Parser.fail (:-1)
at java.net.URI$Parser.checkChars (:-1)
at java.net.URI$Parser.parseHierarchical (:-1)
This is due to the URI constructor, specifically because it does not allow input strings to have spaces in them. However, valid S3 URIs can contain spaces in them.
Expected Behavior
// Code
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))
println(s3Uri) // S3Uri(uri=s3://test-bucket/test file with spaces, bucket=test-bucket, key=test file with spaces, isPathStyle=false, queryParams={})
Current Behavior
// Code with S3 client from v2 SDK
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))
// Exception
Caused by: java.net.URISyntaxException: Illegal character in path at index 21: s3://test-bucket/test file with spaces
at java.net.URI$Parser.fail (:-1)
at java.net.URI$Parser.checkChars (:-1)
at java.net.URI$Parser.parseHierarchical (:-1)
Reproduction Steps
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.0
JDK version used
8
Operating System and version
macOS 12.6.5