You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/02/23 02:03:01 UTC

svn commit: r1292606 - in /commons/proper/compress/trunk/src: changes/ main/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/compress/archivers/ test/resources/

Author: sebb
Date: Thu Feb 23 01:03:01 2012
New Revision: 1292606

URL: http://svn.apache.org/viewvc?rev=1292606&view=rev
Log:
COMPRESS-178 TarArchiveInputStream throws IllegalArgumentException instead of IOException

Added:
    commons/proper/compress/trunk/src/test/resources/COMPRESS-178.tar   (with props)
Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1292606&r1=1292605&r2=1292606&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Thu Feb 23 01:03:01 2012
@@ -46,6 +46,9 @@ The <action> type attribute can be add,u
   <body>
     <release version="1.4" date="unreleased"
              description="Release 1.4">
+      <action issue="COMPRESS-178" type="fix" date="2012-02-23">
+        TarArchiveInputStream throws IllegalArgumentException instead of IOException
+      </action> 
       <action issue="COMPRESS-179" type="fix" date="2012-02-23">
         TarUtils.formatLongOctalOrBinaryBytes() assumes the field will be 12 bytes long
       </action> 

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1292606&r1=1292605&r2=1292606&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Thu Feb 23 01:03:01 2012
@@ -195,7 +195,13 @@ public class TarArchiveInputStream exten
             return null;
         }
 
-        currEntry = new TarArchiveEntry(headerBuf);
+        try {
+            currEntry = new TarArchiveEntry(headerBuf);
+        } catch (IllegalArgumentException e) {
+            IOException ioe = new IOException("Error detected parsing the header");
+            ioe.initCause(e);
+            throw ioe;
+        }
         entryOffset = 0;
         entrySize = currEntry.getSize();
 

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java?rev=1292606&r1=1292605&r2=1292606&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java Thu Feb 23 01:03:01 2012
@@ -300,4 +300,19 @@ public final class TarTestCase extends A
             rmdir(tmp[0]);
         }
     }
+
+    public void testCOMPRESS178() throws Exception {
+        final File input = getFile("COMPRESS-178.tar");
+        final InputStream is = new FileInputStream(input);
+        final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream("tar", is);
+        try {
+            in.getNextEntry();
+            fail("Expected IOException");
+        } catch (IOException e) {
+            Throwable t = e.getCause();
+            assertTrue("Expected cause = IllegalArgumentException", t instanceof IllegalArgumentException);
+        }
+        in.close();
+    }
+
 }

Added: commons/proper/compress/trunk/src/test/resources/COMPRESS-178.tar
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/COMPRESS-178.tar?rev=1292606&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/proper/compress/trunk/src/test/resources/COMPRESS-178.tar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream