Skip to content

Commit 2b965f6

Browse files
dk2kbeikov
authored andcommitted
HHH-18122 added check of the arg type into equals()
1 parent 638466f commit 2b965f6

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

hibernate-core/src/main/java/org/hibernate/internal/util/collections/BoundedConcurrentHashMap.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ public int hashCode() {
225225

226226
@Override
227227
public boolean equals(Object o) {
228+
if (!(o instanceof HashEntry)) {
229+
return false;
230+
}
228231
// HashEntry is internal class, never leaks out of CHM, hence slight optimization
229232
if ( this == o ) {
230233
return true;
@@ -484,6 +487,9 @@ public int hashCode() {
484487

485488
@Override
486489
public boolean equals(Object o) {
490+
if (!(o instanceof LIRSHashEntry)) {
491+
return false;
492+
}
487493
// HashEntry is internal class, never leaks out of CHM, hence slight optimization
488494
if ( this == o ) {
489495
return true;

hibernate-core/src/main/java/org/hibernate/mapping/Table.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,9 @@ public int hashCode() {
840840
}
841841

842842
public boolean equals(Object other) {
843+
if (!(other instanceof ForeignKeyKey)) {
844+
return false;
845+
}
843846
ForeignKeyKey fkk = (ForeignKeyKey) other;
844847
return fkk != null
845848
&& Arrays.equals( fkk.columns, columns )

hibernate-core/src/main/java/org/hibernate/spi/NavigablePath.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ public int hashCode() {
126126

127127
@Override
128128
public boolean equals(@Nullable Object other) {
129+
if (!(other instanceof NavigablePath)) {
130+
return false;
131+
}
132+
129133
if ( this == other ) {
130134
return true;
131135
}

hibernate-core/src/main/java/org/hibernate/type/spi/TypeConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,9 @@ public ArrayCacheKey(SqmExpressible<?>[] components) {
642642

643643
@Override
644644
public boolean equals(Object o) {
645+
if (!(o instanceof ArrayCacheKey)) {
646+
return false;
647+
}
645648
return Arrays.equals( components, ((ArrayCacheKey) o).components );
646649
}
647650

0 commit comments

Comments
 (0)