You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2020/01/25 14:02:55 UTC

[commons-compress] branch master updated: OK, so tar fails. Try to figure out why.

This is an automated email from the ASF dual-hosted git repository.

bodewig 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 57464b2  OK, so tar fails. Try to figure out why.
57464b2 is described below

commit 57464b2f19e0cb048d549fc6f7682ce324bcf9ad
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Sat Jan 25 15:02:33 2020 +0100

    OK, so tar fails. Try to figure out why.
---
 .../org/apache/commons/compress/archivers/tar/SparseFilesTest.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
index 028de5f..8aa8adf 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
@@ -233,10 +233,11 @@ public class SparseFilesTest extends AbstractTestCase {
     }
 
     private InputStream extractTarAndGetInputStream(File tarFile, String sparseFileName) throws IOException, InterruptedException {
-        Runtime runtime = Runtime.getRuntime();
-        Process process = runtime.exec("tar -xf " + tarFile.getPath() + " -C " + resultDir.getPath());
+        ProcessBuilder pb = new ProcessBuilder("tar", "-xf", tarFile.getPath(), "-C", resultDir.getPath());
+        pb.redirectErrorStream(true);
+        Process process = pb.start();
         // wait until the extract finishes
-        assertEquals(0, process.waitFor());
+        assertEquals(new String(IOUtils.toByteArray(process.getInputStream())), 0, process.waitFor());
 
         for (File file : resultDir.listFiles()) {
             if (file.getName().equals(sparseFileName)) {