Re: (tomcat) branch main updated: Use Eclipse generated hashCode() and equals() with some modifications
Christopher Schultz <[email protected]> Fri, 10 Jul 2026 09:54:08 -0400
| Newsgroups | gmane.comp.jakarta.tomcat.devel |
|---|---|
| Message-ID | <[email protected]> |
On 7/10/26 3:58 AM, [email protected] wrote: > This is an automated email from the ASF dual-hosted git repository. > > markt-asf pushed a commit to branch main > in repository https://gitbox.apache.org/repos/asf/tomcat.git > > > The following commit(s) were added to refs/heads/main by this push: > new 645af54895 Use Eclipse generated hashCode() and equals() with some modifications > 645af54895 is described below > > commit 645af54895f0549f1cb4d96ac931e2c0b7f0f941 > Author: Mark Thomas <[email protected]> > AuthorDate: Fri Jul 10 08:58:45 2026 +0100 > > Use Eclipse generated hashCode() and equals() with some modifications > --- > .../tribes/tipis/AbstractReplicatedMap.java | 23 ++++++++-------------- > 1 file changed, 8 insertions(+), 15 deletions(-) > > diff --git a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java > index c5dcdd2d2e..8748964113 100644 > --- a/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java > +++ b/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java > @@ -1759,27 +1759,20 @@ public abstract class AbstractReplicatedMap<K, V> > > @Override > public int hashCode() { > - return key == null ? 0 : key.hashCode(); > + return Objects.hashCode(key) ^ Objects.hashCode(value); > } > > @Override > - public boolean equals(Object o) { > - if (!(o instanceof MapEntry)) { > + public boolean equals(Object obj) { > + if (this == obj) { > + return true; > + } > + if (!(obj instanceof MapEntry)) { > return false; > } > @SuppressWarnings("rawtypes") > - MapEntry other = (MapEntry) o; > - if (key == null) { > - if (value == null) { > - return other.key == null && other.value == null; > - } else { > - return other.key == null && value.equals(other.value); > - } > - } > - if (value == null) { > - return key.equals(other.key) && other.value == null; > - } > - return key.equals(other.key) && value.equals(other.value); > + MapEntry other = (MapEntry) obj; > + return Objects.equals(key, other.key) && Objects.equals(value, other.value); Oh, good. I was about to reply to your previous commit asking why you were torturing the code when Objects.equals() existed :) -chris