From 10f4c90f4e9c0f744d3f46cbb4b16752d14e3f2c Mon Sep 17 00:00:00 2001 From: Jakob Buchgraber Date: Mon, 17 Oct 2016 19:23:19 +0200 Subject: [PATCH] core: Call onSentBytes only if future is successfull. (#2339) For example, if opening a stream failed after a DATA frame had already been queued. --- netty/src/main/java/io/grpc/netty/NettyClientStream.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/netty/src/main/java/io/grpc/netty/NettyClientStream.java b/netty/src/main/java/io/grpc/netty/NettyClientStream.java index aa516fe097..e5e7df2fad 100644 --- a/netty/src/main/java/io/grpc/netty/NettyClientStream.java +++ b/netty/src/main/java/io/grpc/netty/NettyClientStream.java @@ -150,9 +150,11 @@ class NettyClientStream extends AbstractClientStream2 { channel.newPromise().addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { - // Remove the bytes from outbound flow control, optionally notifying - // the client that they can send more bytes. - transportState().onSentBytes(numBytes); + if (future.isSuccess()) { + // Remove the bytes from outbound flow control, optionally notifying + // the client that they can send more bytes. + transportState().onSentBytes(numBytes); + } } }), flush); } else {