Fixes #149 (SyndFeedImpl#equals throws ClassCastException if compared to

an instance of a different class)
This commit is contained in:
Patrick Gotthard 2013-10-03 20:27:18 +02:00
parent 443b36e466
commit da5e32709c

View file

@ -17,7 +17,6 @@
package com.sun.syndication.feed.synd; package com.sun.syndication.feed.synd;
import com.sun.syndication.feed.CopyFrom; import com.sun.syndication.feed.CopyFrom;
import com.sun.syndication.feed.atom.Person;
import com.sun.syndication.feed.impl.ObjectBean; import com.sun.syndication.feed.impl.ObjectBean;
import com.sun.syndication.feed.impl.CopyFromHelper; import com.sun.syndication.feed.impl.CopyFromHelper;
import com.sun.syndication.feed.WireFeed; import com.sun.syndication.feed.WireFeed;
@ -169,16 +168,15 @@ public class SyndFeedImpl implements Serializable, SyndFeed {
* *
*/ */
public boolean equals(Object other) { public boolean equals(Object other) {
if (other == null) { if (other == null || !(other instanceof SyndFeedImpl)) {
return false; return false;
} }
// can't use foreign markup in equals, due to JDOM equals impl // can't use foreign markup in equals, due to JDOM equals impl
List<Element> fm = getForeignMarkup(); List<Element> fm = getForeignMarkup();
setForeignMarkup(((SyndFeedImpl)other).getForeignMarkup()); setForeignMarkup(((SyndFeedImpl)other).getForeignMarkup());
boolean ret = _objBean.equals(other); boolean ret = _objBean.equals(other);
// restore foreign markup setForeignMarkup(fm); // restore foreign markup
setForeignMarkup(fm); return ret;
return ret;
} }
/** /**