From 04ff6d442f5b174217fc0dc56ebfee9aaded69d0 Mon Sep 17 00:00:00 2001 From: Glavo Date: Sat, 23 Nov 2024 04:12:26 +0800 Subject: [PATCH 1/3] Update outdated descriptions in IOUtils and IOUtilsTest --- .../java/org/apache/commons/compress/utils/IOUtils.java | 7 ++++--- .../org/apache/commons/compress/utils/IOUtilsTest.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/utils/IOUtils.java b/src/main/java/org/apache/commons/compress/utils/IOUtils.java index 2b5fb29c28e..455660fca08 100644 --- a/src/main/java/org/apache/commons/compress/utils/IOUtils.java +++ b/src/main/java/org/apache/commons/compress/utils/IOUtils.java @@ -76,9 +76,10 @@ public static void copy(final File sourceFile, final OutputStream outputStream) * Copies the content of a InputStream into an OutputStream. Uses a default buffer size of 8024 bytes. * * @param input the InputStream to copy - * @param output the target, may be null to simulate output to dev/null on Linux and NUL on Windows + * @param output the target * @return the number of bytes copied * @throws IOException if an error occurs + * @throws NullPointerException if the {@code input} or the {@code output} is {@code null} * @deprecated Use {@link org.apache.commons.io.IOUtils#copy(InputStream, OutputStream)}. */ @Deprecated @@ -90,11 +91,11 @@ public static long copy(final InputStream input, final OutputStream output) thro * Copies the content of a InputStream into an OutputStream * * @param input the InputStream to copy - * @param output the target, may be null to simulate output to dev/null on Linux and NUL on Windows + * @param output the target * @param bufferSize the buffer size to use, must be bigger than 0 * @return the number of bytes copied * @throws IOException if an error occurs - * @throws IllegalArgumentException if bufferSize is smaller than or equal to 0 + * @throws NullPointerException if the {@code input} or the {@code output} is {@code null} * @deprecated Use {@link org.apache.commons.io.IOUtils#copy(InputStream, OutputStream, int)}. */ @Deprecated diff --git a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java index fc8993793cf..2410dc9f236 100644 --- a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java +++ b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java @@ -107,7 +107,7 @@ public void testCopyRangeThrowsOnZeroBufferSize() { } @Test - public void testCopyThrowsOnZeroBufferSize() throws IOException { + public void testCopyOnZeroBufferSize() throws IOException { assertEquals(0, IOUtils.copy(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), new ByteArrayOutputStream(), 0)); } From fb8e4bec1190f38933a5757a90343a24d2efa721 Mon Sep 17 00:00:00 2001 From: Glavo Date: Sat, 23 Nov 2024 04:26:08 +0800 Subject: [PATCH 2/3] update javadoc --- .../java/org/apache/commons/compress/utils/IOUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/utils/IOUtils.java b/src/main/java/org/apache/commons/compress/utils/IOUtils.java index 455660fca08..6aaa3c19534 100644 --- a/src/main/java/org/apache/commons/compress/utils/IOUtils.java +++ b/src/main/java/org/apache/commons/compress/utils/IOUtils.java @@ -73,11 +73,11 @@ public static void copy(final File sourceFile, final OutputStream outputStream) } /** - * Copies the content of a InputStream into an OutputStream. Uses a default buffer size of 8024 bytes. + * Copies the content of a InputStream into an OutputStream. Uses a default buffer size of 8192 bytes. * * @param input the InputStream to copy * @param output the target - * @return the number of bytes copied + * @return the number of bytes copied, or -1 if greater than {@link Integer#MAX_VALUE} * @throws IOException if an error occurs * @throws NullPointerException if the {@code input} or the {@code output} is {@code null} * @deprecated Use {@link org.apache.commons.io.IOUtils#copy(InputStream, OutputStream)}. @@ -104,7 +104,7 @@ public static long copy(final InputStream input, final OutputStream output, fina } /** - * Copies part of the content of a InputStream into an OutputStream. Uses a default buffer size of 8024 bytes. + * Copies part of the content of a InputStream into an OutputStream. Uses a default buffer size of 8192 bytes. * * @param input the InputStream to copy * @param output the target Stream From c6c6dc45c12be6ffaab53eb4ac185c3ad74b7439 Mon Sep 17 00:00:00 2001 From: Glavo Date: Sat, 23 Nov 2024 04:51:38 +0800 Subject: [PATCH 3/3] update javadoc --- src/main/java/org/apache/commons/compress/utils/IOUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/compress/utils/IOUtils.java b/src/main/java/org/apache/commons/compress/utils/IOUtils.java index 6aaa3c19534..abe4bfff43e 100644 --- a/src/main/java/org/apache/commons/compress/utils/IOUtils.java +++ b/src/main/java/org/apache/commons/compress/utils/IOUtils.java @@ -292,7 +292,7 @@ public static long skip(final InputStream input, final long toSkip) throws IOExc * @param input the {@code InputStream} to read from * @return the requested byte array * @throws NullPointerException if the input is null - * @throws IOException if an I/O error occurs + * @throws IOException if an I/O error occurs or reads more than {@link Integer#MAX_VALUE} occurs * @since 1.5 * @deprecated Use {@link org.apache.commons.io.IOUtils#toByteArray(InputStream)}. */