LuciferYang opened a new pull request, #56802:
URL: https://github.com/apache/spark/pull/56802

   ### What changes were proposed in this pull request?
   
   In `TransportResponseHandler`, when a `StreamResponse` arrives and 
installing the stream interceptor fails (the `TransportFrameDecoder` is missing 
from the channel pipeline, or `setInterceptor` throws), the handler now fails 
the stream callback and closes the channel. Previously it only logged the error 
and called `deactivateStream()`, leaving the `StreamCallback`, which had 
already been removed from the queue, without any completion or failure 
notification.
   
   ### Why are the changes needed?
   
   This is defensive hardening rather than a fix for a failure seen in 
practice. The catch block is effectively unreachable in normal operation: while 
an interceptor is active the frame decoder stops framing, so the 
`setInterceptor` state check cannot trip, and the decoder is not removed 
mid-dispatch on the single channel event loop. Even so, every other branch in 
`handle()` notifies its callback while this one did not, so if the path were 
ever reached the caller would block until the connection idle-timeout instead 
of failing cleanly. Closing the channel also keeps a connection whose framing 
can no longer be trusted out of the pool, where it could otherwise corrupt 
later requests.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Added 
`TransportResponseHandlerSuite.failStreamCallbackWhenInstallingInterceptorFails`,
 which handles a `StreamResponse` on a channel whose pipeline has no 
`TransportFrameDecoder`, so installing the interceptor throws. It verifies that 
the callback is failed with the install exception and that the channel is 
closed. The test fails on the old code (the callback receives no interaction) 
and passes with the fix; the full `TransportResponseHandlerSuite` passes.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 4.8)
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to