From aeb8f3ec6a44dae8ba25ba3c8f0f06b2678368b7 Mon Sep 17 00:00:00 2001 From: Lanchon Date: Thu, 24 Oct 2019 21:38:28 -0300 Subject: [PATCH] Adapt to Guava changes --- src/main/java/com/google/common/io/ByteStreamsHack.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/common/io/ByteStreamsHack.java b/src/main/java/com/google/common/io/ByteStreamsHack.java index 9b83ead..5d7ae39 100644 --- a/src/main/java/com/google/common/io/ByteStreamsHack.java +++ b/src/main/java/com/google/common/io/ByteStreamsHack.java @@ -24,8 +24,10 @@ public class ByteStreamsHack { // An equivalent -though inefficient- implementation using public-only API is: //return ByteStreams.toByteArray(inputStream); - if (expectedSize < 0) expectedSize = 0; - return Files.readFile(inputStream, expectedSize); + // Note that some special files may report size 0 but have content. + return expectedSize <= 0 ? + ByteStreams.toByteArray(inputStream) : + ByteStreams.toByteArray(inputStream, expectedSize); }