From 424eb21478120833227bfe32a411bb4fea50decb Mon Sep 17 00:00:00 2001 From: Julien Viet Date: Wed, 19 Apr 2023 13:40:10 +0200 Subject: [PATCH] The InputStreamReadStream adapter uses null to signal the end of the stream through the InboundBuffer adapter. However the InboundBuffer does not accept null values. This has not been seen in tests because this only happens when the inbound buffer uses an array deque to store queued items. Instead we should use a proper sentinel value to signal the end of the stream instead of null. --- .../kubernetes/client/vertx/InputStreamReadStream.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/InputStreamReadStream.java b/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/InputStreamReadStream.java index 9219dc5f73a..54c7ad11b5d 100644 --- a/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/InputStreamReadStream.java +++ b/httpclient-vertx/src/main/java/io/fabric8/kubernetes/client/vertx/InputStreamReadStream.java @@ -30,6 +30,7 @@ class InputStreamReadStream implements ReadStream { + private static final Buffer END_SENTINEL = Buffer.buffer(); private static final int CHUNK_SIZE = 2048; private static final int MAX_DEPTH = 8; @@ -71,7 +72,7 @@ public ReadStream handler(Handler handler) { } if (handler != null) { inboundBuffer.handler(buff -> { - if (buff == null) { + if (buff == END_SENTINEL) { if (endHandler != null) { endHandler.handle(null); } @@ -132,7 +133,7 @@ private void readChunk2() { // Full } } else { - inboundBuffer.write((Buffer) null); + inboundBuffer.write(END_SENTINEL); } } else { if (exceptionHandler != null) {