Skip to content

Commit 3c352e2

Browse files
committed
Stay compatible with 2.12.0
1 parent d6da6b2 commit 3c352e2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/org/apache/commons/io/IOUtils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,9 @@ public static int read(final InputStream input, final byte[] buffer) throws IOEx
19261926
*/
19271927
public static int read(final InputStream input, final byte[] buffer, final int offset, final int length)
19281928
throws IOException {
1929+
if (length == 0) {
1930+
return 0;
1931+
}
19291932
return read(input::read, buffer, offset, length);
19301933
}
19311934

@@ -2659,7 +2662,10 @@ public static byte[] toByteArray(final InputStream inputStream) throws IOExcepti
26592662
* @since 2.1
26602663
*/
26612664
public static byte[] toByteArray(final InputStream input, final int size) throws IOException {
2662-
return toByteArray(input::read, size);
2665+
if (size == 0) {
2666+
return EMPTY_BYTE_ARRAY;
2667+
}
2668+
return toByteArray(Objects.requireNonNull(input, "input")::read, size);
26632669
}
26642670

26652671
/**

0 commit comments

Comments
 (0)