diff --git a/app/src/main/java/org/astraea/app/admin/NodeInfo.java b/app/src/main/java/org/astraea/app/admin/NodeInfo.java index 208cdb3410..cd7ad6a275 100644 --- a/app/src/main/java/org/astraea/app/admin/NodeInfo.java +++ b/app/src/main/java/org/astraea/app/admin/NodeInfo.java @@ -38,6 +38,9 @@ static NodeInfo of(int id, String host, int port) { static NodeInfo of(int id, String host, int port, boolean isOffline) { return new NodeInfo() { + // NodeInfo is used to be key of Map commonly, so creating hash can reduce the memory pressure + private final int hashCode = Objects.hash(id, host, port); + @Override public String host() { return host; @@ -60,7 +63,7 @@ public int port() { @Override public int hashCode() { - return Objects.hash(id, host, port); + return hashCode; } @Override