Skip to content

Commit 9900e78

Browse files
committed
Fix incorrect Http2UpgradeClientConnection write.
Motivation: Http2UpgradeClientConnection might emit the event SEND_BUFFERED_MESSAGES_EVENT and end the http request before all chunks have been written Changes: Delay SEND_BUFFERED_MESSAGES_EVENT when the last chunk has been written
1 parent ab87618 commit 9900e78

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main/java/io/vertx/core/http/impl/Http2UpgradeClientConnection.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,21 @@ public boolean writeQueueFull() {
689689
public void writeBuffer(ByteBuf buf, boolean end, Handler<AsyncResult<Void>> handler) {
690690
EventExecutor exec = upgradingConnection.channelHandlerContext().executor();
691691
if (exec.inEventLoop()) {
692-
upgradingStream.writeBuffer(buf, end, handler);
692+
Handler<AsyncResult<Void>> continuation;
693693
if (end) {
694-
ChannelPipeline pipeline = upgradingConnection.channelHandlerContext().pipeline();
695-
pipeline.fireUserEventTriggered(SEND_BUFFERED_MESSAGES);
694+
continuation = ar -> {
695+
if (ar.succeeded()) {
696+
ChannelPipeline pipeline = upgradingConnection.channelHandlerContext().pipeline();
697+
pipeline.fireUserEventTriggered(SEND_BUFFERED_MESSAGES);
698+
}
699+
if (handler != null) {
700+
handler.handle(ar);
701+
}
702+
};
703+
} else {
704+
continuation = handler;
696705
}
706+
upgradingStream.writeBuffer(buf, end, continuation);
697707
} else {
698708
exec.execute(() -> writeBuffer(buf, end, handler));
699709
}

0 commit comments

Comments
 (0)