From d8f4d37624fc38a8c28d8e427f205b395e290f15 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 12 Sep 2016 19:23:15 +0200 Subject: [PATCH] Fixed bug in reading Flux from Channel Fixed bug where the returned Flux from DataBufferUtils.read() would be completed prematurely if the channel was not ready to read, but did not reach the end of the file either. --- .../org/springframework/core/io/buffer/DataBufferUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java index a519449d82..5dccfffd78 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java @@ -164,7 +164,7 @@ public abstract class DataBufferUtils { try { ByteBuffer byteBuffer = ByteBuffer.allocate(chunkSize); int read; - if ((read = channel.read(byteBuffer)) > 0) { + if ((read = channel.read(byteBuffer)) >= 0) { byteBuffer.flip(); boolean release = true; DataBuffer dataBuffer = this.dataBufferFactory.allocateBuffer(read);