commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1500757 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
Date Mon, 08 Jul 2013 14:25:37 GMT
Author: bodewig
Date: Mon Jul  8 14:25:37 2013
New Revision: 1500757

URL: http://svn.apache.org/r1500757
Log:
COMPRESS-232 improve readability of TarArchiveInputStream

Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.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=1500757&r1=1500756&r2=1500757&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Mon Jul  8 14:25:37 2013
@@ -76,6 +76,10 @@ The <action> type attribute can be add,u
         The class now also provides two new methods to obtain all
         entries of a given name rather than just the first one.
       </action>
+      <action type="update" date="2013-07-08" issue="COMPRESS-232"
+              due-to="BELUGA BEHR">
+        Readabilty patch to TarArchiveInputStream.
+      </action>
     </release>
     <release version="1.5" date="2013-03-14"
              description="Release 1.5">

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=1500757&r1=1500756&r2=1500757&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
Mon Jul  8 14:25:37 2013
@@ -233,7 +233,8 @@ public class TarArchiveInputStream exten
 
         byte[] headerBuf = getRecord();
 
-        if (hasHitEOF) {
+        if (headerBuf == null) {
+            /* hit EOF */
             currEntry = null;
             return null;
         }
@@ -324,28 +325,27 @@ public class TarArchiveInputStream exten
      * over any remaining data in the current entry, if there
      * is one, and place the input stream at the header of the
      * next entry.
-     * If there are no more entries in the archive, null will
-     * be returned to indicate that the end of the archive has
-     * been reached.
+     *
+     * <p>If there are no more entries in the archive, null will be
+     * returned to indicate that the end of the archive has been
+     * reached.  At the same time the {@code hasHitEOF} marker will be
+     * set to true.</p>
      *
      * @return The next header in the archive, or null.
      * @throws IOException on error
      */
     private byte[] getRecord() throws IOException {
-        if (hasHitEOF) {
-            return null;
-        }
-
-        byte[] headerBuf = buffer.readRecord();
-
-        if (buffer.isEOFRecord(headerBuf)) {
-            hasHitEOF = true;
-            if (headerBuf != null) {
+        byte[] headerBuf = null;
+        if (!hasHitEOF) {
+            headerBuf = buffer.readRecord();
+            hasHitEOF = buffer.isEOFRecord(headerBuf);
+            if (hasHitEOF && headerBuf != null) {
                 buffer.tryToConsumeSecondEOFRecord();
+                headerBuf = null;
             }
         }
 
-        return hasHitEOF ? null : headerBuf;
+        return headerBuf;
     }
 
     private void paxHeaders() throws IOException{
@@ -456,7 +456,7 @@ public class TarArchiveInputStream exten
             TarArchiveSparseEntry entry;
             do {
                 byte[] headerBuf = getRecord();
-                if (hasHitEOF) {
+                if (headerBuf == null) {
                     currEntry = null;
                     break;
                 }



Mime
View raw message