Skip to content

Commit 1ad4715

Browse files
clementdenismbellade
authored andcommitted
HHH-16385 Ensure QueryKey is immutable and serializable
1 parent cb79ffd commit 1ad4715

File tree

1 file changed

+5
-4
lines changed
  • hibernate-core/src/main/java/org/hibernate/cache/spi

1 file changed

+5
-4
lines changed

hibernate-core/src/main/java/org/hibernate/cache/spi/QueryKey.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import java.io.IOException;
1010
import java.io.Serializable;
11+
import java.util.Arrays;
1112
import java.util.Objects;
1213
import java.util.Set;
1314

@@ -65,7 +66,7 @@ public static QueryKey from(
6566
private final Integer firstRow;
6667
private final Integer maxRows;
6768
private final String tenantIdentifier;
68-
private final Set<String> enabledFilterNames;
69+
private final String[] enabledFilterNames;
6970

7071
/**
7172
* For performance reasons, the hashCode is cached; however, it is marked transient so that it can be
@@ -85,7 +86,7 @@ public QueryKey(
8586
this.firstRow = firstRow;
8687
this.maxRows = maxRows;
8788
this.tenantIdentifier = tenantIdentifier;
88-
this.enabledFilterNames = enabledFilterNames;
89+
this.enabledFilterNames = enabledFilterNames.toArray( String[]::new );
8990
this.hashCode = generateHashCode();
9091
}
9192

@@ -110,7 +111,7 @@ private int generateHashCode() {
110111
// result = 37 * result + ( maxRows==null ? 0 : maxRows );
111112
result = 37 * result + ( tenantIdentifier==null ? 0 : tenantIdentifier.hashCode() );
112113
result = 37 * result + parameterBindingsMemento.hashCode();
113-
result = 37 * result + ( enabledFilterNames == null ? 0 : enabledFilterNames.hashCode() );
114+
result = 37 * result + Arrays.hashCode( enabledFilterNames );
114115
return result;
115116
}
116117

@@ -146,7 +147,7 @@ public boolean equals(Object other) {
146147
return false;
147148
}
148149

149-
if ( ! Objects.equals( enabledFilterNames, that.enabledFilterNames ) ) {
150+
if ( ! Arrays.equals( enabledFilterNames, that.enabledFilterNames ) ) {
150151
return false;
151152
}
152153

0 commit comments

Comments
 (0)