You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Ortwin Glück <or...@nose.ch> on 2003/09/08 09:03:00 UTC

NameValuePair.equals

I just came over the code:

     public boolean equals(Object object) {
         if (this == object) {
             return true;
         } 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;
         }
     }


I think the class check should be changed to using the instanceof 
operator. Otherwise subclassing or different classloaders cause problems 
here.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Re: [PATCH] NameValuePair.equals

Posted by Ortwin Glück <or...@nose.ch>.
see attached patch:

removed strict class check from NameValuePair#equals and rewrote code 
for better readability. Updated API Doc. Test case changed to the 
modified contract.