Skip to content

Commit 8aa55ca

Browse files
committed
fix equals/hashcode/toString
1 parent 3182209 commit 8aa55ca

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

server/src/main/java/org/elasticsearch/TransportVersion.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.HashMap;
3333
import java.util.List;
3434
import java.util.Map;
35+
import java.util.Objects;
3536
import java.util.ServiceLoader;
3637
import java.util.function.Function;
3738
import java.util.function.IntFunction;
@@ -256,12 +257,12 @@ public boolean supports(TransportVersion version) {
256257
if (onOrAfter(version)) {
257258
return true;
258259
}
259-
TransportVersion patchVersion = this.nextPatchVersion;
260-
while (patchVersion != null) {
260+
TransportVersion nextPatchVersion = version.nextPatchVersion;
261+
while (nextPatchVersion != null) {
261262
if (isPatchFrom(version)) {
262263
return true;
263264
}
264-
patchVersion = patchVersion.nextPatchVersion;
265+
nextPatchVersion = nextPatchVersion.nextPatchVersion;
265266
}
266267
return false;
267268
}
@@ -274,9 +275,21 @@ public String toReleaseVersion() {
274275
return VersionsHolder.VERSION_LOOKUP_BY_RELEASE.apply(id);
275276
}
276277

278+
@Override
279+
public boolean equals(Object o) {
280+
if (o == null || getClass() != o.getClass()) return false;
281+
TransportVersion that = (TransportVersion) o;
282+
return id == that.id;
283+
}
284+
285+
@Override
286+
public int hashCode() {
287+
return id;
288+
}
289+
277290
@Override
278291
public String toString() {
279-
return "TransportVersion{" + "name='" + name + '\'' + ", id=" + id + ", patchVersion=" + nextPatchVersion + '}';
292+
return "" + id;
280293
}
281294

282295
private static class VersionsHolder {

0 commit comments

Comments
 (0)