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 29e4f8548e86c9a78b09f11908c0d8815f985d73
Author: Gary Gregory <gardgreg...@gmail.com>
AuthorDate: Mon Feb 1 11:43:28 2021 -0500

    Make public and reuse IOUtils.EMPTY_BYTE_ARRAY.
---
 src/changes/changes.xml                            |  3 ++
 src/main/java/org/apache/commons/io/IOUtils.java   |  7 +++-
 .../io/output/AbstractByteArrayOutputStream.java   |  5 +--
 .../org/apache/commons/io/CharsetsTestCase.java    |  1 +
 .../io/FileUtilsDeleteDirectoryBaseTestCase.java   |  1 +
 .../commons/io/file/PathUtilsDeleteFileTest.java   |  2 ++
 .../apache/commons/io/function/IOFunctionTest.java |  6 ++--
 .../commons/io/input/BoundedInputStreamTest.java   |  2 +-
 .../commons/io/input/CountingInputStreamTest.java  |  6 ++--
 .../io/input/MarkShieldInputStreamTest.java        |  7 ++--
 .../commons/io/input/QueueInputStreamTest.java     | 22 ++++++-------
 .../commons/io/input/TimestampedObserverTest.java  |  2 +-
 .../UnsynchronizedByteArrayInputStreamTest.java    | 37 +++++++++++-----------
 .../io/output/ByteArrayOutputStreamTestCase.java   | 20 ++++++------
 .../commons/io/output/QueueOutputStreamTest.java   | 20 ++++++------
 15 files changed, 77 insertions(+), 64 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 161c914..bc2d032 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -169,6 +169,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Add and use IOUtils.byteArray(*).
       </action>
+      <action dev="ggregory" type="add" due-to="Gary Gregory">
+        Make public and reuse IOUtils.EMPTY_BYTE_ARRAY.
+      </action>
       <!-- UPDATES -->
       <action dev="ggregory" type="update" due-to="Dependabot">
         Update junit-jupiter from 5.6.2 to 5.7.0 #153.
diff --git a/src/main/java/org/apache/commons/io/IOUtils.java 
b/src/main/java/org/apache/commons/io/IOUtils.java
index 9073104..8f5a746 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -105,7 +105,12 @@ public class IOUtils {
     // Writer. Each method should take at least one of these as a parameter,
     // or return one of them.
 
-    private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
+    /** 
+     * A singleton empty byte array.
+     *
+     *  @since 2.9.0
+     */
+    public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
 
     /**
      * The default buffer size ({@value}) to use in copy methods.
diff --git 
a/src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java 
b/src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java
index 0f982c0..e867a74 100644
--- 
a/src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java
+++ 
b/src/main/java/org/apache/commons/io/output/AbstractByteArrayOutputStream.java
@@ -61,9 +61,6 @@ public abstract class AbstractByteArrayOutputStream extends 
OutputStream {
 
     static final int DEFAULT_SIZE = 1024;
 
-    /** A singleton empty byte array. */
-    private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
-
     /** The list of buffers, which grows and never reduces. */
     private final List<byte[]> buffers = new ArrayList<>();
     /** The index of the current buffer. */
@@ -363,7 +360,7 @@ public abstract class AbstractByteArrayOutputStream extends 
OutputStream {
     protected byte[] toByteArrayImpl() {
         int remaining = count;
         if (remaining == 0) {
-            return EMPTY_BYTE_ARRAY;
+            return IOUtils.EMPTY_BYTE_ARRAY;
         }
         final byte[] newbuf = IOUtils.byteArray(remaining);
         int pos = 0;
diff --git a/src/test/java/org/apache/commons/io/CharsetsTestCase.java 
b/src/test/java/org/apache/commons/io/CharsetsTestCase.java
index 56f51f7..9ffae56 100644
--- a/src/test/java/org/apache/commons/io/CharsetsTestCase.java
+++ b/src/test/java/org/apache/commons/io/CharsetsTestCase.java
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.SortedMap;
+
 import org.junit.jupiter.api.Test;
 
 /**
diff --git 
a/src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTestCase.java 
b/src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTestCase.java
index 86fb213..614de3a 100644
--- 
a/src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTestCase.java
+++ 
b/src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTestCase.java
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
 import java.nio.file.Files;
+
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
diff --git 
a/src/test/java/org/apache/commons/io/file/PathUtilsDeleteFileTest.java 
b/src/test/java/org/apache/commons/io/file/PathUtilsDeleteFileTest.java
index d9c340e..863a265 100644
--- a/src/test/java/org/apache/commons/io/file/PathUtilsDeleteFileTest.java
+++ b/src/test/java/org/apache/commons/io/file/PathUtilsDeleteFileTest.java
@@ -22,12 +22,14 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assumptions.assumeFalse;
+
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.LinkOption;
 import java.nio.file.NoSuchFileException;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+
 import org.apache.commons.io.file.Counters.PathCounters;
 import org.apache.commons.lang3.SystemUtils;
 import org.junit.jupiter.api.AfterEach;
diff --git a/src/test/java/org/apache/commons/io/function/IOFunctionTest.java 
b/src/test/java/org/apache/commons/io/function/IOFunctionTest.java
index de0a015..8dcf478 100644
--- a/src/test/java/org/apache/commons/io/function/IOFunctionTest.java
+++ b/src/test/java/org/apache/commons/io/function/IOFunctionTest.java
@@ -17,7 +17,8 @@
 
 package org.apache.commons.io.function;
 
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -26,8 +27,7 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Supplier;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import org.junit.jupiter.api.Test;
 
 public class IOFunctionTest {
 
diff --git 
a/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
index 9845829..8595a7c 100644
--- a/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
@@ -68,7 +68,7 @@ public class BoundedInputStreamTest {
         compare("limit = -1", helloWorld, IOUtils.toByteArray(bounded));
 
         bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), 
0);
-        compare("limit = 0", new byte[0], IOUtils.toByteArray(bounded));
+        compare("limit = 0", IOUtils.EMPTY_BYTE_ARRAY, 
IOUtils.toByteArray(bounded));
 
         bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), 
helloWorld.length);
         compare("limit = length", helloWorld, IOUtils.toByteArray(bounded));
diff --git 
a/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
index 0ca3141..eb7ab52 100644
--- a/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
@@ -118,7 +118,7 @@ public class CountingInputStreamTest {
 
     @Test
     public void testZeroLength1() throws Exception {
-        final ByteArrayInputStream bais = new ByteArrayInputStream(new 
byte[0]);
+        final ByteArrayInputStream bais = new 
ByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
         try (final CountingInputStream cis = new CountingInputStream(bais)) {
 
             final int found = cis.read();
@@ -129,7 +129,7 @@ public class CountingInputStreamTest {
 
     @Test
     public void testZeroLength2() throws Exception {
-        final ByteArrayInputStream bais = new ByteArrayInputStream(new 
byte[0]);
+        final ByteArrayInputStream bais = new 
ByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
         try (final CountingInputStream cis = new CountingInputStream(bais)) {
 
             final byte[] result = new byte[10];
@@ -142,7 +142,7 @@ public class CountingInputStreamTest {
 
     @Test
     public void testZeroLength3() throws Exception {
-        final ByteArrayInputStream bais = new ByteArrayInputStream(new 
byte[0]);
+        final ByteArrayInputStream bais = new 
ByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
         try (final CountingInputStream cis = new CountingInputStream(bais)) {
 
             final byte[] result = new byte[10];
diff --git 
a/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java
index 1c3e4a0..3ec24c3 100644
--- a/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java
@@ -16,12 +16,15 @@
  */
 package org.apache.commons.io.input;
 
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.io.InputStream;
 
-import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.Test;
 
 public class MarkShieldInputStreamTest {
 
diff --git 
a/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
index 1fdfa90..16f1e77 100644
--- a/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
@@ -16,14 +16,9 @@
  */
 package org.apache.commons.io.input;
 
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.output.QueueOutputStream;
-import org.apache.commons.io.output.QueueOutputStreamTest;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -35,9 +30,14 @@ import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.stream.Stream;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.QueueOutputStream;
+import org.apache.commons.io.output.QueueOutputStreamTest;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 /**
  * Test {@link QueueInputStream}.
diff --git 
a/src/test/java/org/apache/commons/io/input/TimestampedObserverTest.java 
b/src/test/java/org/apache/commons/io/input/TimestampedObserverTest.java
index dca9e1d..a3cd425 100644
--- a/src/test/java/org/apache/commons/io/input/TimestampedObserverTest.java
+++ b/src/test/java/org/apache/commons/io/input/TimestampedObserverTest.java
@@ -17,8 +17,8 @@
 
 package org.apache.commons.io.input;
 
-import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.ByteArrayInputStream;
diff --git 
a/src/test/java/org/apache/commons/io/input/UnsynchronizedByteArrayInputStreamTest.java
 
b/src/test/java/org/apache/commons/io/input/UnsynchronizedByteArrayInputStreamTest.java
index 482e3ac..27b19d1 100644
--- 
a/src/test/java/org/apache/commons/io/input/UnsynchronizedByteArrayInputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/io/input/UnsynchronizedByteArrayInputStreamTest.java
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.io.input;
 
-import org.junit.jupiter.api.Test;
-
 import static 
org.apache.commons.io.input.UnsynchronizedByteArrayInputStream.END_OF_STREAM;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -26,6 +24,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 
+import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.Test;
+
 /**
  * Basic unit tests for the alternative ByteArrayInputStream implementation.
  */
@@ -33,7 +34,7 @@ public class UnsynchronizedByteArrayInputStreamTest {
 
     @Test
     public void testConstructor1() throws IOException {
-        final byte[] empty = new byte[0];
+        final byte[] empty = IOUtils.EMPTY_BYTE_ARRAY;
         final byte[] one = new byte[1];
         final byte[] some = new byte[25];
 
@@ -53,7 +54,7 @@ public class UnsynchronizedByteArrayInputStreamTest {
     @Test
     @SuppressWarnings("resource") // not necessary to close these resources
     public void testConstructor2() {
-        final byte[] empty = new byte[0];
+        final byte[] empty = IOUtils.EMPTY_BYTE_ARRAY;
         final byte[] one = new byte[1];
         final byte[] some = new byte[25];
 
@@ -82,7 +83,7 @@ public class UnsynchronizedByteArrayInputStreamTest {
     @Test
     @SuppressWarnings("resource") // not necessary to close these resources
     public void testConstructor3() {
-        final byte[] empty = new byte[0];
+        final byte[] empty = IOUtils.EMPTY_BYTE_ARRAY;
         final byte[] one = new byte[1];
         final byte[] some = new byte[25];
 
@@ -137,28 +138,28 @@ public class UnsynchronizedByteArrayInputStreamTest {
     @Test
     public void testInvalidConstructor2OffsetUnder() {
         assertThrows(IllegalArgumentException.class, () -> {
-            new UnsynchronizedByteArrayInputStream(new byte[0], -1);
+            new UnsynchronizedByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY, 
-1);
         });
     }
 
     @Test
     public void testInvalidConstructor3LengthUnder() {
         assertThrows(IllegalArgumentException.class, () -> {
-            new UnsynchronizedByteArrayInputStream(new byte[0], 0, -1);
+            new UnsynchronizedByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY, 
0, -1);
         });
     }
 
     @Test
     public void testInvalidConstructor3OffsetUnder() {
         assertThrows(IllegalArgumentException.class, () -> {
-            new UnsynchronizedByteArrayInputStream(new byte[0], -1, 1);
+            new UnsynchronizedByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY, 
-1, 1);
         });
     }
 
     @Test
     @SuppressWarnings("resource") // not necessary to close these resources
     public void testInvalidReadArrayExplicitLenUnder() {
-        final byte[] buf = new byte[0];
+        final byte[] buf = IOUtils.EMPTY_BYTE_ARRAY;
         final UnsynchronizedByteArrayInputStream is = new 
UnsynchronizedByteArrayInputStream(new byte[] {(byte)0xa, (byte)0xb, 
(byte)0xc});
         assertThrows(IndexOutOfBoundsException.class, () -> {
             is.read(buf, 0, -1);
@@ -167,7 +168,7 @@ public class UnsynchronizedByteArrayInputStreamTest {
 
     @Test
     public void testInvalidReadArrayExplicitOffsetUnder() {
-        final byte[] buf = new byte[0];
+        final byte[] buf = IOUtils.EMPTY_BYTE_ARRAY;
         @SuppressWarnings("resource") // not necessary to close these resources
         final UnsynchronizedByteArrayInputStream is = new 
UnsynchronizedByteArrayInputStream(new byte[] {(byte)0xa, (byte)0xb, 
(byte)0xc});
         assertThrows(IndexOutOfBoundsException.class, () -> {
@@ -177,7 +178,7 @@ public class UnsynchronizedByteArrayInputStreamTest {
 
     @Test
     public void testInvalidReadArrayExplicitRangeOver() {
-        final byte[] buf = new byte[0];
+        final byte[] buf = IOUtils.EMPTY_BYTE_ARRAY;
         @SuppressWarnings("resource") // not necessary to close these resources
         final UnsynchronizedByteArrayInputStream is = new 
UnsynchronizedByteArrayInputStream(new byte[] {(byte)0xa, (byte)0xb, 
(byte)0xc});
         assertThrows(IndexOutOfBoundsException.class, () -> {
@@ -234,12 +235,12 @@ public class UnsynchronizedByteArrayInputStreamTest {
     public void testReadArray() {
         byte[] buf = new byte[10];
         @SuppressWarnings("resource") // not necessary to close these resources
-        UnsynchronizedByteArrayInputStream is = new 
UnsynchronizedByteArrayInputStream(new byte[0]);
+        UnsynchronizedByteArrayInputStream is = new 
UnsynchronizedByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
         int read = is.read(buf);
         assertEquals(END_OF_STREAM, read);
         assertArrayEquals(new byte[10], buf);
 
-        buf = new byte[0];
+        buf = IOUtils.EMPTY_BYTE_ARRAY;
         is = new UnsynchronizedByteArrayInputStream(new byte[]{(byte) 0xa, 
(byte) 0xb, (byte) 0xc});
         read = is.read(buf);
         assertEquals(0, read);
@@ -268,24 +269,24 @@ public class UnsynchronizedByteArrayInputStreamTest {
     public void testReadArrayExplicit() {
         byte[] buf = new byte[10];
         @SuppressWarnings("resource") // not necessary to close these resources
-        UnsynchronizedByteArrayInputStream is = new 
UnsynchronizedByteArrayInputStream(new byte[0]);
+        UnsynchronizedByteArrayInputStream is = new 
UnsynchronizedByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
         int read = is.read(buf, 0, 10);
         assertEquals(END_OF_STREAM, read);
         assertArrayEquals(new byte[10], buf);
 
         buf = new byte[10];
-        is = new UnsynchronizedByteArrayInputStream(new byte[0]);
+        is = new UnsynchronizedByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
         read = is.read(buf, 4, 2);
         assertEquals(END_OF_STREAM, read);
         assertArrayEquals(new byte[10], buf);
 
         buf = new byte[10];
-        is = new UnsynchronizedByteArrayInputStream(new byte[0]);
+        is = new UnsynchronizedByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
         read = is.read(buf, 4, 6);
         assertEquals(END_OF_STREAM, read);
         assertArrayEquals(new byte[10], buf);
 
-        buf = new byte[0];
+        buf = IOUtils.EMPTY_BYTE_ARRAY;
         is = new UnsynchronizedByteArrayInputStream(new byte[]{(byte) 0xa, 
(byte) 0xb, (byte) 0xc});
         read = is.read(buf, 0,0);
         assertEquals(0, read);
@@ -305,7 +306,7 @@ public class UnsynchronizedByteArrayInputStreamTest {
     @Test
     public void testReadSingle() {
         @SuppressWarnings("resource") // not necessary to close these resources
-        UnsynchronizedByteArrayInputStream is = new 
UnsynchronizedByteArrayInputStream(new byte[0]);
+        UnsynchronizedByteArrayInputStream is = new 
UnsynchronizedByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
         assertEquals(END_OF_STREAM, is.read());
 
         is = new UnsynchronizedByteArrayInputStream(new byte[] {(byte)0xa, 
(byte)0xb, (byte)0xc});
diff --git 
a/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java 
b/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java
index 6846c55..da38934 100644
--- 
a/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java
+++ 
b/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java
@@ -16,6 +16,13 @@
  */
 package org.apache.commons.io.output;
 
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -28,13 +35,6 @@ import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.MethodSource;
 
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
 /**
  * Basic unit tests for the alternative ByteArrayOutputStream implementations.
  */
@@ -106,7 +106,7 @@ public class ByteArrayOutputStreamTestCase {
     @MethodSource("baosFactories")
     public void testWriteZero(final String baosName, final BAOSFactory<?> 
baosFactory) throws IOException {
         try (final AbstractByteArrayOutputStream baout = 
baosFactory.newInstance()) {
-            baout.write(new byte[0], 0, 0);
+            baout.write(IOUtils.EMPTY_BYTE_ARRAY, 0, 0);
             assertTrue(true, "Dummy");
         }
     }
@@ -123,7 +123,7 @@ public class ByteArrayOutputStreamTestCase {
     @MethodSource("baosFactories")
     public void testInvalidWriteOffsetOver(final String baosName, final 
BAOSFactory<?> baosFactory) throws IOException {
         try (final AbstractByteArrayOutputStream baout = 
baosFactory.newInstance()) {
-            assertThrows(IndexOutOfBoundsException.class, () -> 
baout.write(new byte[0], 1, 0));
+            assertThrows(IndexOutOfBoundsException.class, () -> 
baout.write(IOUtils.EMPTY_BYTE_ARRAY, 1, 0));
         }
     }
 
@@ -174,7 +174,7 @@ public class ByteArrayOutputStreamTestCase {
     @ParameterizedTest(name = "[{index}] {0}")
     @MethodSource("toBufferedInputStreamFunctionFactories")
     public void testToBufferedInputStreamEmpty(final String baosName, final 
IOFunction<InputStream, InputStream> toBufferedInputStreamFunction) throws 
IOException {
-        try (final ByteArrayInputStream bain = new ByteArrayInputStream(new 
byte[0])) {
+        try (final ByteArrayInputStream bain = new 
ByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY)) {
             assertEquals(0, bain.available());
 
             try (final InputStream buffered = 
toBufferedInputStreamFunction.apply(bain)) {
diff --git 
a/src/test/java/org/apache/commons/io/output/QueueOutputStreamTest.java 
b/src/test/java/org/apache/commons/io/output/QueueOutputStreamTest.java
index 06c3c5c..c1aeaf8 100644
--- a/src/test/java/org/apache/commons/io/output/QueueOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/QueueOutputStreamTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.commons.io.output;
 
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.input.QueueInputStream;
-import org.apache.commons.io.input.QueueInputStreamTest;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.Test;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.InterruptedIOException;
 import java.nio.charset.StandardCharsets;
@@ -30,11 +30,11 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.LinkedBlockingQueue;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.QueueInputStream;
+import org.apache.commons.io.input.QueueInputStreamTest;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test {@link QueueOutputStream} and {@link QueueInputStream}

Reply via email to