You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/09/03 11:54:30 UTC
(commons-io) 01/02: Don't check for size twice
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 860de720c663776d7b9de091e8699f6276950169
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 1 15:39:15 2025 -0400
Don't check for size twice
Javadoc
---
src/main/java/org/apache/commons/io/IOUtils.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java
index b9b7b63ab..05ff9e94c 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -2671,9 +2671,6 @@ public static byte[] toByteArray(final InputStream inputStream) throws IOExcepti
*/
@SuppressWarnings("resource")
public static byte[] toByteArray(final InputStream input, final int size) throws IOException {
- if (size == 0) {
- return EMPTY_BYTE_ARRAY;
- }
return toByteArray(Objects.requireNonNull(input, "input")::read, size);
}
@@ -2703,7 +2700,7 @@ public static byte[] toByteArray(final InputStream input, final long size) throw
/**
* Gets the contents of an input as a {@code byte[]}.
*
- * @param input the input to read.
+ * @param input the input to read, not null.
* @param size the size of the input to read, where 0 < {@code size} <= length of input.
* @return byte [] of length {@code size}.
* @throws IOException if an I/O error occurs or input length is smaller than parameter {@code size}.