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-compress.git
commit 4b52e7ecea8a6c24104ca9d8f4965f139d364344 Author: Gary D. Gregory <[email protected]> AuthorDate: Tue Sep 9 16:10:17 2025 -0700 Deprecate ByteUtils.EMPTY_BYTE_ARRAY in favor or ArrayUtils.EMPTY_BYTE_ARRAY --- src/changes/changes.xml | 3 ++- .../commons/compress/archivers/sevenz/AbstractCoder.java | 4 ++-- .../apache/commons/compress/archivers/sevenz/SevenZFile.java | 3 +-- .../org/apache/commons/compress/archivers/zip/JarMarker.java | 6 +++--- .../apache/commons/compress/archivers/zip/X7875_NewUnix.java | 3 +-- .../archivers/zip/Zip64ExtendedInformationExtraField.java | 4 ++-- .../apache/commons/compress/archivers/zip/ZipArchiveEntry.java | 3 +-- .../commons/compress/archivers/zip/ZipArchiveOutputStream.java | 4 ++-- .../commons/compress/compressors/deflate64/HuffmanDecoder.java | 4 ++-- src/main/java/org/apache/commons/compress/utils/ByteUtils.java | 6 +++++- .../commons/compress/utils/SeekableInMemoryByteChannel.java | 4 +++- .../commons/compress/archivers/ArchiveStreamFactoryTest.java | 6 +++--- .../java/org/apache/commons/compress/archivers/TarTest.java | 6 +++--- .../compress/archivers/sevenz/SevenZNativeHeapTest.java | 4 ++-- .../compress/archivers/sevenz/SevenZOutputFileTest.java | 6 +++--- .../apache/commons/compress/archivers/tar/TarUtilsTest.java | 4 ++-- .../apache/commons/compress/archivers/zip/BitStreamTest.java | 4 ++-- .../commons/compress/archivers/zip/X7875_NewUnixTest.java | 6 +++--- .../commons/compress/archivers/zip/ZipArchiveEntryTest.java | 10 +++++----- .../compress/archivers/zip/ZipArchiveInputStreamTest.java | 10 +++++----- .../org/apache/commons/compress/archivers/zip/ZipFileTest.java | 8 ++++---- .../commons/compress/compressors/DetectCompressorTest.java | 6 +++--- .../lz77support/AbstractLZ77CompressorInputStreamTest.java | 6 +++--- .../org/apache/commons/compress/utils/BitInputStreamTest.java | 3 ++- .../java/org/apache/commons/compress/utils/ByteUtilsTest.java | 9 +++++---- .../compress/utils/ChecksumCalculatingInputStreamTest.java | 5 +++-- .../java/org/apache/commons/compress/utils/IOUtilsTest.java | 9 +++++---- .../compress/utils/MultiReadOnlySeekableByteChannelTest.java | 3 ++- .../utils/ZipSplitReadOnlySeekableByteChannelTest.java | 3 ++- 29 files changed, 81 insertions(+), 71 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 164ef80a5..c6a68132e 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -43,7 +43,6 @@ The <action> type attribute can be add,update,fix,remove. </properties> <body> <release version="1.29.0" date="YYYY-MM-DD" description="This is a feature and maintenance release. Java 8 or later is required. This release updates Apache Commons Lang to 3.18.0 to pick up the fix for CVE-2025-48924 (https://nvd.nist.gov/vuln/detail/CVE-2025-48924), but is not affected by it."> - <!-- FIX --> <!-- FIX sevenz --> <action type="fix" issue="COMPRESS-702" dev="ggregory" due-to="Zhang Di, Lastoneee">Performance issue in SevenZFile #681.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix kilobyte to kibibyte conversion in SevenZFile.ArchiveStatistics.assertValidity(int).</action> @@ -97,6 +96,8 @@ The <action> type attribute can be add,update,fix,remove. <action type="fix" dev="ggregory" due-to="Gary Gregory">Classes in org.apache.commons.compress.archivers now throw a subclass of IOException called ArchiveException instead of IOException when a formatting problem is found.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Classes in org.apache.commons.compress.compressors now throw a subclass of IOException called CompressorException instead of IOException when a formatting problem is found.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Normalize exception message sentences to start with a capital letter.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate ByteUtils.EMPTY_BYTE_ARRAY in favor or ArrayUtils.EMPTY_BYTE_ARRAY.</action> + <!-- FIX --> <!-- ADD --> <action type="add" dev="ggregory" due-to="Gary Gregory">Add MemoryLimitException.MemoryLimitException(long, long).</action> <action type="add" dev="ggregory" due-to="Gary Gregory">Add CompressException.CompressException(String, Object...).</action> diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/AbstractCoder.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/AbstractCoder.java index 6934f717a..3e26fa5db 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/AbstractCoder.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/AbstractCoder.java @@ -24,7 +24,7 @@ import java.util.Objects; import java.util.stream.Stream; -import org.apache.commons.compress.utils.ByteUtils; +import org.apache.commons.lang3.ArrayUtils; /** * Abstracts a base Codec class. @@ -78,7 +78,7 @@ OutputStream encode(final OutputStream out, final Object options) throws IOExcep * @throws IOException Optionally thrown by subclassses. */ byte[] getOptionsAsProperties(final Object options) throws IOException { - return ByteUtils.EMPTY_BYTE_ARRAY; + return ArrayUtils.EMPTY_BYTE_ARRAY; } /** diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java index e458eb2eb..84724e246 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java @@ -52,7 +52,6 @@ import org.apache.commons.compress.MemoryLimitException; import org.apache.commons.compress.archivers.ArchiveException; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.compress.utils.InputStreamStatistics; import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; @@ -1006,7 +1005,7 @@ private void computeIfAbsent(final Map<Integer, SevenZArchiveEntry> archiveEntri private InputStream getCurrentStream() throws IOException { if (archive.files[currentEntryIndex].getSize() == 0) { - return new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY); + return new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY); } if (deferredBlockStreams.isEmpty()) { throw new IllegalStateException("No current 7z entry (call getNextEntry() first)."); diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/JarMarker.java b/src/main/java/org/apache/commons/compress/archivers/zip/JarMarker.java index 6bb156f87..b6763ab72 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/JarMarker.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/JarMarker.java @@ -20,7 +20,7 @@ import java.util.zip.ZipException; -import org.apache.commons.compress.utils.ByteUtils; +import org.apache.commons.lang3.ArrayUtils; /** * If this extra field is added as the very first extra field of the archive, Solaris will consider it an executable jar file. @@ -54,7 +54,7 @@ public JarMarker() { */ @Override public byte[] getCentralDirectoryData() { - return ByteUtils.EMPTY_BYTE_ARRAY; + return ArrayUtils.EMPTY_BYTE_ARRAY; } /** @@ -84,7 +84,7 @@ public ZipShort getHeaderId() { */ @Override public byte[] getLocalFileDataData() { - return ByteUtils.EMPTY_BYTE_ARRAY; + return ArrayUtils.EMPTY_BYTE_ARRAY; } /** diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X7875_NewUnix.java b/src/main/java/org/apache/commons/compress/archivers/zip/X7875_NewUnix.java index 8ac2ffecf..f2311efcb 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/X7875_NewUnix.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/X7875_NewUnix.java @@ -26,7 +26,6 @@ import java.util.Arrays; import java.util.zip.ZipException; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.lang3.ArrayUtils; /** @@ -153,7 +152,7 @@ public boolean equals(final Object o) { */ @Override public byte[] getCentralDirectoryData() { - return ByteUtils.EMPTY_BYTE_ARRAY; + return ArrayUtils.EMPTY_BYTE_ARRAY; } /** diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java index 7093512d7..9fbc4f22e 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java @@ -23,7 +23,7 @@ import java.util.zip.ZipException; -import org.apache.commons.compress.utils.ByteUtils; +import org.apache.commons.lang3.ArrayUtils; /** * Holds size and other extended information for entries that use Zip64 features. @@ -162,7 +162,7 @@ public byte[] getLocalFileDataData() { addSizes(data); return data; } - return ByteUtils.EMPTY_BYTE_ARRAY; + return ArrayUtils.EMPTY_BYTE_ARRAY; } @Override diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java index 863d56a96..59879f562 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java @@ -38,7 +38,6 @@ import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.EntryStreamOffsets; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.io.file.attribute.FileTimes; import org.apache.commons.lang3.ArrayUtils; @@ -823,7 +822,7 @@ public Date getLastModifiedDate() { */ public byte[] getLocalFileDataExtra() { final byte[] extra = getExtra(); - return extra != null ? extra : ByteUtils.EMPTY_BYTE_ARRAY; + return extra != null ? extra : ArrayUtils.EMPTY_BYTE_ARRAY; } /** diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java index 8672e2fd6..9b643bfff 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java @@ -40,8 +40,8 @@ import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.ArchiveOutputStream; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.io.Charsets; +import org.apache.commons.lang3.ArrayUtils; /** * Reimplementation of {@link java.util.zip.ZipOutputStream java.util.zip.ZipOutputStream} to handle the extended functionality of this package, especially @@ -1166,7 +1166,7 @@ private void preClose() throws IOException { } if (!entry.hasWritten) { - write(ByteUtils.EMPTY_BYTE_ARRAY, 0, 0); + write(ArrayUtils.EMPTY_BYTE_ARRAY, 0, 0); } } diff --git a/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java b/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java index 586be380b..e9821f7ab 100644 --- a/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java +++ b/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java @@ -31,9 +31,9 @@ import java.util.Arrays; import org.apache.commons.compress.utils.BitInputStream; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.compress.utils.ExactMath; import org.apache.commons.lang3.ArrayFill; +import org.apache.commons.lang3.ArrayUtils; /** * TODO This class can't be final because it is mocked by Mockito. @@ -137,7 +137,7 @@ private final class HuffmanCodes extends DecoderState { private final BinaryTreeNode distanceTree; private int runBufferPos; - private byte[] runBuffer = ByteUtils.EMPTY_BYTE_ARRAY; + private byte[] runBuffer = ArrayUtils.EMPTY_BYTE_ARRAY; private int runBufferLength; HuffmanCodes(final HuffmanState state, final int[] lengths, final int[] distance) { diff --git a/src/main/java/org/apache/commons/compress/utils/ByteUtils.java b/src/main/java/org/apache/commons/compress/utils/ByteUtils.java index c89f933e3..0ad786296 100644 --- a/src/main/java/org/apache/commons/compress/utils/ByteUtils.java +++ b/src/main/java/org/apache/commons/compress/utils/ByteUtils.java @@ -25,6 +25,8 @@ import java.io.InputStream; import java.io.OutputStream; +import org.apache.commons.lang3.ArrayUtils; + /** * Utility methods for reading and writing bytes. * @@ -114,8 +116,10 @@ public void accept(final int b) throws IOException { * Empty array. * * @since 1.21 + * @deprecated Use {@link ArrayUtils#EMPTY_BYTE_ARRAY}. */ - public static final byte[] EMPTY_BYTE_ARRAY = {}; + @Deprecated + public static final byte[] EMPTY_BYTE_ARRAY = ArrayUtils.EMPTY_BYTE_ARRAY; private static void checkReadLength(final int length) { if (length > 8) { diff --git a/src/main/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannel.java b/src/main/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannel.java index 0ee624aaf..286a11d76 100644 --- a/src/main/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannel.java +++ b/src/main/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannel.java @@ -26,6 +26,8 @@ import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.commons.lang3.ArrayUtils; + /** * A {@link SeekableByteChannel} implementation that wraps a byte[]. * <p> @@ -50,7 +52,7 @@ public class SeekableInMemoryByteChannel implements SeekableByteChannel { * Constructs a new instance using a default empty buffer. */ public SeekableInMemoryByteChannel() { - this(ByteUtils.EMPTY_BYTE_ARRAY); + this(ArrayUtils.EMPTY_BYTE_ARRAY); } /** diff --git a/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java b/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java index 1fe084286..1563bda46 100644 --- a/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java @@ -45,8 +45,8 @@ import org.apache.commons.compress.archivers.jar.JarArchiveInputStream; import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.io.input.BrokenInputStream; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.reflect.FieldUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -235,7 +235,7 @@ void testAiffFilesAreNoTARs() throws Exception { @Test void testCantRead7zFromStream() throws Exception { assertThrows(StreamingNotSupportedException.class, () -> ArchiveStreamFactory.DEFAULT.createArchiveInputStream(ArchiveStreamFactory.SEVEN_Z, - new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))); + new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))); } @Test @@ -264,7 +264,7 @@ void testDetect() throws Exception { } final ArchiveException e1 = assertThrows(ArchiveException.class, - () -> ArchiveStreamFactory.detect(new BufferedInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))), + () -> ArchiveStreamFactory.detect(new BufferedInputStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))), "shouldn't be able to detect empty stream"); assertEquals("No Archiver found for the stream signature", e1.getMessage()); diff --git a/src/test/java/org/apache/commons/compress/archivers/TarTest.java b/src/test/java/org/apache/commons/compress/archivers/TarTest.java index 512df8842..26d79e2de 100644 --- a/src/test/java/org/apache/commons/compress/archivers/TarTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/TarTest.java @@ -44,8 +44,8 @@ import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; import org.apache.commons.compress.archivers.tar.TarConstants; import org.apache.commons.compress.archivers.tar.TarFile; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; import shaded.org.apache.commons.lang3.StringUtils; @@ -135,7 +135,7 @@ void testDirectoryRead() throws IOException { assertEquals(TarConstants.LF_DIR, directoryEntry.getLinkFlag()); assertTrue(directoryEntry.isDirectory()); final byte[] directoryRead = IOUtils.toByteArray(in); - assertArrayEquals(ByteUtils.EMPTY_BYTE_ARRAY, directoryRead); + assertArrayEquals(ArrayUtils.EMPTY_BYTE_ARRAY, directoryRead); } } @@ -353,7 +353,7 @@ void testTarFileDirectoryRead() throws IOException { assertTrue(directoryEntry.isDirectory()); try (InputStream directoryStream = tarFile.getInputStream(directoryEntry)) { final byte[] directoryRead = IOUtils.toByteArray(directoryStream); - assertArrayEquals(ByteUtils.EMPTY_BYTE_ARRAY, directoryRead); + assertArrayEquals(ArrayUtils.EMPTY_BYTE_ARRAY, directoryRead); } } } diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZNativeHeapTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZNativeHeapTest.java index 990c6d0e4..e034de5fc 100644 --- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZNativeHeapTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZNativeHeapTest.java @@ -31,7 +31,7 @@ import org.apache.commons.compress.archivers.sevenz.Coders.DeflateDecoder; import org.apache.commons.compress.archivers.sevenz.Coders.DeflateDecoder.DeflateDecoderInputStream; import org.apache.commons.compress.archivers.sevenz.Coders.DeflateDecoder.DeflateDecoderOutputStream; -import org.apache.commons.compress.utils.ByteUtils; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; class SevenZNativeHeapTest extends AbstractTest { @@ -259,7 +259,7 @@ void testEndInflaterOnCloseStream() throws Exception { final Coders.DeflateDecoder deflateDecoder = new DeflateDecoder(); final DelegatingInflater delegatingInflater; try (DeflateDecoderInputStream inputStream = (DeflateDecoderInputStream) deflateDecoder.decode("dummy", - new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), 0, null, null, Integer.MAX_VALUE)) { + new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY), 0, null, null, Integer.MAX_VALUE)) { delegatingInflater = new DelegatingInflater(inputStream.inflater); inputStream.inflater = delegatingInflater; } diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java index 6b527cbc7..ddcf781f7 100644 --- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java @@ -44,9 +44,9 @@ import org.apache.commons.compress.AbstractTest; import org.apache.commons.compress.PasswordRequiredException; import org.apache.commons.compress.archivers.ArchiveException; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; import org.apache.commons.compress.utils.TimeUtilsTest; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; import org.tukaani.xz.LZMA2Options; @@ -277,7 +277,7 @@ void testDirectoriesAndEmptyFiles() throws Exception { entry.setCreationDate(creationDate); entry.setAccessTime(accessTime); outArchive.putArchiveEntry(entry); - outArchive.write(ByteUtils.EMPTY_BYTE_ARRAY); + outArchive.write(ArrayUtils.EMPTY_BYTE_ARRAY); outArchive.closeArchiveEntry(); entry = new SevenZArchiveEntry(); @@ -285,7 +285,7 @@ void testDirectoriesAndEmptyFiles() throws Exception { entry.setCreationDate(creationDate); entry.setAccessTime(accessTime); outArchive.putArchiveEntry(entry); - outArchive.write(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY)); + outArchive.write(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY)); outArchive.closeArchiveEntry(); entry = new SevenZArchiveEntry(); diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java index 8b3a630d6..e42712276 100644 --- a/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java @@ -43,8 +43,8 @@ import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.zip.ZipEncoding; import org.apache.commons.compress.archivers.zip.ZipEncodingHelper; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.io.input.NullInputStream; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -273,7 +273,7 @@ void testParseOctalEmbeddedSpace() { @Test void testParseOctalInvalid() { - final byte[] buffer1 = ByteUtils.EMPTY_BYTE_ARRAY; + final byte[] buffer1 = ArrayUtils.EMPTY_BYTE_ARRAY; assertThrows(IllegalArgumentException.class, () -> TarUtils.parseOctal(buffer1, 0, buffer1.length), "Expected IllegalArgumentException - should be at least 2 bytes long"); diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java index 6addf8ad3..0d0d6f184 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java @@ -23,7 +23,7 @@ import java.io.ByteArrayInputStream; -import org.apache.commons.compress.utils.ByteUtils; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; class BitStreamTest { @@ -43,7 +43,7 @@ void testNextByte() throws Exception { @Test void testNextByteFromEmptyStream() throws Exception { - try (BitStream stream = new BitStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))) { + try (BitStream stream = new BitStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))) { assertEquals(-1, stream.nextByte(), "next byte"); assertEquals(-1, stream.nextByte(), "next byte"); } diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java index 5d28a5e53..67b1e7ccf 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/X7875_NewUnixTest.java @@ -27,7 +27,7 @@ import java.util.zip.ZipException; -import org.apache.commons.compress.utils.ByteUtils; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -80,7 +80,7 @@ private void parseReparse(final long uid, final long gid, final byte[] expected, assertEquals(0, xf.getCentralDirectoryLength().getValue()); result = xf.getCentralDirectoryData(); - assertArrayEquals(ByteUtils.EMPTY_BYTE_ARRAY, result); + assertArrayEquals(ArrayUtils.EMPTY_BYTE_ARRAY, result); // And now we re-parse: xf.parseFromCentralDirectoryData(result, 0, result.length); @@ -197,7 +197,7 @@ void testSampleFile() throws Exception { @Test void testTrimLeadingZeroesForceMinLength4() { final byte[] NULL = null; - final byte[] EMPTY = ByteUtils.EMPTY_BYTE_ARRAY; + final byte[] EMPTY = ArrayUtils.EMPTY_BYTE_ARRAY; final byte[] ONE_ZERO = { 0 }; final byte[] TWO_ZEROES = { 0, 0 }; final byte[] FOUR_ZEROES = { 0, 0, 0, 0 }; diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java index 35af7b2b1..a34438405 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java @@ -36,9 +36,9 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipException; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.compress.utils.TimeUtils; import org.apache.commons.io.file.attribute.FileTimes; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; /** @@ -61,7 +61,7 @@ private ZipExtraField[] parsingModeBehaviorTestData() { a.setMode(0755); final UnrecognizedExtraField u = new UnrecognizedExtraField(); u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - u.setLocalFileDataData(ByteUtils.EMPTY_BYTE_ARRAY); + u.setLocalFileDataData(ArrayUtils.EMPTY_BYTE_ARRAY); final UnparseableExtraFieldData x = new UnparseableExtraFieldData(); final byte[] unparseable = { 0, 0, (byte) 0xff, (byte) 0xff, 0, 0, 0 }; x.parseFromLocalFileData(unparseable, 0, unparseable.length); @@ -78,7 +78,7 @@ void testAddAsFirstExtraField() { a.setMode(0755); final UnrecognizedExtraField u = new UnrecognizedExtraField(); u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - u.setLocalFileDataData(ByteUtils.EMPTY_BYTE_ARRAY); + u.setLocalFileDataData(ArrayUtils.EMPTY_BYTE_ARRAY); final ZipArchiveEntry ze = new ZipArchiveEntry("test/"); ze.setExtraFields(new ZipExtraField[] { a, u }); @@ -160,7 +160,7 @@ void testExtraFieldMerging() { a.setMode(0755); final UnrecognizedExtraField u = new UnrecognizedExtraField(); u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - u.setLocalFileDataData(ByteUtils.EMPTY_BYTE_ARRAY); + u.setLocalFileDataData(ArrayUtils.EMPTY_BYTE_ARRAY); final ZipArchiveEntry ze = new ZipArchiveEntry("test/"); ze.setExtraFields(new ZipExtraField[] { a, u }); @@ -206,7 +206,7 @@ void testExtraFields() { a.setMode(0755); final UnrecognizedExtraField u = new UnrecognizedExtraField(); u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - u.setLocalFileDataData(ByteUtils.EMPTY_BYTE_ARRAY); + u.setLocalFileDataData(ArrayUtils.EMPTY_BYTE_ARRAY); final ZipArchiveEntry ze = new ZipArchiveEntry("test/"); ze.setExtraFields(new ZipExtraField[] { a, u }); diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java index 8fdd0b739..79258f5b5 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java @@ -53,10 +53,10 @@ import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.ArchiveInputStream; import org.apache.commons.compress.archivers.ArchiveStreamFactory; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.io.function.IOConsumer; import org.apache.commons.lang3.ArrayFill; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -212,14 +212,14 @@ void testDecompressNextSymbol() throws IOException { @Test void testGetCompressedCountEmptyZip() throws IOException { - try (ZipArchiveInputStream zin = new ZipArchiveInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))) { + try (ZipArchiveInputStream zin = new ZipArchiveInputStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))) { assertEquals(-1, zin.getCompressedCount()); } } @Test void testGetFirstEntryEmptyZip() throws IOException { - try (ZipArchiveInputStream zin = new ZipArchiveInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))) { + try (ZipArchiveInputStream zin = new ZipArchiveInputStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))) { final ZipArchiveEntry entry = zin.getNextEntry(); assertNull(entry); } @@ -235,7 +235,7 @@ void testGetNextZipEntry() throws IOException { @Test void testGetUncompressedCountEmptyZip() throws IOException { - try (ZipArchiveInputStream zin = new ZipArchiveInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))) { + try (ZipArchiveInputStream zin = new ZipArchiveInputStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))) { assertEquals(0, zin.getUncompressedCount()); } } @@ -338,7 +338,7 @@ void testOffsets() throws Exception { @Test void testProperlyMarksEntriesAsUnreadableIfUncompressedSizeIsUnknown() throws Exception { // we never read any data - try (ZipArchiveInputStream zis = new ZipArchiveInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))) { + try (ZipArchiveInputStream zis = new ZipArchiveInputStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))) { final ZipArchiveEntry e = new ZipArchiveEntry("test"); e.setMethod(ZipMethod.DEFLATED.getCode()); assertTrue(zis.canReadEntryData(e)); diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java index 06adb90f2..9bc86856f 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java @@ -57,11 +57,11 @@ import org.apache.commons.compress.AbstractTest; import org.apache.commons.compress.archivers.ArchiveException; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; import org.apache.commons.io.IOUtils; import org.apache.commons.io.function.IORunnable; import org.apache.commons.lang3.ArrayFill; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.SystemUtils; import org.junit.Assume; import org.junit.jupiter.api.AfterEach; @@ -129,7 +129,7 @@ private void assertAllReadMethods(final byte[] expected, final ZipFile zipFile, final byte[] bytes = new byte[0x40000]; final int read = stream.read(bytes); if (read < 0) { - full = ByteUtils.EMPTY_BYTE_ARRAY; + full = ArrayUtils.EMPTY_BYTE_ARRAY; } else { full = readStreamRest(bytes, read, stream); } @@ -141,7 +141,7 @@ private void assertAllReadMethods(final byte[] expected, final ZipFile zipFile, final byte[] full; final int single = stream.read(); if (single < 0) { - full = ByteUtils.EMPTY_BYTE_ARRAY; + full = ArrayUtils.EMPTY_BYTE_ARRAY; } else { final byte[] big = new byte[0x40000]; big[0] = (byte) single; @@ -973,7 +973,7 @@ void testSkipsPK00Prefix() throws Exception { void testThrowsExceptionWhenWritingPreamble() throws IOException { try (ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(new ByteArrayOutputStream())) { outputStream.putArchiveEntry(new ZipArchiveEntry()); - assertThrows(IllegalStateException.class, () -> outputStream.writePreamble(ByteUtils.EMPTY_BYTE_ARRAY)); + assertThrows(IllegalStateException.class, () -> outputStream.writePreamble(ArrayUtils.EMPTY_BYTE_ARRAY)); outputStream.closeArchiveEntry(); } } diff --git a/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTest.java b/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTest.java index 3e559e194..77ddd04c4 100644 --- a/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTest.java @@ -43,8 +43,8 @@ import org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream; import org.apache.commons.compress.compressors.xz.XZCompressorInputStream; import org.apache.commons.compress.compressors.zstandard.ZstdCompressorInputStream; -import org.apache.commons.compress.utils.ByteUtils; import org.apache.commons.io.input.BrokenInputStream; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -240,7 +240,7 @@ void testCreateWithAutoDetection() throws Exception { assertInstanceOf(ZstdCompressorInputStream.class, zstd); } - assertThrows(CompressorException.class, () -> factory.createCompressorInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))); + assertThrows(CompressorException.class, () -> factory.createCompressorInputStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))); } @Test @@ -261,7 +261,7 @@ void testDetect() throws Exception { assertEquals(CompressorStreamFactory.LZMA, detect("COMPRESS-382")); assertThrows(CompressorException.class, - () -> CompressorStreamFactory.detect(new BufferedInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY)))); + () -> CompressorStreamFactory.detect(new BufferedInputStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY)))); final IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> CompressorStreamFactory.detect(null), "shouldn't be able to detect null stream"); diff --git a/src/test/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStreamTest.java index 42afb5c30..e955cfab6 100644 --- a/src/test/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/lz77support/AbstractLZ77CompressorInputStreamTest.java @@ -26,7 +26,7 @@ import java.io.IOException; import java.io.InputStream; -import org.apache.commons.compress.utils.ByteUtils; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; class AbstractLZ77CompressorInputStreamTest { @@ -68,7 +68,7 @@ void testIfPrefillExceedsWindowSizeTheLastBytesAreUsed() throws IOException { final byte[] data = new byte[2048]; data[2046] = 3; data[2047] = 4; - try (TestStream s = new TestStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))) { + try (TestStream s = new TestStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))) { s.prefill(data); s.startBackReference(2, 4); final byte[] r = new byte[4]; @@ -80,7 +80,7 @@ void testIfPrefillExceedsWindowSizeTheLastBytesAreUsed() throws IOException { @Test void testPrefillCanBeUsedForBackReferences() throws IOException { final byte[] data = { 1, 2, 3, 4 }; - try (TestStream s = new TestStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))) { + try (TestStream s = new TestStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY))) { s.prefill(data); s.startBackReference(2, 4); final byte[] r = new byte[4]; diff --git a/src/test/java/org/apache/commons/compress/utils/BitInputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/BitInputStreamTest.java index 60eac230c..513412e42 100644 --- a/src/test/java/org/apache/commons/compress/utils/BitInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/utils/BitInputStreamTest.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.nio.ByteOrder; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; class BitInputStreamTest { @@ -200,7 +201,7 @@ void testReading31BitsInLittleEndian() throws IOException { @Test void testReadingOneBitFromEmptyStream() throws Exception { - try (BitInputStream bis = new BitInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), ByteOrder.LITTLE_ENDIAN)) { + try (BitInputStream bis = new BitInputStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY), ByteOrder.LITTLE_ENDIAN)) { assertEquals(-1, bis.readBit(), "next bit"); assertEquals(-1, bis.readBit(), "next bit"); assertEquals(-1, bis.readBit(), "next bit"); diff --git a/src/test/java/org/apache/commons/compress/utils/ByteUtilsTest.java b/src/test/java/org/apache/commons/compress/utils/ByteUtilsTest.java index 9ad1bbd66..7a09478dd 100644 --- a/src/test/java/org/apache/commons/compress/utils/ByteUtilsTest.java +++ b/src/test/java/org/apache/commons/compress/utils/ByteUtilsTest.java @@ -37,6 +37,7 @@ import org.apache.commons.compress.utils.ByteUtils.InputStreamByteSupplier; import org.apache.commons.compress.utils.ByteUtils.OutputStreamByteConsumer; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; class ByteUtilsTest { @@ -66,7 +67,7 @@ void testFromLittleEndianFromArrayOneArgUnsignedInt32() { @Test void testFromLittleEndianFromArrayThrowsForLengthTooBig() { - assertThrows(IllegalArgumentException.class, () -> fromLittleEndian(ByteUtils.EMPTY_BYTE_ARRAY, 0, 9)); + assertThrows(IllegalArgumentException.class, () -> fromLittleEndian(ArrayUtils.EMPTY_BYTE_ARRAY, 0, 9)); } @Test @@ -83,7 +84,7 @@ void testFromLittleEndianFromDataInput() throws IOException { @Test void testFromLittleEndianFromDataInputThrowsForLengthTooBig() { - final DataInput din = new DataInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY)); + final DataInput din = new DataInputStream(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY)); assertThrows(IllegalArgumentException.class, () -> fromLittleEndian(din, 9)); } @@ -107,7 +108,7 @@ void testFromLittleEndianFromStream() throws IOException { @Test void testFromLittleEndianFromStreamThrowsForLengthTooBig() { - assertThrows(IllegalArgumentException.class, () -> fromLittleEndian(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), 9)); + assertThrows(IllegalArgumentException.class, () -> fromLittleEndian(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY), 9)); } @Test @@ -131,7 +132,7 @@ void testFromLittleEndianFromSupplier() throws IOException { @Test void testFromLittleEndianFromSupplierThrowsForLengthTooBig() { assertThrows(IllegalArgumentException.class, - () -> fromLittleEndian(new InputStreamByteSupplier(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY)), 9)); + () -> fromLittleEndian(new InputStreamByteSupplier(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY)), 9)); } @Test diff --git a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java index 3f31eda16..a4b6bd2e1 100644 --- a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java @@ -29,6 +29,7 @@ import java.util.zip.CRC32; import java.util.zip.CheckedInputStream; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; /** @@ -138,7 +139,7 @@ void testSkipReturningPositiveSanityCheck() throws IOException { @Test void testSkipReturningZero() throws IOException { final Adler32 adler32 = new Adler32(); - final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY); + final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY); try (ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32, byteArrayInputStream)) { final long skipResult = checksumCalculatingInputStream.skip(60L); assertEquals(0L, skipResult); @@ -149,7 +150,7 @@ void testSkipReturningZero() throws IOException { @Test void testSkipReturningZeroSanityCheck() throws IOException { final Adler32 adler32 = new Adler32(); - final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY); + final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY); try (CheckedInputStream checksumCalculatingInputStream = new CheckedInputStream(byteArrayInputStream, adler32)) { final long skipResult = checksumCalculatingInputStream.skip(60L); assertEquals(0L, skipResult); 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 38128c22d..be73d7942 100644 --- a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java +++ b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java @@ -37,6 +37,7 @@ import org.apache.commons.io.input.NullInputStream; import org.apache.commons.io.output.NullOutputStream; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; class IOUtilsTest { @@ -84,7 +85,7 @@ void testCopy_inputStreamToOutputStream_nullOut() { @Test void testCopyOnZeroBufferSize() throws IOException { - assertEquals(0, IOUtils.copy(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), new ByteArrayOutputStream(), 0)); + assertEquals(0, IOUtils.copy(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY), new ByteArrayOutputStream(), 0)); } @Test @@ -110,9 +111,9 @@ void testCopyRangeStopsIfThereIsNothingToCopyAnymore() throws IOException { @Test void testCopyRangeThrowsOnZeroBufferSize() throws IOException { assertThrows(IllegalArgumentException.class, - () -> IOUtils.copyRange(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), 5, new ByteArrayOutputStream(), 0)); - assertEquals(0, IOUtils.copyRange(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), 5, new ByteArrayOutputStream(), 1)); - assertEquals(0, IOUtils.copyRange(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), 5, null, 1)); + () -> IOUtils.copyRange(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY), 5, new ByteArrayOutputStream(), 0)); + assertEquals(0, IOUtils.copyRange(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY), 5, new ByteArrayOutputStream(), 1)); + assertEquals(0, IOUtils.copyRange(new ByteArrayInputStream(ArrayUtils.EMPTY_BYTE_ARRAY), 5, null, 1)); assertEquals(1, IOUtils.copyRange(new ByteArrayInputStream(new byte[1]), 5, null, 1)); } diff --git a/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java b/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java index a63f5de61..475d6ffba 100644 --- a/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java +++ b/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java @@ -37,6 +37,7 @@ import java.util.Arrays; import java.util.List; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -187,7 +188,7 @@ private byte[][] grouped(final byte[] input, final int chunkSize) { } private SeekableByteChannel makeEmpty() { - return makeSingle(ByteUtils.EMPTY_BYTE_ARRAY); + return makeSingle(ArrayUtils.EMPTY_BYTE_ARRAY); } private SeekableByteChannel makeMulti(final byte[][] arr) { diff --git a/src/test/java/org/apache/commons/compress/utils/ZipSplitReadOnlySeekableByteChannelTest.java b/src/test/java/org/apache/commons/compress/utils/ZipSplitReadOnlySeekableByteChannelTest.java index 1a1a7b33a..3f3872125 100644 --- a/src/test/java/org/apache/commons/compress/utils/ZipSplitReadOnlySeekableByteChannelTest.java +++ b/src/test/java/org/apache/commons/compress/utils/ZipSplitReadOnlySeekableByteChannelTest.java @@ -37,6 +37,7 @@ import java.util.Random; import org.apache.commons.compress.archivers.zip.ZipSplitReadOnlySeekableByteChannel; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; class ZipSplitReadOnlySeekableByteChannelTest { @@ -146,7 +147,7 @@ void testForOrderedSeekableByteChannelsReturnCorrectClass() throws IOException { @Test void testForOrderedSeekableByteChannelsReturnsIdentityForSingleElement() throws IOException { - try (SeekableByteChannel emptyChannel = new SeekableInMemoryByteChannel(ByteUtils.EMPTY_BYTE_ARRAY); + try (SeekableByteChannel emptyChannel = new SeekableInMemoryByteChannel(ArrayUtils.EMPTY_BYTE_ARRAY); SeekableByteChannel channel = ZipSplitReadOnlySeekableByteChannel.forOrderedSeekableByteChannels(emptyChannel)) { assertSame(emptyChannel, channel); }
