[#3364] Not use VoidChannelPromise in SslHandler to guard against IllegalStateException
Motivation: SslHandler adds a pending write with an empty buffer and a VoidChannelPromise when a user flush and not pending writes are currently stored. This may produce an IllegalStateException later if the user try to add a ChannelFutureListener to the promise in the next ChannelOutboundHandler. Modifications: Replace ctx.voidPromise() with ctx.newPromise() Result: No more IllegalStateException possible
This commit is contained in:
parent
bed3502772
commit
0f2ae0cafe
@ -457,7 +457,11 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pendingUnencryptedWrites.isEmpty()) {
|
if (pendingUnencryptedWrites.isEmpty()) {
|
||||||
pendingUnencryptedWrites.add(Unpooled.EMPTY_BUFFER, ctx.voidPromise());
|
// It's important to NOT use a voidPromise here as the user
|
||||||
|
// may want to add a ChannelFutureListener to the ChannelPromise later.
|
||||||
|
//
|
||||||
|
// See https://github.com/netty/netty/issues/3364
|
||||||
|
pendingUnencryptedWrites.add(Unpooled.EMPTY_BUFFER, ctx.newPromise());
|
||||||
}
|
}
|
||||||
if (!handshakePromise.isDone()) {
|
if (!handshakePromise.isDone()) {
|
||||||
flushedBeforeHandshake = true;
|
flushedBeforeHandshake = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user