ffang commented on code in PR #3701:
URL: https://github.com/apache/cxf/pull/3701#discussion_r4528581834


##########
rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java:
##########
@@ -1161,22 +1161,21 @@ public CompletableFuture<HttpResponse<InputStream>> 
run() throws IOException {
                 future = cl.sendAsync(request, handler);
             }
             future.exceptionally(ex -> {
-                // Record the failure on the message so the close() invoked 
below
-                // does not treat this as an un-sent request and resend it: the
-                // shared WrappedOutputStream#close() already skips
-                // handleHeadersTrustCaching() once outMessage carries an 
Exception
-                // (CXF-9250).
-                outMessage.setContent(Exception.class,
-                        ex instanceof Exception ? (Exception) ex : new 
IOException(ex));
-                if (pout != null) {
-                    synchronized (pout) {
-                        pout.notifyAll();
+                // Only release a writer waiting for the connection or blocked 
on the body. The

Review Comment:
   Hi @reta,
   
   Thanks for checking. I went through the paths again, and I don't think 
anything is lost:
   
   - **`ex`:** the future `exceptionally()` returns was never kept, so its 
`null` result goes nowhere. The `future` field, the one `sendAsync` returned, 
still completes exceptionally, and the caller gets the failure from it with 
`future.get()`: in `getResponse()` from the response handling, or in 
`isConnectionAttemptCompleted()` for a writer waiting for the connection. The 
exception the callback recorded on the out message was only ever checked for 
null, by the guards in `close()` and `handleResponseOnWorkqueue()`. Nothing 
passed it on to the caller, and that check is what kept the response handling 
from running for an async call. I've added an assertion to the test that the 
failure reported is the `ConnectException`, both when it reaches the fault 
observer and when the caller gets it from the stream (fca4ec191c).
   - **Callers that read the out message:** Camel's 
`CxfClientCallback.handleException` takes the exception from 
`cxfExchange.getOutMessage().getContent(Exception.class)`. With this change it 
finds the `ConnectException` there when the callback is called, because the 
response handling sets it on the out message before calling the fault observer. 
That's the same as on 4.2.3, and the same as on 4.2.4 for the calls that didn't 
hang. For the calls that hung, the raw `CompletionException` was on the out 
message, but the callback never ran, so nothing read it. I checked this with a 
callback that reads the out message the way Camel's does.
   - **`exception`:** it was never set. `git log -S` only finds it in the 
commit that introduced the conduit. It's declared and checked in 
`handleNoOutput()`, `setupWrappedStream()` and `thresholdReached()`, but 
nothing assigns it, also before this PR. I left it alone to keep this change 
focused, but I'm happy to remove the dead field in a separate cleanup.
   
   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]

Reply via email to