diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index aac0b0cd9d9..5cdd32b3f97 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -448,12 +448,12 @@ public class Node implements Releasable { return this.injector; } - @SuppressForbidden(reason = "Need to specify port and pass to formatter") + /** Writes a file to the logs dir containing the ports for the given transport type */ private void writePortsFile(String type, BoundTransportAddress boundAddress) { Path tmpPortsFile = environment.logsFile().resolve(type + ".ports.tmp"); try (BufferedWriter writer = Files.newBufferedWriter(tmpPortsFile, Charset.forName("UTF-8"))) { for (TransportAddress address : boundAddress.boundAddresses()) { - InetSocketAddress socketAddress = new InetSocketAddress(address.getAddress(), address.getPort()); + InetSocketAddress socketAddress = buildAddress(address.getAddress(), address.getPort()); if (socketAddress.getAddress() instanceof Inet6Address && socketAddress.getAddress().isLinkLocalAddress()) { // no link local, just causes problems @@ -471,4 +471,9 @@ public class Node implements Releasable { throw new RuntimeException("Failed to rename ports file", e); } } + + @SuppressForbidden(reason = "Need to specify address and port") + private static InetSocketAddress buildAddress(String address, int port) { + return new InetSocketAddress(address, port); + } }