mirror of https://github.com/grpc/grpc-java.git
netty: NOOP_MESSAGE must be staged before connect() (#3411)
Addresses flakey test Fixes #3408
This commit is contained in:
parent
6164b7b2ee
commit
e6fc6f33a5
|
@ -216,10 +216,11 @@ class NettyClientTransport implements ConnectionClientTransport {
|
||||||
}
|
}
|
||||||
// Start the write queue as soon as the channel is constructed
|
// Start the write queue as soon as the channel is constructed
|
||||||
handler.startWriteQueue(channel);
|
handler.startWriteQueue(channel);
|
||||||
// Start the connection operation to the server.
|
|
||||||
channel.connect(address);
|
|
||||||
// This write will have no effect, yet it will only complete once the negotiationHandler
|
// This write will have no effect, yet it will only complete once the negotiationHandler
|
||||||
// flushes any pending writes.
|
// flushes any pending writes. We need it to be staged *before* the `connect` so that
|
||||||
|
// the channel can't have been closed yet, removing all handlers. This write will sit in the
|
||||||
|
// AbstractBufferingHandler's buffer, and will either be flushed on a successful connection,
|
||||||
|
// or failed if the connection fails.
|
||||||
channel.writeAndFlush(NettyClientHandler.NOOP_MESSAGE).addListener(new ChannelFutureListener() {
|
channel.writeAndFlush(NettyClientHandler.NOOP_MESSAGE).addListener(new ChannelFutureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(ChannelFuture future) throws Exception {
|
public void operationComplete(ChannelFuture future) throws Exception {
|
||||||
|
@ -230,6 +231,8 @@ class NettyClientTransport implements ConnectionClientTransport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Start the connection operation to the server.
|
||||||
|
channel.connect(address);
|
||||||
|
|
||||||
if (keepAliveManager != null) {
|
if (keepAliveManager != null) {
|
||||||
keepAliveManager.onTransportStarted();
|
keepAliveManager.onTransportStarted();
|
||||||
|
|
Loading…
Reference in New Issue