[#1517] Only fire the exception throught the pipeline if the channel is registered when using VoidChannelPromise
This commit is contained in:
parent
f64a121de7
commit
cea873286e
@ -150,9 +150,7 @@ final class VoidChannelPromise extends AbstractFuture<Void> implements ChannelPr
|
||||
}
|
||||
@Override
|
||||
public VoidChannelPromise setFailure(Throwable cause) {
|
||||
if (fireException) {
|
||||
channel.pipeline().fireExceptionCaught(cause);
|
||||
}
|
||||
fireException(cause);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -163,17 +161,13 @@ final class VoidChannelPromise extends AbstractFuture<Void> implements ChannelPr
|
||||
|
||||
@Override
|
||||
public boolean tryFailure(Throwable cause) {
|
||||
if (fireException) {
|
||||
channel.pipeline().fireExceptionCaught(cause);
|
||||
}
|
||||
fireException(cause);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cancel(boolean mayInterruptIfRunning) {
|
||||
if (fireException) {
|
||||
channel.pipeline().fireExceptionCaught(new CancellationException());
|
||||
}
|
||||
fireException(new CancellationException());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -200,4 +194,14 @@ final class VoidChannelPromise extends AbstractFuture<Void> implements ChannelPr
|
||||
public Void getNow() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void fireException(Throwable cause) {
|
||||
// Only fire the exception if the channel is open and registered
|
||||
// if not the pipeline is not setup and so it would hit the tail
|
||||
// of the pipeline.
|
||||
// See https://github.com/netty/netty/issues/1517
|
||||
if (fireException && channel.isRegistered()) {
|
||||
channel.pipeline().fireExceptionCaught(cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user