diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 3fbe05c1c7a..ea1973c4057 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -312,30 +312,25 @@ public class DiscoveryNode implements Writeable, ToXContent { return nodeId.hashCode(); } - private String toString; - @Override public String toString() { - if (toString == null) { - StringBuilder sb = new StringBuilder(); - if (nodeName.length() > 0) { - sb.append('{').append(nodeName).append('}'); - } - if (nodeId != null) { - sb.append('{').append(nodeId).append('}'); - } - if (Strings.hasLength(hostName)) { - sb.append('{').append(hostName).append('}'); - } - if (address != null) { - sb.append('{').append(address).append('}'); - } - if (!attributes.isEmpty()) { - sb.append(attributes); - } - toString = sb.toString(); + StringBuilder sb = new StringBuilder(); + if (nodeName.length() > 0) { + sb.append('{').append(nodeName).append('}'); } - return toString; + if (nodeId != null) { + sb.append('{').append(nodeId).append('}'); + } + if (Strings.hasLength(hostName)) { + sb.append('{').append(hostName).append('}'); + } + if (address != null) { + sb.append('{').append(address).append('}'); + } + if (!attributes.isEmpty()) { + sb.append(attributes); + } + return sb.toString(); } @Override