]> source.dussan.org Git - poi.git/commitdiff
FindBugs fix
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 16 Feb 2014 23:36:32 +0000 (23:36 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 16 Feb 2014 23:36:32 +0000 (23:36 +0000)
- fixed "Equals method should not assume anything about the type of its argument"
- see http://findbugs.sourceforge.net/bugDescriptions.html#BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1568861 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
src/java/org/apache/poi/poifs/filesystem/Ole10Native.java
src/java/org/apache/poi/ss/format/CellNumberFormatter.java
src/resources/devtools/findbugs-filters.xml
src/scratchpad/src/org/apache/poi/hwpf/model/ListFormatOverrideLevel.java
src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java

index 026f99754be83409cc7e8853ca8773b54e9210ed..b82d7fbb02bba07adbfcac8959843f594166426a 100644 (file)
@@ -83,9 +83,8 @@ public final class HyperlinkRecord extends StandardRecord {
 
                @Override
                public boolean equals(Object obj) {
+            if (!(obj instanceof GUID)) return false;
                        GUID other = (GUID) obj;
-            if (obj == null || !(obj instanceof GUID))
-                return false;
                        return _d1 == other._d1 && _d2 == other._d2
                            && _d3 == other._d3 && _d4 == other._d4;
                }
index 122eb0a5aecea8347346ee12f17b73e073c8555f..4aee1e07b2e828dc2ffddb095fe934950ba6f1b8 100644 (file)
@@ -98,7 +98,8 @@ public class Ole10Native {
        DocumentEntry nativeEntry = \r
           (DocumentEntry)directory.getEntry(OLE10_NATIVE);\r
        byte[] data = new byte[nativeEntry.getSize()];\r
-       directory.createDocumentInputStream(nativeEntry).read(data);\r
+       int readBytes = directory.createDocumentInputStream(nativeEntry).read(data);\r
+       assert(readBytes == data.length);\r
   \r
        return new Ole10Native(data, 0);\r
     }
index d2b9100556079b1f5817b033adb9dc56c81d0b01..485d335e344e45f15fb8a24e4003c4803ee8cff5 100644 (file)
@@ -16,8 +16,6 @@
 ==================================================================== */
 package org.apache.poi.ss.format;
 
-import org.apache.poi.ss.format.CellFormatPart.PartHandler;
-
 import java.text.DecimalFormat;
 import java.text.FieldPosition;
 import java.util.BitSet;
@@ -31,6 +29,8 @@ import java.util.Set;
 import java.util.TreeSet;
 import java.util.regex.Matcher;
 
+import org.apache.poi.ss.format.CellFormatPart.PartHandler;
+
 /**
  * This class implements printing out a value using a number format.
  *
@@ -658,7 +658,7 @@ public class CellNumberFormatter extends CellFormatter {
                             delEndPos + adjust; // delete end point in current
 
                     if (modPos < modEndPos) {
-                        if (nextChange.toAdd == "")
+                        if ("".equals(nextChange.toAdd))
                             output.delete(modPos, modEndPos);
                         else {
                             char fillCh = nextChange.toAdd.charAt(0);
index 9ec102bfd9f06c207c7a51f59e15ab5bf2664394..518557fa02ce9f2cdac35b7220920da6668c0177 100644 (file)
@@ -19,6 +19,6 @@
 -->\r
 <FindBugsFilter>\r
        <Match>\r
-               <Bug pattern="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE,MS_PKGPROTECT,MS_MUTABLE_ARRAY"/>\r
+               <Bug code="EI,EI2" pattern="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE,MS_PKGPROTECT,MS_MUTABLE_ARRAY"/>\r
        </Match>\r
 </FindBugsFilter>
\ No newline at end of file
index 0acd9d0c3b6907d290d164290f420acee92c48d5..bcffbe8b3d1aaac40cdacada054bb6c1539ce3ce 100644 (file)
@@ -44,10 +44,7 @@ public final class ListFormatOverrideLevel
 
     public boolean equals( Object obj )
     {
-        if ( obj == null )
-        {
-            return false;
-        }
+        if (!(obj instanceof ListFormatOverrideLevel)) return false;
         ListFormatOverrideLevel lfolvl = (ListFormatOverrideLevel) obj;
         boolean lvlEquality = false;
         if ( _lvl != null )
index 3de08d8d433276a445c72c223cd0a393ac8c2657..f8e331fe533a34e9c63c3e08d2766fbd97f62305 100644 (file)
@@ -104,8 +104,7 @@ public final class ListLevel
     @Override
     public boolean equals( Object obj )
     {
-        if ( obj == null )
-            return false;
+        if (!(obj instanceof ListLevel)) return false;
 
         ListLevel lvl = (ListLevel) obj;
         return lvl._lvlf.equals( this._lvlf )
index ccf56cfe053ba98a7e5cf50b5823f121843e42f1..b9bdff1afc82c48884970601cc501a16a0738fd2 100644 (file)
@@ -67,6 +67,7 @@ public final class SEPX extends PropertyNode<SEPX>
     @Override
     public boolean equals( Object o )
     {
+        if (!(o instanceof SEPX)) return false;
         SEPX sepx = (SEPX) o;
         if ( super.equals( o ) )
         {