Author: bodewig
Date: Sun Aug  7 07:56:19 2011
New Revision: 1154667

URL: http://svn.apache.org/viewvc?rev=1154667&view=rev
Log:
address most issues detected by findbugs

Added:
    commons/proper/compress/trunk/findbugs-exclude-filter.xml   (with props)
Modified:
    commons/proper/compress/trunk/pom.xml
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java

Added: commons/proper/compress/trunk/findbugs-exclude-filter.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/findbugs-exclude-filter.xml?rev=1154667&view=auto
==============================================================================
--- commons/proper/compress/trunk/findbugs-exclude-filter.xml (added)
+++ commons/proper/compress/trunk/findbugs-exclude-filter.xml Sun Aug  7 
07:56:19 2011
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<!--
+  This file contains some false positive bugs detected by findbugs. Their
+  false positive nature has been analyzed individually and they have been
+  put here to instruct findbugs it must ignore them.
+-->
+<FindBugsFilter>
+
+  <!-- Reason: References to System.out/err == -->
+  <Match>
+    <Class name="org.apache.commons.compress.archivers.Lister" />
+    <Or>
+      <Method name="main" />
+      <Method name="usage" />
+    </Or>
+    <Bug pattern="NP_ALWAYS_NULL" />
+  </Match>
+  <Match>
+    <Class name="org.apache.commons.compress.archivers.zip.ZipFile" />
+    <Method name="finalize" />
+    <Bug pattern="NP_ALWAYS_NULL" />
+  </Match>
+
+  <!-- Reason: fallthrough is intended -->
+  <Match>
+    <Class name="org.apache.commons.compress.archivers.zip.ExtraFieldUtils" />
+    <Method name="parse" />
+    <Bug pattern="SF_SWITCH_FALLTHROUGH" />
+  </Match>
+
+  <!-- Reason: fields unused as documented -->
+  <Match>
+    <Class name="org.apache.commons.compress.archivers.jar.JarArchiveEntry" />
+    <Or>
+      <Field name="certificates"/>
+      <Field name="manifestAttributes"/>
+    </Or>
+    <Bug pattern="UWF_NULL_FIELD" />
+  </Match>
+
+  <!-- Reason: exception in close swallowed in order to re-throw original -->
+  <Match>
+    <Class name="org.apache.commons.compress.archivers.zip.ZipFile" />
+    <Method name="&lt;init&gt;" />
+    <Bug pattern="DE_MIGHT_IGNORE" />
+  </Match>
+
+</FindBugsFilter>

Propchange: commons/proper/compress/trunk/findbugs-exclude-filter.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1154667&r1=1154666&r2=1154667&view=diff
==============================================================================
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Sun Aug  7 07:56:19 2011
@@ -244,7 +244,7 @@
         <configuration>
           <threshold>Normal</threshold>
           <effort>Default</effort>
-          
<!--excludeFilterFile>${basedir}/findbugs-exclude-filter.xml</excludeFilterFile-->
+          
<excludeFilterFile>${basedir}/findbugs-exclude-filter.xml</excludeFilterFile>
        </configuration>
       </plugin>
     </plugins>

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java?rev=1154667&r1=1154666&r2=1154667&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java
 Sun Aug  7 07:56:19 2011
@@ -66,4 +66,13 @@ public class JarArchiveEntry extends Zip
             return null;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        return super.equals(o);
+    }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode();
+    }
 }

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java?rev=1154667&r1=1154666&r2=1154667&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java
 Sun Aug  7 07:56:19 2011
@@ -103,14 +103,25 @@ public abstract class AbstractUnicodeExt
      * @return The utf-8 encoded name.
      */
     public byte[] getUnicodeName() {
-        return unicodeName;
+        byte[] b = null;
+        if (unicodeName != null) {
+            b = new byte[unicodeName.length];
+            System.arraycopy(unicodeName, 0, b, 0, b.length);
+        }
+        return b;
     }
 
     /**
      * @param unicodeName The utf-8 encoded name to set.
      */
     public void setUnicodeName(byte[] unicodeName) {
-        this.unicodeName = unicodeName;
+        if (unicodeName != null) {
+            this.unicodeName = new byte[unicodeName.length];
+            System.arraycopy(unicodeName, 0, this.unicodeName, 0,
+                             unicodeName.length);
+        } else {
+            this.unicodeName = null;
+        }
         data = null;
     }
 
@@ -119,7 +130,12 @@ public abstract class AbstractUnicodeExt
         if (data == null) {
             this.assembleData();
         }
-        return data;
+        byte[] b = null;
+        if (data != null) {
+            b = new byte[data.length];
+            System.arraycopy(data, 0, b, 0, b.length);
+        }
+        return b;
     }
 
     /** {@inheritDoc} */

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java?rev=1154667&r1=1154666&r2=1154667&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java
 Sun Aug  7 07:56:19 2011
@@ -63,10 +63,25 @@ class Simple8BitZipEncoding implements Z
             return this.unicode - a.unicode;
         }
 
+        @Override
         public String toString() {
             return "0x" + Integer.toHexString(0xffff & unicode)
                 + "->0x" + Integer.toHexString(0xff & code);
         }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof Simple8BitChar) {
+                Simple8BitChar other = (Simple8BitChar) o;
+                return unicode == other.unicode && code == other.code;
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            return unicode;
+        }
     }
 
     /**

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=1154667&r1=1154666&r2=1154667&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
 Sun Aug  7 07:56:19 2011
@@ -297,7 +297,9 @@ public class ZipArchiveOutputStream exte
     public void setEncoding(final String encoding) {
         this.encoding = encoding;
         this.zipEncoding = ZipEncodingHelper.getZipEncoding(encoding);
-        useUTF8Flag &= ZipEncodingHelper.isUTF8(encoding);
+        if (useUTF8Flag && !ZipEncodingHelper.isUTF8(encoding)) {
+            useUTF8Flag = false;
+        }
     }
 
     /**
@@ -463,7 +465,9 @@ public class ZipArchiveOutputStream exte
 
                     // * reset hasUsedZip64 if it has been set because
                     //   of this entry
-                    hasUsedZip64 &= !entry.causedUseOfZip64;
+                    if (entry.causedUseOfZip64) {
+                        hasUsedZip64 = false;
+                    }
                 }
             }
             raf.seek(save);

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java?rev=1154667&r1=1154666&r2=1154667&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
 Sun Aug  7 07:56:19 2011
@@ -63,7 +63,7 @@ public final class ZipEightByteInteger {
 
     private final BigInteger value;
 
-    public static ZipEightByteInteger ZERO = new ZipEightByteInteger(0);
+    public static final ZipEightByteInteger ZERO = new ZipEightByteInteger(0);
 
     /**
      * Create instance from a number.


Reply via email to