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 9ab1c9dd2de7983110a291eaec53fdfde70b5b8f
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Dec 23 08:20:45 2024 -0500

    Don't use deprecated code in TarArchiveInputStream
---
 src/changes/changes.xml                              |  3 ++-
 .../archivers/tar/TarArchiveInputStream.java         | 20 +++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 109d66223..03f4dd3c2 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -56,7 +56,8 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Glavo">Update outdated links 
in ZipMethod Javadoc #619.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate 
ZipUtil.signedByteToUnsignedInt(byte) in favor of 
Byte.toUnsignedInt(byte).</action> 
       <action type="fix" dev="ggregory" due-to="Gary 
Gregory">ZipArchiveOutputStream.close() does not close its underlying output 
stream.</action> 
-      <action type="fix" dev="ggregory" due-to="Gary 
Gregory">ZipArchiveOutputStream.close() does not close its underlying output 
stream.</action> 
+      <action type="fix" dev="ggregory" due-to="Gary 
Gregory">ZipArchiveOutputStream.close() does not close its underlying output 
stream.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Don't use 
deprecated code in TarArchiveInputStream.</action>
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
GzipParameters.getModificationInstant().</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
GzipParameters.setModificationInstant(Instant).</action>
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 3821c4c3e..b4b313726 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
@@ -37,8 +37,8 @@ import 
org.apache.commons.compress.archivers.ArchiveInputStream;
 import org.apache.commons.compress.archivers.zip.ZipEncoding;
 import org.apache.commons.compress.archivers.zip.ZipEncodingHelper;
 import org.apache.commons.compress.utils.ArchiveUtils;
-import org.apache.commons.compress.utils.BoundedInputStream;
 import org.apache.commons.compress.utils.IOUtils;
+import org.apache.commons.io.input.BoundedInputStream;
 
 /**
  * The TarInputStream reads a Unix tar archive as an InputStream. methods are 
provided to position at each successive entry in the archive, and the read each
@@ -262,20 +262,26 @@ public class TarArchiveInputStream extends 
ArchiveInputStream<TarArchiveEntry> {
                 // sparse header says to move backwards inside the extracted 
entry
                 throw new IOException("Corrupted struct sparse detected");
             }
-
             // only store the zero block if it is not empty
             if (zeroBlockSize > 0) {
-                sparseInputStreams.add(new BoundedInputStream(zeroInputStream, 
sparseHeader.getOffset() - offset));
+                // @formatter:off
+                sparseInputStreams.add(BoundedInputStream.builder()
+                        .setInputStream(zeroInputStream)
+                        .setMaxCount(sparseHeader.getOffset() - offset)
+                        .get());
+                // @formatter:on
             }
-
             // only store the input streams with non-zero size
             if (sparseHeader.getNumbytes() > 0) {
-                sparseInputStreams.add(new BoundedInputStream(in, 
sparseHeader.getNumbytes()));
+                // @formatter:off
+                sparseInputStreams.add(BoundedInputStream.builder()
+                        .setInputStream(in)
+                        .setMaxCount(sparseHeader.getNumbytes())
+                        .get());
+                // @formatter:on
             }
-
             offset = sparseHeader.getOffset() + sparseHeader.getNumbytes();
         }
-
         if (!sparseInputStreams.isEmpty()) {
             currentSparseInputStreamIndex = 0;
         }

Reply via email to