Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions server/src/main/java/org/elasticsearch/http/HttpInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -55,10 +55,10 @@ public HttpInfo(BoundTransportAddress address, long maxContentLength) {
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
Expand All @@ -83,13 +83,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
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."
);
}
}
Expand Down
23 changes: 13 additions & 10 deletions server/src/test/java/org/elasticsearch/http/HttpInfoTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,25 @@ public void testCorrectlyDisplayPublishedCname() throws Exception {
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, false
), NetworkAddress.format(localhost) + ':' + port
new HttpInfo(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert noisy formatting change

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 {
Expand All @@ -66,7 +69,7 @@ public void testCorrectDisplayPublishedIp() throws Exception {
new BoundTransportAddress(
new TransportAddress[]{new TransportAddress(localhost, port)},
new TransportAddress(localhost, port)
), 0L, true
), 0L, false
), NetworkAddress.format(localhost) + ':' + port
);
}
Expand All @@ -77,7 +80,7 @@ public void testCorrectDisplayPublishedIpv6() throws Exception {
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()
);
}
Expand Down