You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Rand McNeely <ra...@yahoo.com> on 2002/06/29 19:09:43 UTC
HttpClient NullPointerException in equals(Object o) of org.apache.commons.httpclient.NameValuePair
This is my first contribution to a Jakarta project, if I am in poor
form, let me know.
Before calling object.getClass(), check to see if passed object is null.
/**
* Test if the given <i>object</i> is equal to me.
* In this implementation, an <i>object</i> is
* equal to me iff it has the same runtime
* type and the <i>name</i> and <i>value</i> attributes
* are both <tt>equal</tt> (or <tt>==</tt>).
*
* @param object the {@link Object} to compare to
*/
public boolean equals(Object object) {
if (this == object) {
return true;
} else if (null == object) {
return false;
} else if (this.getClass().equals(object.getClass())) {
NameValuePair pair = (NameValuePair) object;
return ((null == name ? null == pair.name :
name.equals(pair.name))
&& (null == value ? null == pair.value :
value.equals(pair.value)));
} else {
return false;
}
}
Thanks,
Rand
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>