commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject commons-compress git commit: Refactor magic string.
Date Sat, 09 Apr 2016 15:59:54 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/master ac6b5f3a7 -> 8954b8be6


Refactor magic string.

Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/8954b8be
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/8954b8be
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/8954b8be

Branch: refs/heads/master
Commit: 8954b8be675333bafc75f9c3ccbf1839bbff8c62
Parents: ac6b5f3
Author: ggregory <ggregory@apache.org>
Authored: Sat Apr 9 08:59:51 2016 -0700
Committer: ggregory <ggregory@apache.org>
Committed: Sat Apr 9 08:59:51 2016 -0700

----------------------------------------------------------------------
 .../compress/archivers/arj/ArjArchiveEntry.java |  3 +-
 .../archivers/arj/ArjArchiveInputStream.java    | 10 +--
 .../BoundedRandomAccessFileInputStream.java     |  3 +-
 .../archivers/sevenz/SevenZArchiveEntry.java    | 15 ++--
 .../compress/archivers/sevenz/SevenZFile.java   | 85 +++++++++-----------
 .../compress/archivers/zip/CircularBuffer.java  |  3 +-
 .../archivers/zip/FallbackZipEncoding.java      |  6 +-
 .../compress/archivers/zip/X000A_NTFS.java      |  3 +-
 .../archivers/zip/X5455_ExtendedTimestamp.java  |  3 +-
 .../archivers/zip/ZipArchiveInputStream.java    |  5 +-
 .../commons/compress/archivers/zip/ZipFile.java |  3 +-
 .../commons/compress/archivers/zip/ZipUtil.java | 15 ++--
 .../commons/compress/changes/ChangeSet.java     |  5 +-
 .../bzip2/BZip2CompressorInputStream.java       | 83 +++++++++----------
 .../compress/compressors/bzip2/BlockSort.java   |  9 +--
 .../compress/utils/BoundedInputStream.java      |  3 +-
 .../utils/ChecksumVerifyingInputStream.java     |  3 +-
 17 files changed, 107 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
index 3ce49b5..a033a14 100644
--- a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
@@ -50,9 +50,8 @@ public class ArjArchiveEntry implements ArchiveEntry {
         if ((localFileHeader.arjFlags & LocalFileHeader.Flags.PATHSYM) != 0) {
             return localFileHeader.name.replaceAll("/",
                     Matcher.quoteReplacement(File.separator));
-        } else {
-            return localFileHeader.name;
         }
+        return localFileHeader.name;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
index 96d1e8c..f049299 100644
--- a/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
@@ -114,10 +114,9 @@ public class ArjArchiveInputStream extends ArchiveInputStream {
         }
         if (charsetName != null) {
             return new String(buffer.toByteArray(), charsetName);
-        } else {
-            // intentionally using the default encoding as that's the contract for a null
charsetName
-            return new String(buffer.toByteArray());
         }
+        // intentionally using the default encoding as that's the contract for a null charsetName
+        return new String(buffer.toByteArray());
     }
     
     private void readFully(final DataInputStream dataIn, byte[] b)
@@ -330,10 +329,9 @@ public class ArjArchiveInputStream extends ArchiveInputStream {
                         currentLocalFileHeader.originalSize, currentLocalFileHeader.originalCrc32);
             }
             return new ArjArchiveEntry(currentLocalFileHeader);
-        } else {
-            currentInputStream = null;
-            return null;
         }
+        currentInputStream = null;
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/sevenz/BoundedRandomAccessFileInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/BoundedRandomAccessFileInputStream.java
b/src/main/java/org/apache/commons/compress/archivers/sevenz/BoundedRandomAccessFileInputStream.java
index 482bd7a..63cf4bb 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/BoundedRandomAccessFileInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/BoundedRandomAccessFileInputStream.java
@@ -36,9 +36,8 @@ class BoundedRandomAccessFileInputStream extends InputStream {
         if (bytesRemaining > 0) {
             --bytesRemaining;
             return file.read();
-        } else {
-            return -1;
         }
+        return -1;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
index c3f2bb9..b15bb7d 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
@@ -147,10 +147,9 @@ public class SevenZArchiveEntry implements ArchiveEntry {
     public Date getCreationDate() {
         if (hasCreationDate) {
             return ntfsTimeToJavaTime(creationDate);
-        } else {
-            throw new UnsupportedOperationException(
-                    "The entry doesn't have this timestamp");
         }
+        throw new UnsupportedOperationException(
+                "The entry doesn't have this timestamp");
     }
     
     /**
@@ -199,10 +198,9 @@ public class SevenZArchiveEntry implements ArchiveEntry {
     public Date getLastModifiedDate() {
         if (hasLastModifiedDate) {
             return ntfsTimeToJavaTime(lastModifiedDate);
-        } else {
-            throw new UnsupportedOperationException(
-                    "The entry doesn't have this timestamp");
         }
+        throw new UnsupportedOperationException(
+                "The entry doesn't have this timestamp");
     }
     
     /**
@@ -250,10 +248,9 @@ public class SevenZArchiveEntry implements ArchiveEntry {
     public Date getAccessDate() {
         if (hasAccessDate) {
             return ntfsTimeToJavaTime(accessDate);
-        } else {
-            throw new UnsupportedOperationException(
-                    "The entry doesn't have this timestamp");
         }
+        throw new UnsupportedOperationException(
+                "The entry doesn't have this timestamp");
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index 0e47f8c..2512eec 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -381,10 +381,9 @@ public class SevenZFile implements Closeable {
         final int external = header.readUnsignedByte();
         if (external != 0) {
             throw new IOException("External unsupported");
-        } else {
-            for (int i = 0; i < (int)numFolders; i++) {
-                folders[i] = readFolder(header);
-            }
+        }
+        for (int i = 0; i < (int)numFolders; i++) {
+            folders[i] = readFolder(header);
         }
         
         nid = header.readUnsignedByte();
@@ -647,24 +646,23 @@ public class SevenZFile implements Closeable {
                     final int external = header.readUnsignedByte();
                     if (external != 0) {
                         throw new IOException("Not implemented");
-                    } else {
-                        if (((size - 1) & 1) != 0) {
-                            throw new IOException("File names length invalid");
-                        }
-                        final byte[] names = new byte[(int)(size - 1)];
-                        header.readFully(names);
-                        int nextFile = 0;
-                        int nextName = 0;
-                        for (int i = 0; i < names.length; i += 2) {
-                            if (names[i] == 0 && names[i+1] == 0) {
-                                files[nextFile++].setName(new String(names, nextName, i-nextName,
CharsetNames.UTF_16LE));
-                                nextName = i + 2;
-                            }
-                        }
-                        if (nextName != names.length || nextFile != files.length) {
-                            throw new IOException("Error parsing file names");
+                    }
+                    if (((size - 1) & 1) != 0) {
+                        throw new IOException("File names length invalid");
+                    }
+                    final byte[] names = new byte[(int)(size - 1)];
+                    header.readFully(names);
+                    int nextFile = 0;
+                    int nextName = 0;
+                    for (int i = 0; i < names.length; i += 2) {
+                        if (names[i] == 0 && names[i+1] == 0) {
+                            files[nextFile++].setName(new String(names, nextName, i-nextName,
CharsetNames.UTF_16LE));
+                            nextName = i + 2;
                         }
                     }
+                    if (nextName != names.length || nextFile != files.length) {
+                        throw new IOException("Error parsing file names");
+                    }
                     break;
                 }
                 case NID.kCTime: {
@@ -672,12 +670,11 @@ public class SevenZFile implements Closeable {
                     final int external = header.readUnsignedByte();
                     if (external != 0) {
                         throw new IOException("Unimplemented");
-                    } else {
-                        for (int i = 0; i < files.length; i++) {
-                            files[i].setHasCreationDate(timesDefined.get(i));
-                            if (files[i].getHasCreationDate()) {
-                                files[i].setCreationDate(Long.reverseBytes(header.readLong()));
-                            }
+                    }
+                    for (int i = 0; i < files.length; i++) {
+                        files[i].setHasCreationDate(timesDefined.get(i));
+                        if (files[i].getHasCreationDate()) {
+                            files[i].setCreationDate(Long.reverseBytes(header.readLong()));
                         }
                     }
                     break;
@@ -687,12 +684,11 @@ public class SevenZFile implements Closeable {
                     final int external = header.readUnsignedByte();
                     if (external != 0) {
                         throw new IOException("Unimplemented");
-                    } else {
-                        for (int i = 0; i < files.length; i++) {
-                            files[i].setHasAccessDate(timesDefined.get(i));
-                            if (files[i].getHasAccessDate()) {
-                                files[i].setAccessDate(Long.reverseBytes(header.readLong()));
-                            }
+                    }
+                    for (int i = 0; i < files.length; i++) {
+                        files[i].setHasAccessDate(timesDefined.get(i));
+                        if (files[i].getHasAccessDate()) {
+                            files[i].setAccessDate(Long.reverseBytes(header.readLong()));
                         }
                     }
                     break;
@@ -702,12 +698,11 @@ public class SevenZFile implements Closeable {
                     final int external = header.readUnsignedByte();
                     if (external != 0) {
                         throw new IOException("Unimplemented");
-                    } else {
-                        for (int i = 0; i < files.length; i++) {
-                            files[i].setHasLastModifiedDate(timesDefined.get(i));
-                            if (files[i].getHasLastModifiedDate()) {
-                                files[i].setLastModifiedDate(Long.reverseBytes(header.readLong()));
-                            }
+                    }
+                    for (int i = 0; i < files.length; i++) {
+                        files[i].setHasLastModifiedDate(timesDefined.get(i));
+                        if (files[i].getHasLastModifiedDate()) {
+                            files[i].setLastModifiedDate(Long.reverseBytes(header.readLong()));
                         }
                     }
                     break;
@@ -717,12 +712,11 @@ public class SevenZFile implements Closeable {
                     final int external = header.readUnsignedByte();
                     if (external != 0) {
                         throw new IOException("Unimplemented");
-                    } else {
-                        for (int i = 0; i < files.length; i++) {
-                            files[i].setHasWindowsAttributes(attributesDefined.get(i));
-                            if (files[i].getHasWindowsAttributes()) {
-                                files[i].setWindowsAttributes(Integer.reverseBytes(header.readInt()));
-                            }
+                    }
+                    for (int i = 0; i < files.length; i++) {
+                        files[i].setHasWindowsAttributes(attributesDefined.get(i));
+                        if (files[i].getHasWindowsAttributes()) {
+                            files[i].setWindowsAttributes(Integer.reverseBytes(header.readInt()));
                         }
                     }
                     break;
@@ -888,9 +882,8 @@ public class SevenZFile implements Closeable {
         if (folder.hasCrc) {
             return new CRC32VerifyingInputStream(inputStreamStack,
                     folder.getUnpackSize(), folder.crc);
-        } else {
-            return inputStreamStack;
         }
+        return inputStreamStack;
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/zip/CircularBuffer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/CircularBuffer.java b/src/main/java/org/apache/commons/compress/archivers/zip/CircularBuffer.java
index af64a85..10a35a8 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/CircularBuffer.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/CircularBuffer.java
@@ -67,9 +67,8 @@ class CircularBuffer {
             int value = buffer[readIndex];
             readIndex = (readIndex + 1) % size;
             return value & 0xFF;
-        } else {
-            return -1;
         }
+        return -1;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java
b/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java
index 4baae8a..14bab4a 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java
@@ -76,9 +76,8 @@ class FallbackZipEncoding implements ZipEncoding {
     public ByteBuffer encode(String name) throws IOException {
         if (this.charsetName == null) { // i.e. use default charset, see no-args constructor
             return ByteBuffer.wrap(name.getBytes());
-        } else {
-            return ByteBuffer.wrap(name.getBytes(this.charsetName));
         }
+        return ByteBuffer.wrap(name.getBytes(this.charsetName));
     }
 
     /**
@@ -88,8 +87,7 @@ class FallbackZipEncoding implements ZipEncoding {
     public String decode(byte[] data) throws IOException {
         if (this.charsetName == null) { // i.e. use default charset, see no-args constructor
             return new String(data);
-        } else {
-            return new String(data,this.charsetName);
         }
+        return new String(data,this.charsetName);
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java b/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
index 0b5e419..e2bde27 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X000A_NTFS.java
@@ -321,9 +321,8 @@ public class X000A_NTFS implements ZipExtraField {
             return (modifyTime == xf.modifyTime || (modifyTime != null && modifyTime.equals(xf.modifyTime)))
&&
                     (accessTime == xf.accessTime || (accessTime != null && accessTime.equals(xf.accessTime)))
&&
                     (createTime == xf.createTime || (createTime != null && createTime.equals(xf.createTime)));
-        } else {
-            return false;
         }
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
index b1ac3ee..8a7c7df 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestamp.java
@@ -562,9 +562,8 @@ public class X5455_ExtendedTimestamp implements ZipExtraField, Cloneable,
Serial
                     (modifyTime == xf.modifyTime || (modifyTime != null && modifyTime.equals(xf.modifyTime)))
&&
                     (accessTime == xf.accessTime || (accessTime != null && accessTime.equals(xf.accessTime)))
&&
                     (createTime == xf.createTime || (createTime != null && createTime.equals(xf.createTime)));
-        } else {
-            return false;
         }
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index f8df66b..be036e5 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -654,10 +654,9 @@ public class ZipArchiveInputStream extends ArchiveInputStream {
             long n = in.read(buf.array(), 0, (int) Math.min(buf.capacity(), remaining));
             if (n < 0) {
                 throw new EOFException("Truncated ZIP entry: " + current.entry.getName());
-            } else {
-                count(n);
-                remaining -= n;
             }
+            count(n);
+            remaining -= n;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
index f1bcbef..3b51b07 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
@@ -475,9 +475,8 @@ public class ZipFile implements Closeable {
                     in.close();
                 }
             }
-        } else {
-            return null;
         }
+        return null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
index 7c21e29..757967d 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
@@ -99,9 +99,8 @@ public abstract class ZipUtil {
     public static long adjustToLong(int i) {
         if (i < 0) {
             return 2 * ((long) Integer.MAX_VALUE) + 2 + i;
-        } else {
-            return i;
         }
+        return i;
     }
 
     /**
@@ -135,9 +134,8 @@ public abstract class ZipUtil {
     static long bigToLong(BigInteger big) {
         if (big.bitLength() <= 63) { // bitLength() doesn't count the sign bit.
             return big.longValue();
-        } else {
-            throw new NumberFormatException("The BigInteger cannot fit inside a 64 bit java
long: [" + big + "]");
         }
+        throw new NumberFormatException("The BigInteger cannot fit inside a 64 bit java long:
[" + big + "]");
     }
 
     /**
@@ -173,9 +171,8 @@ public abstract class ZipUtil {
     public static int signedByteToUnsignedInt(byte b) {
         if (b >= 0) {
             return b;
-        } else {
-            return 256 + b;
         }
+        return 256 + b;
     }
 
     /**
@@ -192,9 +189,8 @@ public abstract class ZipUtil {
         }
         if (i < 128) {
             return (byte) i;
-        } else {
-            return (byte) (i - 256);
         }
+        return (byte) (i - 256);
     }
 
     /**
@@ -354,9 +350,8 @@ public abstract class ZipUtil {
                 throw
                     new UnsupportedZipFeatureException(UnsupportedZipFeatureException
                                                        .Feature.METHOD, ze);
-            } else {
-                throw new UnsupportedZipFeatureException(m, ze);
             }
+            throw new UnsupportedZipFeatureException(m, ze);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/changes/ChangeSet.java b/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
index a9be42d..72df166 100644
--- a/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
+++ b/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
@@ -108,10 +108,9 @@ public final class ChangeSet {
                             it.remove();
                             changes.add(pChange);
                             return;
-                        } else {
-                            // do not add this change
-                            return;
                         }
+                        // do not add this change
+                        return;
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
index edf90cb..b4c7d9d 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
@@ -140,9 +140,8 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
             int r = read0();
             count(r < 0 ? -1 : 1);
             return r;
-        } else {
-            throw new IOException("stream closed");
         }
+        throw new IOException("stream closed");
     }
 
     /*
@@ -299,24 +298,23 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
             ) {
             this.currentState = EOF;
             throw new IOException("bad block header");
-        } else {
-            this.storedBlockCRC = bsGetInt();
-            this.blockRandomised = bsR(1) == 1;
-
-            /**
-             * Allocate data here instead in constructor, so we do not allocate
-             * it if the input file is empty.
-             */
-            if (this.data == null) {
-                this.data = new Data(this.blockSize100k);
-            }
-
-            // currBlockNo++;
-            getAndMoveToFrontDecode();
+        }
+        this.storedBlockCRC = bsGetInt();
+        this.blockRandomised = bsR(1) == 1;
 
-            this.crc.initialiseCRC();
-            this.currentState = START_BLOCK_STATE;
+        /**
+         * Allocate data here instead in constructor, so we do not allocate
+         * it if the input file is empty.
+         */
+        if (this.data == null) {
+            this.data = new Data(this.blockSize100k);
         }
+
+        // currBlockNo++;
+        getAndMoveToFrontDecode();
+
+        this.crc.initialiseCRC();
+        this.currentState = START_BLOCK_STATE;
     }
 
     private void endBlock() throws IOException {
@@ -630,9 +628,8 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
                             bsBuffShadow = (bsBuffShadow << 8) | thech;
                             bsLiveShadow += 8;
                             continue;
-                        } else {
-                            throw new IOException("unexpected end of stream");
                         }
+                        throw new IOException("unexpected end of stream");
                     }
                     int zvec = (bsBuffShadow >> (bsLiveShadow - zn))
                         & ((1 << zn) - 1);
@@ -646,10 +643,9 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
                                 bsBuffShadow = (bsBuffShadow << 8) | thech;
                                 bsLiveShadow += 8;
                                 continue;
-                            } else {
-                                throw new IOException(
-                                                      "unexpected end of stream");
                             }
+                            throw new IOException(
+                                                  "unexpected end of stream");
                         }
                         bsLiveShadow--;
                         zvec = (zvec << 1)
@@ -713,9 +709,8 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
                         bsBuffShadow = (bsBuffShadow << 8) | thech;
                         bsLiveShadow += 8;
                         continue;
-                    } else {
-                        throw new IOException("unexpected end of stream");
                     }
+                    throw new IOException("unexpected end of stream");
                 }
                 int zvec = (bsBuffShadow >> (bsLiveShadow - zn))
                     & ((1 << zn) - 1);
@@ -729,9 +724,8 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
                             bsBuffShadow = (bsBuffShadow << 8) | thech;
                             bsLiveShadow += 8;
                             continue;
-                        } else {
-                            throw new IOException("unexpected end of stream");
                         }
+                        throw new IOException("unexpected end of stream");
                     }
                     bsLiveShadow--;
                     zvec = (zvec << 1) | ((bsBuffShadow >> bsLiveShadow) &
1);
@@ -764,9 +758,8 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
                     bsBuffShadow = (bsBuffShadow << 8) | thech;
                     bsLiveShadow += 8;
                     continue;
-                } else {
-                    throw new IOException("unexpected end of stream");
                 }
+                throw new IOException("unexpected end of stream");
             }
             bsLiveShadow--;
             zvec = (zvec << 1) | ((bsBuffShadow >> bsLiveShadow) & 1);
@@ -833,11 +826,10 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
             this.currentState = RAND_PART_B_STATE;
             this.crc.updateCRC(su_ch2Shadow);
             return su_ch2Shadow;
-        } else {
-            endBlock();
-            initBlock();
-            return setupBlock();
         }
+        endBlock();
+        initBlock();
+        return setupBlock();
     }
 
     private int setupNoRandPartA() throws IOException {
@@ -850,12 +842,11 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
             this.currentState = NO_RAND_PART_B_STATE;
             this.crc.updateCRC(su_ch2Shadow);
             return su_ch2Shadow;
-        } else {
-            this.currentState = NO_RAND_PART_A_STATE;
-            endBlock();
-            initBlock();
-            return setupBlock();
         }
+        this.currentState = NO_RAND_PART_A_STATE;
+        endBlock();
+        initBlock();
+        return setupBlock();
     }
 
     private int setupRandPartB() throws IOException {
@@ -891,12 +882,11 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
             this.crc.updateCRC(this.su_ch2);
             this.su_j2++;
             return this.su_ch2;
-        } else {
-            this.currentState = RAND_PART_A_STATE;
-            this.su_i2++;
-            this.su_count = 0;
-            return setupRandPartA();
         }
+        this.currentState = RAND_PART_A_STATE;
+        this.su_i2++;
+        this.su_count = 0;
+        return setupRandPartA();
     }
 
     private int setupNoRandPartB() throws IOException {
@@ -920,11 +910,10 @@ public class BZip2CompressorInputStream extends CompressorInputStream
implements
             this.su_j2++;
             this.currentState = NO_RAND_PART_C_STATE;
             return su_ch2Shadow;
-        } else {
-            this.su_i2++;
-            this.su_count = 0;
-            return setupNoRandPartA();
         }
+        this.su_i2++;
+        this.su_count = 0;
+        return setupNoRandPartA();
     }
 
     private static final class Data {

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java b/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
index c7c26b2..bafa9e5 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/BlockSort.java
@@ -725,13 +725,10 @@ class BlockSort {
                                                 }
                                                 break HAMMER;
                                             } // while x > 0
-                                            else {
-                                                if ((block[i1] & 0xff) > (block[i2]
& 0xff)) {
-                                                    continue HAMMER;
-                                                } else {
-                                                    break HAMMER;
-                                                }
+                                            if ((block[i1] & 0xff) > (block[i2] &
0xff)) {
+                                                continue HAMMER;
                                             }
+                                            break HAMMER;
                                         } else if ((block[i1 + 5] & 0xff) > (block[i2
+ 5] & 0xff)) {
                                             continue HAMMER;
                                         } else {

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/utils/BoundedInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/utils/BoundedInputStream.java b/src/main/java/org/apache/commons/compress/utils/BoundedInputStream.java
index 791f08c..5b35667 100644
--- a/src/main/java/org/apache/commons/compress/utils/BoundedInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/BoundedInputStream.java
@@ -45,9 +45,8 @@ public class BoundedInputStream extends InputStream {
         if (bytesRemaining > 0) {
             --bytesRemaining;
             return in.read();
-        } else {
-            return -1;
         }
+        return -1;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/8954b8be/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
index 69bf03c..856e448 100644
--- a/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStream.java
@@ -98,9 +98,8 @@ public class ChecksumVerifyingInputStream extends InputStream {
         // Can't really skip, we have to hash everything to verify the checksum
         if (read() >= 0) {
             return 1;
-        } else {
-            return 0;
         }
+        return 0;
     }
 
     @Override


Mime
View raw message