From a39457d1c736edf4666808906e8c0c7158f2b903 Mon Sep 17 00:00:00 2001 From: Gurmeen Bindra Date: Fri, 7 Sep 2012 09:30:37 +0100 Subject: Correct the equals method of JID class The method was comparing the classes instead of instances as a result of which equal JIDs but belonging to different derived class were always unequal. Test-information: Tested using an XMPP client which is using objects of class derived from JID class to compare with raw JID objects diff --git a/src/com/isode/stroke/jid/JID.java b/src/com/isode/stroke/jid/JID.java index acd1430..490a65d 100644 --- a/src/com/isode/stroke/jid/JID.java +++ b/src/com/isode/stroke/jid/JID.java @@ -218,13 +218,13 @@ public class JID implements Comparable { } @Override - public boolean equals(final Object otherObject) { - if (otherObject == null || getClass() != otherObject.getClass()) { - return false; - } + public boolean equals(final Object otherObject) { if (otherObject == this) { return true; } + if (!(otherObject instanceof JID)) { + return false; + } JID other = (JID)otherObject; String node1 = getNode(); String node2 = other.getNode(); -- cgit v0.10.2-6-g49f6