diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java index cc85ba1c33b..d8b74e639f1 100644 --- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java @@ -318,7 +318,7 @@ public ArArchiveEntry getNextEntry() throws IOException { do { // If there is a current entry, skip any unread data and padding if (currentEntry != null) { - IOUtils.skip(this, Long.MAX_VALUE); // Skip to end of current entry + IOUtils.consume(this); // Skip to end of current entry skipRecordPadding(); // Skip padding to align to the next record } diff --git a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java index a26b4a88234..60d8d39d9e3 100644 --- a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java @@ -263,7 +263,7 @@ public ArjArchiveEntry getNextEntry() throws IOException { if (currentInputStream != null) { // return value ignored as IOUtils.skip ensures the stream is drained completely final InputStream input = currentInputStream; - IOUtils.skip(input, Long.MAX_VALUE); + IOUtils.consume(input); currentInputStream.close(); currentLocalFileHeader = null; currentInputStream = null; diff --git a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java index 317755eba77..1d580dc6b70 100644 --- a/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java @@ -308,19 +308,6 @@ public void close() throws IOException { } } - /** - * Closes the current CPIO entry and positions the stream for reading the next entry. - * - * @throws IOException if an I/O error has occurred or if a CPIO file error has occurred - */ - private void closeEntry() throws IOException { - // the skip implementation of this class will not skip more - // than Integer.MAX_VALUE bytes - while (skip((long) Integer.MAX_VALUE) == Integer.MAX_VALUE) { // NOPMD NOSONAR - // do nothing - } - } - /** * Reads the next CPIO file entry and positions stream at the beginning of the entry data. * @@ -332,7 +319,7 @@ private void closeEntry() throws IOException { public CpioArchiveEntry getNextCPIOEntry() throws IOException { checkOpen(); if (entry != null) { - closeEntry(); + IOUtils.consume(this); } readFully(buffer2, 0, buffer2.length); if (CpioUtil.byteArray2long(buffer2, false) == MAGIC_OLD_BINARY) { 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 05ad45c0af4..11b3cf2d0d3 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 @@ -1104,7 +1104,7 @@ private InputStream getCurrentStream() throws IOException { // streams to get access to an entry. We defer this until really needed // so that entire blocks can be skipped without wasting time for decompression. try (InputStream stream = deferredBlockStreams.remove(0)) { - IOUtils.skip(stream, Long.MAX_VALUE); + IOUtils.consume(stream); } compressedBytesReadFromCurrentEntry = 0; } diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java index fa93dea545d..dee3f08f03d 100644 --- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java @@ -494,7 +494,7 @@ public TarArchiveEntry getNextEntry() throws IOException { do { // If there is a current entry, skip any unread data and padding if (currentInputStream != null) { - IOUtils.skip(currentInputStream, Long.MAX_VALUE); // Skip to end of current entry + IOUtils.consume(currentInputStream); // Skip to end of current entry skipRecordPadding(); // Skip padding to align to the next record } // Read the next header record