diff options
author | zpencer <spencerfang@google.com> | 2017-08-28 17:48:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-28 17:48:14 -0700 |
commit | e6fc6f33a54c0abc74a0da8dd74c00a9b6fd392d (patch) | |
tree | 1bcc202aea331d966ca85a3717881d8aa3c2e484 /netty | |
parent | 6164b7b2ee8066c5f047f6ea49c477b6f9e3aba6 (diff) | |
download | grpc-grpc-java-e6fc6f33a54c0abc74a0da8dd74c00a9b6fd392d.tar.gz |
netty: NOOP_MESSAGE must be staged before connect() (#3411)
Addresses flakey test
Fixes #3408
Diffstat (limited to 'netty')
-rw-r--r-- | netty/src/main/java/io/grpc/netty/NettyClientTransport.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java index 5805cce83..189b06a48 100644 --- a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java +++ b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java @@ -216,10 +216,11 @@ class NettyClientTransport implements ConnectionClientTransport { } // Start the write queue as soon as the channel is constructed 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 - // 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() { @Override 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) { keepAliveManager.onTransportStarted(); |