Description
Using version 1.7.21, a NettyResponseFuture never gets completed because the provider uses a channel that has already been closed and handled by closeChannel(...)
.
If I have read the source properly, what we have here is a classical race condition:
-
[in client thread]
doConnect(...)
is called and a cached channel is selected.At this point, the attachment connected to the channel is still
DiscardEvent
NettyAsyncHttpProvider.java#L913
doConnect(...)
checks that the connection isOpen(), which it still is. -
[in I/O thread] The channel is closed by the remote end and
channelClosed(...)
is called. Since the attachment isDiscardEvent
, nothing is done. -
[in client thread]
doConnect(...)
continues using the now closed channel by attaching aNettyResponseFuture
to the channel. -
[in client thread]
doConnect(...)
callswriteRequest(...)
which checks if the channel is closed, which it is.NettyAsyncHttpProvider.java#L447
However,
writeRequest(...)
does nothing about the fact, relying onchannelClosed(...)
to handle the situation. But, aschannelClosed(...)
has already been executed at step 2, theabort(...)
ordone(...)
methods will never get called, resulting in that the listeners of the future will never get notified.