This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 3c352e208d90c37ceca371920ead1bb80fa83229 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Jun 2 13:35:27 2023 -0400 Stay compatible with 2.12.0 --- src/main/java/org/apache/commons/io/IOUtils.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java index 160bb176..a8d8ffb2 100644 --- a/src/main/java/org/apache/commons/io/IOUtils.java +++ b/src/main/java/org/apache/commons/io/IOUtils.java @@ -1926,6 +1926,9 @@ public class IOUtils { */ public static int read(final InputStream input, final byte[] buffer, final int offset, final int length) throws IOException { + if (length == 0) { + return 0; + } return read(input::read, buffer, offset, length); } @@ -2659,7 +2662,10 @@ public class IOUtils { * @since 2.1 */ public static byte[] toByteArray(final InputStream input, final int size) throws IOException { - return toByteArray(input::read, size); + if (size == 0) { + return EMPTY_BYTE_ARRAY; + } + return toByteArray(Objects.requireNonNull(input, "input")::read, size); } /**