Menu

#7 Cookie and HeaderEntry violate Object contract

open
nobody
None
5
2004-08-20
2004-08-20
No

The contract for Object.hashCode() includes "If two objects are
equal according to the equals(Object) method, then calling the
hashCode method on each of the two objects must produce the
same integer result." Both Cookie and HeaderEntry override
equals(Object) without overriding hashCode(), and so violate this
contract. This can lead to unexpected behaviour if they're used in
conjunction with hashed data structures such as
java.util.Hash{Map,Set}.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB