Author: olegk Date: Wed Oct 19 13:51:46 2005 New Revision: 326707 URL: http://svn.apache.org/viewcvs?rev=326707&view=rev Log: PR #37154 (UsernamePasswordCredentials.equals(null) throws NPE)
Contributed by Oleg Kalnichevski Reviewed by Michael Becke Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/NTCredentials.java jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/NTCredentials.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/NTCredentials.java?rev=326707&r1=326706&r2=326707&view=diff ============================================================================== --- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/NTCredentials.java (original) +++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/NTCredentials.java Wed Oct 19 13:51:46 2005 @@ -175,9 +175,8 @@ * @return <code>true</code> if all of the credentials match. */ public boolean equals(Object o) { - if (this == o) - return true; - + if (o == null) return false; + if (this == o) return true; if (super.equals(o) ) { if (o instanceof NTCredentials) { NTCredentials that = (NTCredentials) o; Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java?rev=326707&r1=326706&r2=326707&view=diff ============================================================================== --- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java (original) +++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java Wed Oct 19 13:51:46 2005 @@ -194,13 +194,11 @@ * @return <code>true</code> if the object is equivalent. */ public boolean equals(Object o) { - if (o == this) { - return true; - } - + if (o == null) return false; + if (this == o) return true; // note - to allow for sub-classing, this checks that class is the same // rather than do "instanceof". - if (o.getClass() == this.getClass() ) { + if (this.getClass().equals(o.getClass())) { UsernamePasswordCredentials that = (UsernamePasswordCredentials) o; if (LangUtils.equals(this.userName, that.userName) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]