aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2014-02-16 23:36:32 +0000
committerAndreas Beeker <kiwiwings@apache.org>2014-02-16 23:36:32 +0000
commitbc5912e74d75fe06af7435dc71fe559eaeaa3565 (patch)
treef97b3c3223fd85689d3a813ca6243236265066e4
parent220b2638308534f360fa3011ebe1727224989d58 (diff)
downloadpoi-bc5912e74d75fe06af7435dc71fe559eaeaa3565.tar.gz
poi-bc5912e74d75fe06af7435dc71fe559eaeaa3565.zip
FindBugs fix
- 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
-rw-r--r--src/java/org/apache/poi/hssf/record/HyperlinkRecord.java3
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/Ole10Native.java3
-rw-r--r--src/java/org/apache/poi/ss/format/CellNumberFormatter.java6
-rw-r--r--src/resources/devtools/findbugs-filters.xml2
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/ListFormatOverrideLevel.java5
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java3
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java1
7 files changed, 10 insertions, 13 deletions
diff --git a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
index 026f99754b..b82d7fbb02 100644
--- a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
+++ b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
@@ -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;
}
diff --git a/src/java/org/apache/poi/poifs/filesystem/Ole10Native.java b/src/java/org/apache/poi/poifs/filesystem/Ole10Native.java
index 122eb0a5ae..4aee1e07b2 100644
--- a/src/java/org/apache/poi/poifs/filesystem/Ole10Native.java
+++ b/src/java/org/apache/poi/poifs/filesystem/Ole10Native.java
@@ -98,7 +98,8 @@ public class Ole10Native {
DocumentEntry nativeEntry =
(DocumentEntry)directory.getEntry(OLE10_NATIVE);
byte[] data = new byte[nativeEntry.getSize()];
- directory.createDocumentInputStream(nativeEntry).read(data);
+ int readBytes = directory.createDocumentInputStream(nativeEntry).read(data);
+ assert(readBytes == data.length);
return new Ole10Native(data, 0);
}
diff --git a/src/java/org/apache/poi/ss/format/CellNumberFormatter.java b/src/java/org/apache/poi/ss/format/CellNumberFormatter.java
index d2b9100556..485d335e34 100644
--- a/src/java/org/apache/poi/ss/format/CellNumberFormatter.java
+++ b/src/java/org/apache/poi/ss/format/CellNumberFormatter.java
@@ -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);
diff --git a/src/resources/devtools/findbugs-filters.xml b/src/resources/devtools/findbugs-filters.xml
index 9ec102bfd9..518557fa02 100644
--- a/src/resources/devtools/findbugs-filters.xml
+++ b/src/resources/devtools/findbugs-filters.xml
@@ -19,6 +19,6 @@
-->
<FindBugsFilter>
<Match>
- <Bug pattern="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE,MS_PKGPROTECT,MS_MUTABLE_ARRAY"/>
+ <Bug code="EI,EI2" pattern="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE,MS_PKGPROTECT,MS_MUTABLE_ARRAY"/>
</Match>
</FindBugsFilter> \ No newline at end of file
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/ListFormatOverrideLevel.java b/src/scratchpad/src/org/apache/poi/hwpf/model/ListFormatOverrideLevel.java
index 0acd9d0c3b..bcffbe8b3d 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/ListFormatOverrideLevel.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/ListFormatOverrideLevel.java
@@ -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 )
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java b/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
index 3de08d8d43..f8e331fe53 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java
@@ -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 )
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java
index ccf56cfe05..b9bdff1afc 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java
@@ -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 ) )
{