Elffuss BraidHub

kikocis/java-driver public

JAVA-942: Fix implementation of UserType.hashCode()

(Backported from 3.0 branch)
Changeset0d619c82c5fa97ac7ceea725220ce4fd91110f405de23c95a54fdcf107d1aaa4
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2015-10-08 13:00 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2015-10-12 11:54 +02:00
Parents98a9d75ec57e

Browse the files at this changeset

2 files changed

modified changelog/README.md +5 −0
@@ -1,5 +1,10 @@
11 ## Changelog
22
3+### 2.1.9 (in progress)
4+
5+- [bug] Fix implementation of UserType.hashCode() (JAVA-942)
6+
7+
38 ### 2.1.8
49
510 Merged from 2.0 branch:
modified driver-core/src/main/java/com/datastax/driver/core/UserType.java +7 −2
@@ -179,7 +179,11 @@
179179
180180 @Override
181181 public final int hashCode() {
182- return Arrays.hashCode(new Object[]{ name, keyspace, typeName, byIdx });
182+ int result = name.hashCode();
183+ result = 31 * result + keyspace.hashCode();
184+ result = 31 * result + typeName.hashCode();
185+ result = 31 * result + Arrays.hashCode(byIdx);
186+ return result;
183187 }
184188
185189 @Override
@@ -191,7 +195,8 @@
191195
192196 // Note: we don't test byName because it's redundant with byIdx in practice,
193197 // but also because the map holds 'int[]' which don't have proper equal.
194- return keyspace.equals(other.keyspace)
198+ return name.equals(other.name)
199+ && keyspace.equals(other.keyspace)
195200 && typeName.equals(other.typeName)
196201 && Arrays.equals(byIdx, other.byIdx);
197202 }