From 3e91086ee77c56bf353c68ae0ddfb445700abb6f Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Wed, 18 Apr 2018 15:41:37 +0300 Subject: [PATCH] fix #321: Handle the delayed writes when onComplete/onError event is sent When onNext event is sent and the previous thread was not in an event loop then the write will be delayed. Then when onComplete/onError event is sent, the implementation need to check the pending writes and also the delayed. --- .../reactor/ipc/netty/channel/ChannelOperationsHandler.java | 6 +++--- .../reactor/ipc/netty/http/server/HttpsSendFileTests.java | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/reactor/ipc/netty/channel/ChannelOperationsHandler.java b/src/main/java/reactor/ipc/netty/channel/ChannelOperationsHandler.java index ee116d712e..a0085b749b 100755 --- a/src/main/java/reactor/ipc/netty/channel/ChannelOperationsHandler.java +++ b/src/main/java/reactor/ipc/netty/channel/ChannelOperationsHandler.java @@ -527,7 +527,7 @@ public void onComplete() { if (p != 0L) { produced = 0L; produced(p); - if (parent.pendingBytes > 0L || parent.hasPendingWriteBytes()) { + if (parent.pendingBytes > 0L || parent.hasPendingWriteBytes() || !lastThreadInEventLoop) { if (parent.ctx.channel() .isActive()) { parent.pendingBytes = 0L; @@ -548,7 +548,7 @@ public void onComplete() { } if (f != null) { - if (!f.isDone() && parent.hasPendingWriteBytes()) { + if (!f.isDone() && (parent.hasPendingWriteBytes() || !lastThreadInEventLoop)) { EventLoop eventLoop = parent.ctx.channel().eventLoop(); if (eventLoop.inEventLoop()) { parent.pendingWriteOffer.test(f, PENDING_WRITES); @@ -592,7 +592,7 @@ public void onError(Throwable t) { } if (f != null) { - if (!f.isDone() && parent.hasPendingWriteBytes()) { + if (!f.isDone() && (parent.hasPendingWriteBytes() || !lastThreadInEventLoop)) { EventLoop eventLoop = parent.ctx.channel().eventLoop(); if (eventLoop.inEventLoop()) { parent.pendingWriteOffer.test(f, PENDING_WRITES); diff --git a/src/test/java/reactor/ipc/netty/http/server/HttpsSendFileTests.java b/src/test/java/reactor/ipc/netty/http/server/HttpsSendFileTests.java index c6a3a3768b..19ffe59ba1 100644 --- a/src/test/java/reactor/ipc/netty/http/server/HttpsSendFileTests.java +++ b/src/test/java/reactor/ipc/netty/http/server/HttpsSendFileTests.java @@ -56,10 +56,4 @@ protected void customizeClientOptions(HttpClientOptions.Builder options) { throw new RuntimeException(e); } } - - @Override - protected void doTestSendFileAsync(int chunk) throws IOException, URISyntaxException { - // TODO: FIX THIS FOR SSL, remove this overridden method that disables the currently failing tests - // https://github.com/reactor/reactor-netty/issues/321 - } }