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


The following commit(s) were added to refs/heads/master by this push:
     new 71f1c1415 Migrate to non-deprecated code
71f1c1415 is described below

commit 71f1c1415c74d1ea78f1524a01836ee73ce87293
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sat Jan 25 09:06:49 2025 -0500

    Migrate to non-deprecated code
    
    Reuse IOUtils.copy()
---
 .../org/apache/commons/compress/harmony/unpack200/Archive.java | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java 
b/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java
index c07aea52b..f3bbd364f 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/Archive.java
@@ -100,7 +100,7 @@ public Archive(final InputStream inputStream, final 
JarOutputStream outputStream
     public Archive(final String inputFileName, final String outputFileName) 
throws FileNotFoundException, IOException {
         this.inputPath = Paths.get(inputFileName);
         this.inputSize = Files.size(this.inputPath);
-        this.inputStream = new 
BoundedInputStream(Files.newInputStream(inputPath), inputSize);
+        this.inputStream = 
BoundedInputStream.builder().setPath(inputPath).setMaxCount(inputSize).get();
         this.outputStream = new JarOutputStream(new BufferedOutputStream(new 
FileOutputStream(outputFileName)));
         this.outputFileName = outputFileName;
         this.closeStreams = true;
@@ -220,12 +220,7 @@ public void unpack() throws Pack200Exception, IOException {
                 JarEntry jarEntry;
                 while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
                     outputStream.putNextEntry(jarEntry);
-                    final byte[] bytes = new byte[16_384];
-                    int bytesRead = jarInputStream.read(bytes);
-                    while (bytesRead != -1) {
-                        outputStream.write(bytes, 0, bytesRead);
-                        bytesRead = jarInputStream.read(bytes);
-                    }
+                    IOUtils.copy(jarInputStream, outputStream, 16_384);
                     outputStream.closeEntry();
                 }
             } else {
@@ -236,7 +231,6 @@ public void unpack() throws Pack200Exception, IOException {
                     segment.setLogLevel(logLevel);
                     segment.setLogStream(logFile != null ? logFile : 
System.out);
                     segment.setPreRead(false);
-
                     if (i == 1) {
                         segment.log(Segment.LOG_LEVEL_VERBOSE, "Unpacking from 
" + inputPath + " to " + outputFileName);
                     }

Reply via email to