PMD: AbstractReferenceMap.SoftRef implements hashCode() but not equals()

This commit is contained in:
Gary Gregory 2022-11-06 11:35:53 -05:00
parent e84ff4dff0
commit d22eb8951b
2 changed files with 18 additions and 0 deletions

View File

@ -106,6 +106,9 @@
<action type="fix" dev="ggregory" due-to="Marc Wrobel">
Fix minor typos #323
</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">
AbstractReferenceMap.SoftRef implements hashCode() but not equals().
</action>
<!-- ADD -->
<action issue="COLLECTIONS-760" dev="kinow" type="add" due-to="Isira Seneviratne">
Add tests for MapUtils.

View File

@ -966,6 +966,21 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
public int hashCode() {
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
SoftRef<?> other = (SoftRef<?>) obj;
return hash == other.hash;
}
}
/**