diff --git a/server/src/main/java/org/elasticsearch/http/HttpInfo.java b/server/src/main/java/org/elasticsearch/http/HttpInfo.java index cf9e4672d62..f3457495294 100644 --- a/server/src/main/java/org/elasticsearch/http/HttpInfo.java +++ b/server/src/main/java/org/elasticsearch/http/HttpInfo.java @@ -45,7 +45,7 @@ public class HttpInfo implements Writeable, ToXContentFragment { private final BoundTransportAddress address; private final long maxContentLength; - private final boolean cnameInPublishHost; + private final boolean cnameInPublishHostProperty; public HttpInfo(StreamInput in) throws IOException { this(new BoundTransportAddress(in), in.readLong(), CNAME_IN_PUBLISH_HOST); @@ -55,10 +55,10 @@ public class HttpInfo implements Writeable, ToXContentFragment { this(address, maxContentLength, CNAME_IN_PUBLISH_HOST); } - HttpInfo(BoundTransportAddress address, long maxContentLength, boolean cnameInPublishHost) { + HttpInfo(BoundTransportAddress address, long maxContentLength, boolean cnameInPublishHostProperty) { this.address = address; this.maxContentLength = maxContentLength; - this.cnameInPublishHost = cnameInPublishHost; + this.cnameInPublishHostProperty = cnameInPublishHostProperty; } @Override @@ -83,13 +83,11 @@ public class HttpInfo implements Writeable, ToXContentFragment { String publishAddressString = publishAddress.toString(); String hostString = publishAddress.address().getHostString(); if (InetAddresses.isInetAddress(hostString) == false) { - if (cnameInPublishHost) { - publishAddressString = hostString + '/' + publishAddress.toString(); - } else { + publishAddressString = hostString + '/' + publishAddress.toString(); + if (cnameInPublishHostProperty) { deprecationLogger.deprecated( - "[http.publish_host] was printed as [ip:port] instead of [hostname/ip:port]. " - + "This format is deprecated and will change to [hostname/ip:port] in a future version. " - + "Use -Des.http.cname_in_publish_address=true to enforce non-deprecated formatting." + "es.http.cname_in_publish_address system property is deprecated and no longer affects http.publish_address " + + "formatting. Remove this property to get rid of this deprecation warning." ); } } diff --git a/server/src/test/java/org/elasticsearch/http/HttpInfoTests.java b/server/src/test/java/org/elasticsearch/http/HttpInfoTests.java index db149bd6d0d..cd0cf7e1894 100644 --- a/server/src/test/java/org/elasticsearch/http/HttpInfoTests.java +++ b/server/src/test/java/org/elasticsearch/http/HttpInfoTests.java @@ -40,14 +40,30 @@ public class HttpInfoTests extends ESTestCase { new BoundTransportAddress( new TransportAddress[]{new TransportAddress(localhost, port)}, new TransportAddress(localhost, port) - ), 0L, true + ), 0L, false ), "localhost/" + NetworkAddress.format(localhost) + ':' + port ); } - public void hideCnameIfDeprecatedFormat() throws Exception { + public void testDeprecatedWarningIfPropertySpecified() throws Exception { InetAddress localhost = InetAddress.getByName("localhost"); int port = 9200; + assertPublishAddress( + new HttpInfo( + new BoundTransportAddress( + new TransportAddress[]{new TransportAddress(localhost, port)}, + new TransportAddress(localhost, port) + ), 0L, true + ), "localhost/" + NetworkAddress.format(localhost) + ':' + port + ); + assertWarnings( + "es.http.cname_in_publish_address system property is deprecated and no longer affects http.publish_address " + + "formatting. Remove this property to get rid of this deprecation warning."); + } + + public void testCorrectDisplayPublishedIp() throws Exception { + InetAddress localhost = InetAddress.getByName(NetworkAddress.format(InetAddress.getByName("localhost"))); + int port = 9200; assertPublishAddress( new HttpInfo( new BoundTransportAddress( @@ -58,26 +74,13 @@ public class HttpInfoTests extends ESTestCase { ); } - public void testCorrectDisplayPublishedIp() throws Exception { - InetAddress localhost = InetAddress.getByName(NetworkAddress.format(InetAddress.getByName("localhost"))); - int port = 9200; - assertPublishAddress( - new HttpInfo( - new BoundTransportAddress( - new TransportAddress[]{new TransportAddress(localhost, port)}, - new TransportAddress(localhost, port) - ), 0L, true - ), NetworkAddress.format(localhost) + ':' + port - ); - } - public void testCorrectDisplayPublishedIpv6() throws Exception { int port = 9200; TransportAddress localhost = new TransportAddress(InetAddress.getByName(NetworkAddress.format(InetAddress.getByName("0:0:0:0:0:0:0:1"))), port); assertPublishAddress( new HttpInfo( - new BoundTransportAddress(new TransportAddress[]{localhost}, localhost), 0L, true + new BoundTransportAddress(new TransportAddress[]{localhost}, localhost), 0L, false ), localhost.toString() ); }