commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1189085 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
Date Wed, 26 Oct 2011 09:05:48 GMT
Author: bodewig
Date: Wed Oct 26 09:05:48 2011
New Revision: 1189085

URL: http://svn.apache.org/viewvc?rev=1189085&view=rev
Log:
Use a constant for the length of the expected signature

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java?rev=1189085&r1=1189084&r2=1189085&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
Wed Oct 26 09:05:48 2011
@@ -229,6 +229,7 @@ public class Pack200CompressorInputStrea
     private static final byte[] CAFE_DOOD = new byte[] {
         (byte) 0xCA, (byte) 0xFE, (byte) 0xD0, (byte) 0x0D
     };
+    private static final int SIG_LENGTH = CAFE_DOOD.length;
 
     /**
      * Checks if the signature matches what is expected for a pack200
@@ -242,11 +243,11 @@ public class Pack200CompressorInputStrea
      * false otherwise
      */
     public static boolean matches(byte[] signature, int length) {
-        if (length < 4) {
+        if (length < SIG_LENGTH) {
             return false;
         }
 
-        for (int i = 0; i < 4; i++) {
+        for (int i = 0; i < SIG_LENGTH; i++) {
             if (signature[i] != CAFE_DOOD[i]) {
                 return false;
             }



Mime
View raw message