[PATCH JGIT] Equals method should not assume anything about the type of its argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The equals(Object o) method shouldn't make any assumptions about the type of o. It should simply return false if o is not the same type as this.

Signed-off-by: Matthias Sohn <matthias.sohn@xxxxxxx>
---
 .../src/org/spearce/jgit/lib/AnyObjectId.java      |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
index 2e3a43e..0bd2288 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java
@@ -253,7 +253,11 @@ public boolean equals(final AnyObjectId other) {
 	}
 
 	public boolean equals(final Object o) {
-		return equals((AnyObjectId) o);
+		if (o instanceof AnyObjectId) {
+			return equals((AnyObjectId) o);
+		} else {
+			return false;
+		}
 	}
 
 	/**
-- 
1.6.2.2.1669.g7eaf8

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]