Skip to content

Commit 9d3bcc2

Browse files
Fix unstable test URLTest.testHashcode
1 parent 3720471 commit 9d3bcc2

File tree

1 file changed

+7
-5
lines changed
  • dubbo-common/src/main/java/org/apache/dubbo/common/url/component

1 file changed

+7
-5
lines changed

dubbo-common/src/main/java/org/apache/dubbo/common/url/component/URLParam.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -890,15 +890,17 @@ public boolean equals(Object o) {
890890
@Override
891891
public int hashCode() {
892892
if (hashCodeCache == -1) {
893+
int result = 1;
893894
for (Map.Entry<String, String> entry : EXTRA_PARAMS.entrySet()) {
894895
if (!TIMESTAMP_KEY.equals(entry.getKey())) {
895-
hashCodeCache = hashCodeCache * 31 + Objects.hashCode(entry);
896+
result += entry.hashCode();
896897
}
897898
}
898-
for (Integer value : VALUE) {
899-
hashCodeCache = hashCodeCache * 31 + value;
900-
}
901-
hashCodeCache = hashCodeCache * 31 + ((KEY == null) ? 0 : KEY.hashCode());
899+
900+
result = 31 * result + Arrays.hashCode(VALUE);
901+
result = 31 * result + ((KEY == null) ? 0 : KEY.hashCode());
902+
903+
hashCodeCache = result;
902904
}
903905
return hashCodeCache;
904906
}

0 commit comments

Comments
 (0)