diff --git a/extensions/core/runtime/src/main/java/io/quarkiverse/cxf/vertx/http/client/VertxHttpClientHTTPConduit.java b/extensions/core/runtime/src/main/java/io/quarkiverse/cxf/vertx/http/client/VertxHttpClientHTTPConduit.java index c16077ee6..7e20d0cda 100644 --- a/extensions/core/runtime/src/main/java/io/quarkiverse/cxf/vertx/http/client/VertxHttpClientHTTPConduit.java +++ b/extensions/core/runtime/src/main/java/io/quarkiverse/cxf/vertx/http/client/VertxHttpClientHTTPConduit.java @@ -1557,7 +1557,7 @@ public int read() throws IOException { @Override public int read(byte b[], final int off, int len) throws IOException { - // Log.infof("Ready to read up to %d bytes", len); + // log.tracef("Ready to read up to %d bytes", len); Buffer rb = takeBuffer(true); if (rb == null) { // log.trace("Nothing more to read"); @@ -1633,7 +1633,7 @@ private void freeReadBufferIfNeeded() { public void close() { // log.trace("Closing reader"); // log.tracef("Closing reader: got %d bytes in %d reads", bytesRead, readCounter); - readBuffer = null; + freeReadBufferIfNeeded(); // assert queueEmpty() : "Queue still has " + queue.size() + " items"; } diff --git a/extensions/core/runtime/src/test/java/io/quarkiverse/cxf/vertx/http/client/InputStreamWriteStreamTest.java b/extensions/core/runtime/src/test/java/io/quarkiverse/cxf/vertx/http/client/InputStreamWriteStreamTest.java index 4d36aae82..7d0c7d941 100644 --- a/extensions/core/runtime/src/test/java/io/quarkiverse/cxf/vertx/http/client/InputStreamWriteStreamTest.java +++ b/extensions/core/runtime/src/test/java/io/quarkiverse/cxf/vertx/http/client/InputStreamWriteStreamTest.java @@ -246,6 +246,26 @@ void twoBuffers() throws IOException { } } + @Test + void readAfterClose() throws IOException { + ContextInternal ctx = (ContextInternal) Vertx.vertx().getOrCreateContext(); + InputStreamWriteStream ws = new InputStreamWriteStream(ctx, 2); + final String INPUT1 = "abcd"; + final String INPUT2 = "efgh"; + final String INPUT3 = "ijkl"; + ws.write(Buffer.buffer(INPUT1)); + ws.write(Buffer.buffer(INPUT2)); + ws.write(Buffer.buffer(INPUT3)); + ws.end(); + byte[] arr = new byte[12]; + Assertions.assertThat(ws.read(arr)).isEqualTo(12); + Assertions.assertThat(arr).isEqualTo((INPUT1 + INPUT2 + INPUT3).getBytes(StandardCharsets.UTF_8)); + Assertions.assertThat(ws.read(arr)).isEqualTo(-1); + ws.close(); + Assertions.assertThat(ws.read(arr)).isEqualTo(-1); + ws.close(); + } + @Test void threeBuffers() throws IOException {