import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
import io.netty.handler.ssl.SslHandler;
import io.netty.util.concurrent.Promise;
import java.util.concurrent.Future;
} else {
startNegotiationWithOpen();
}
+ this.channel.closeFuture().addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(final ChannelFuture f) {
+ cancelTimers();
+ }
+ });
+ }
+
+ private void cancelTimers() {
+ failTimer.cancel(false);
}
private void startNegotiationWithOpen() {
@Override
protected final void handleMessage(final Message msg) {
- this.failTimer.cancel(false);
+ cancelTimers();
LOG.debug("Channel {} handling message {} in state {}", this.channel, msg, this.state);
import io.netty.channel.ChannelPipeline;
import io.netty.channel.DefaultChannelPromise;
import io.netty.channel.EventLoop;
+import io.netty.util.concurrent.GenericFutureListener;
import io.netty.util.concurrent.ScheduledFuture;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
@Mock
protected Channel channel;
+ @Mock
+ private ChannelFuture channelFuture;
+
@Mock
private EventLoop eventLoop;
return future;
}
}).when(this.channel).writeAndFlush(any(Notification.class));
+ doReturn(this.channelFuture).when(this.channel).closeFuture();
+ doReturn(this.channelFuture).when(this.channelFuture).addListener(any(GenericFutureListener.class));
doReturn("TestingChannel").when(this.channel).toString();
doReturn(this.pipeline).when(this.channel).pipeline();
doReturn(this.address).when(this.channel).localAddress();