[UrlConnectionHttpClient] propagate IOExceptions during request body sending (to benefit from the aws sdk retry policy) #2891
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.








Sending the request body may fail due to an IOException when the server
has closed the underlying socket without a preliminary hint such as
a
Connection: closeresponse header.This closure comes in the form of a server-initiated TLS alert
(close_notify). The cause of these intermittent non-orderly closures is
unclear. It could be based on the volume of data sent over the socket,
or the count of requests submitted. I suspect AWS uses an ELB fronting
an API Gateway on the endpoint side, and those decisions are made based
on some policy that the client has no control over, therefore there
closures will happen, and the requests need to be retried when that
happens.
However, When this does, the invokeSafely() wraps the IOException into an
UncheckedIOException which makes the retriable error non-retriable,
because UncheckedIOException extends RuntimeException, which to the AWS
SDK looks like a nondescript error condition that could / should not be
retried.
This Bugfix propagates the UncheckedIOException's inner IOException cause
so that the UrlConnectionHttpClient may benefit from the same retry policy
as the ApacheHttpClient for request body sending.
Motivation and Context
The UrlConnectionClient is not working as reliably as the ApacheClient
if it cannot benefit from the same retry capability.
The Pull Request #2848
improved the situation by allowing the use of the UrlConnectionClient
for requests with very large bodies. But this won't help if the client
cannot handle occasionally closed connections.
Description
Catch UncheckedIOException, and rethrow the IOException cause.
Testing
It is not possible to have the AWS endpoint close a connection in a
deterministic way.
I made the change in a private project, and was able to see such
IOExceptions be considered retriable, and be retried through the SDK
retry policy.
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceeds-> ran
install -pl :bom-internal,:s3 -P quick --am -T 2C-> can't find the code style information
License