aws-sdk-java: org.apache.httpcomponents:httpclient:4.5.7 breaks fetching S3 objects with consecutive slashes in the key
org.apache.httpcomponents:httpclient:4.5.7 made a change[1] to url rewriting (used when executing a request) where it normalizes the provided urls by removing empty path segments (effectively collapsing consecutive slashes into a single slash).
S3 supports objects with consecutive slashes, but because of this behaviour change in httpclient, you can no longer fetch those objects with the AWS SDK, since the url httpclient makes a request to is different. On a side note, the manifestation of this issue is a signature mismatch, since the signature calculated by the SDK uses double slashes but when httpclient hits the path without double slashes, the calculated signature is different.
It looks like there’s some debate on it now and they’re actually working on making normalization optional[2], so once that’s released we can update the RequestConfig[3] to disable normalization and revert to the previous behaviour[3].
Example stack trace showing the code path to slash collapsing:
rewriteURI:158, URIUtils (org.apache.http.client.utils)
rewriteURIForRoute:231, URIUtils (org.apache.http.client.utils)
rewriteRequestURI:95, ProtocolExec (org.apache.http.impl.execchain)
execute:132, ProtocolExec (org.apache.http.impl.execchain)
doExecute:185, InternalHttpClient (org.apache.http.impl.client)
execute:83, CloseableHttpClient (org.apache.http.impl.client)
execute:56, CloseableHttpClient (org.apache.http.impl.client)
execute:72, SdkHttpClient (com.amazonaws.http.apache.client.impl)
executeOneRequest:1285, AmazonHttpClient$RequestExecutor (com.amazonaws.http)
executeHelper:1101, AmazonHttpClient$RequestExecutor (com.amazonaws.http)
doExecute:758, AmazonHttpClient$RequestExecutor (com.amazonaws.http)
executeWithTimer:732, AmazonHttpClient$RequestExecutor (com.amazonaws.http)
execute:714, AmazonHttpClient$RequestExecutor (com.amazonaws.http)
access$500:674, AmazonHttpClient$RequestExecutor (com.amazonaws.http)
execute:656, AmazonHttpClient$RequestExecutionBuilderImpl (com.amazonaws.http)
execute:520, AmazonHttpClient (com.amazonaws.http)
invoke:4705, AmazonS3Client (com.amazonaws.services.s3)
invoke:4652, AmazonS3Client (com.amazonaws.services.s3)
getObject:1457, AmazonS3Client (com.amazonaws.services.s3)
getObject:1316, AmazonS3Client (com.amazonaws.services.s3)
1: https://issues.apache.org/jira/browse/HTTPCLIENT-1960, https://github.com/apache/httpcomponents-client/commit/8c04c6ae5e5ba1432e40684428338ce68431766b 2: https://issues.apache.org/jira/browse/HTTPCLIENT-1968, https://github.com/apache/httpcomponents-client/commit/4093a3015d6b789888077e317e535df4c8102e5d 3: https://github.com/aws/aws-sdk-java/blob/1.11.502/aws-java-sdk-core/src/main/java/com/amazonaws/http/AmazonHttpClient.java#L1282
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (7 by maintainers)
Links to this issue
Commits related to this issue
- Don't allow httpclient to normalize URIs #1919 — committed to akhaku/aws-sdk-java by akhaku 8 years ago
- Don't allow httpclient to normalize URIs #1919 — committed to akhaku/aws-sdk-java by akhaku 8 years ago
- Disable Apache normalization to handle breaking change introduced in v4.5.7 See https://github.com/aws/aws-sdk-java/issues/1919 for more details. — committed to aws/aws-sdk-java-v2 by varunnvs92 8 years ago
- Don't allow httpclient to normalize URIs #1919 — committed to akhaku/aws-sdk-java by akhaku 8 years ago
- Don't allow httpclient to normalize URIs #1919 — committed to akhaku/aws-sdk-java by akhaku 8 years ago
- Disable Apache normalization to handle breaking change introduced in v4.5.7 See https://github.com/aws/aws-sdk-java/issues/1919 for more details. — committed to aws/aws-sdk-java-v2 by varunnvs92 8 years ago
- Disable Apache normalization to handle breaking change introduced in v4.5.7 See https://github.com/aws/aws-sdk-java/issues/1919 for more details. — committed to aws/aws-sdk-java-v2 by varunnvs92 8 years ago
- Correction for bad issue link in CHANGELOG The link to issue #1919 for release `1.11.596` (2019-07-22) is somewhat garbled, as described in Issue #2056. I believe this change fixes that. — committed to larrywest/aws-sdk-java by larrywest 7 years ago
- BAU - Add httpclient as direct dependency `org.apache.httpcomponents:httpclient` is a transitive dependency of `io.dropwizard:dropwizard-client` but is also used by AWS core. As the transitive depen... — committed to alphagov/pay-ledger by kbottla 7 years ago
- Correction for bad issue link in CHANGELOG The link to issue aws#1919 for release `1.11.596` (2019-07-22) is somewhat garbled, as described in Issue aws#2056. — committed to larrywest/aws-sdk-java by larrywest 7 years ago
- hadoop-project/pom.xml: Update aws-java-sdk to fix paths with consecutive double slash See https://github.com/aws/aws-sdk-java/issues/1919 — committed to kube-reporting/hadoop by deleted user 7 years ago
- [fix] httpclient:4.5.7 breaks fetching S3 https://github.com/aws/aws-sdk-java/issues/1919 — committed to r-uchida13/aws-glue-samples by r-uchida13 7 years ago
- Update httpclient and httpcore Saw the following error in some logs: Sep 10, 2020 3:19:25 PM com.amazonaws.http.apache.utils.ApacheUtils noSuchMethodThrownByNormalizeUriInvoker WARNING: NoSu... — committed to crate/crate by mfussenegger 6 years ago
- Update httpclient and httpcore Saw the following error in some logs: Sep 10, 2020 3:19:25 PM com.amazonaws.http.apache.utils.ApacheUtils noSuchMethodThrownByNormalizeUriInvoker WARNING: NoSu... — committed to crate/crate by mfussenegger 6 years ago
- |#0 update org.apache.httpcomponents version https://github.com/aws/aws-sdk-java/issues/1919 — committed to avniproject/avni-server by vindeolal 5 years ago
- Bump clj-http version to avoid the following error: WARNING: NoSuchMethodException was thrown when disabling normalizeUri. This indicates you are using an old version (< 4.5.8) of Apache http client. ... — committed to deckeraa/video-note-taker by deckeraa 6 years ago
- Update httpclient to address a breaking change A `NoSuchMethodException` is being raised during startup. Update versions of httpclient and httpcore to address the issue. https://github.com/aws/aws-s... — committed to ConsoleCatzirl/Bridge-Exporter by ConsoleCatzirl 2 years ago
For me resolved as below:
@akhaku Thank you for the detailed report!
Using
org.apache.httpcomponents:httpclient:4.5.7indeed removed one of the two consecutive slashes in my tests.Based on the resolution of [2] https://issues.apache.org/jira/browse/HTTPCLIENT-1968, we’ll keep an eye on the next
httpclientrelease to see what is the new behaviour of the fix. I’ll keep this issue open in the meantime.I am seeing this issue (“AmazonS3Exception: The request signature we calculated does not match the signature you provided.”) on S3 key that contains “+” character (that seems the only thing out of ordinary) - like “2019/a+b/item”. Could it be related? The regression is caused by upgrading to Spring Boot 2.1.3 which brings in (version manages) httpclient:jar:4.5.7 (from 4.5.6).
The same warning (see my latest comments to aws/aws-sdk-java-v2#1372)
+1
I’m still receiving the warning with version 1.11.603 of aws-java-sdk-s3
Hey everyone, the SDK version
1.11.596was released, updating Apachehttpclientto 4.5.9.Please try it out and feel free to reach out if you’re still experiencing any issue.
Again, thank you for your patience!