ffang commented on code in PR #3645:
URL: https://github.com/apache/cxf/pull/3645#discussion_r4413543662
##########
rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java:
##########
@@ -870,8 +870,8 @@ protected void retransmitStream() throws IOException {
protected void setupNewConnection(String newURL) throws IOException {
httpResponse = null;
- isAsync = outMessage != null && outMessage.getExchange() != null
- && !outMessage.getExchange().isSynchronous();
+ // the thread that retransmits handles the response, also for an
asynchronous exchange
Review Comment:
Thanks @reta. `setupNewConnection` is only used for retransmits: its only
caller is `HTTPConduit.retransmit()`, which is reached from
`handleRetransmits()` (redirects and auth). For the normal execution `isAsync`
is still initialized from `!exchange.isSynchronous()` in the stream
constructor, and that is unchanged.
`isAsync` means that no thread waits for the response, so the I/O callback
has to start the response handling. Since this change, a retransmit always
happens on a thread that then waits for the retransmitted response and handles
it:
- the caller thread for a synchronous exchange (`handleResponse`);
- the thread that handles the response for an asynchronous one
(`handleRetransmitsAndResponse`).
So the value is always `false` here, and a parameter would always be passed
`false`. Setting it from `isSynchronous()` again would make the I/O callback
dispatch a second handler for the retransmitted response while that thread
waits for it. That is the "empty body of the redirect parsed as the response"
issue: `testAutoRedirect[hc]` and `testAuthenticationChallenge[hc]` fail with
`Unexpected EOF in prolog` with the old line.
I just made the comment clearer that this is only for retransmits.
```
// only used to retransmit: the thread that retransmits waits for the
response and handles it,
// for an asynchronous exchange too, so the response must not be dispatched
again when it is received
isAsync = false;
```
Best Regards
Freeman
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]