fix: Preserve error cause in CRT http client TLS and socket timeout failures#7157
Conversation
c5d7ec2 to
93ce8b0
Compare
| <!-- Shared HTTP client test suites live in src/main/java so client modules can consume them; | ||
| allow test-style underscore method names. --> | ||
| <suppress checks="MethodName" | ||
| files=".*[\\/]http-client-tests[\\/]src[\\/]main[\\/]java[\\/].*Test.*\.java$"/> |
There was a problem hiding this comment.
Tiny nit on the file name here - I think .*Test.* may be too permissive - I'd lean towards making it .*Test\.java$ to enforce the name ends with Test and we don't pick up a class name that just happens to have "Test" in it.
There was a problem hiding this comment.
Edit: nvm, I see the files are TestSuite. I think we should still enforce the ending, but maybe must be either *Test.java or *TestSuite.java
There was a problem hiding this comment.
Valid point, will make it *TestSuite.java
I think we should not add it for generic *Test.java since these classes should go in tst/ folder and not in main src.
|
This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one. |
Motivation and Context
The CRT HTTP client translates native TLS negotiation failures (CRT error code 1029)
into
SSLHandshakeExceptionand socket timeouts during connection acquisition(CRT error code 1048) into
ConnectException. Both translations build the newexception from the message string alone and discard the underlying CRT
HttpException, sogetCause()returnsnulland the CRT error code is lost.Without a cause chain, callers cannot classify a TLS failure as transient
(connection interrupted during the handshake) or persistent (certificate
validation failure), and cannot write retry predicates that target one case
and not the other. The Apache, Netty, and UrlConnection clients preserve the
full cause chain for the same failure. This change fixes the CRT client to
match that behavior.
Modifications
CrtUtils.wrapCrtException: chain the originalHttpExceptionviainitCausein theSSLHandshakeExceptionbranch (error code 1029) and theConnectExceptionbranch (error code 1048). Exception types and messagesare unchanged, so existing callers that match on type are unaffected.
CrtUtilsTest: add two tests asserting that each wrapped exception carriesthe
HttpExceptionas its cause.CrtRequestExecutorTestandCrtAsyncRequestExecutorTest: extendexecute_httpException_mapsToCorrectExceptionwithhasRootCause(exception)assertions.
SdkHttpClientSslHandshakeBehaviorTestSuite(new, intest/http-client-tests):shared suite that runs an HTTPS server with a self-signed certificate and
asserts that the handshake failure surfaces as
SSLHandshakeExceptionwith anon-null cause. Reusable by every
SdkHttpClientimplementation.CrtSslHandshakeBehaviorTest(aws-crt-client) andApacheSslHandshakeBehaviorTest(apache-client): wire the new suite intoboth clients. The CRT test fails without the
CrtUtilsfix and passes with it.Testing
Screenshots (if appropriate)
Types of changes
License