Skip to content

Commit a5ceca7

Browse files
author
Andrey Ershov
authored
Remove deprecated es.http.cname_in_publish_address setting (#45616)
Follow up on #32806. The system property es.http.cname_in_publish_address is deprecated starting from 7.0.0 and deprecation warning should be added if the property is specified. This PR will go to 7.x and master. Follow-up PR to remove es.http.cname_in_publish_address property completely will go to the master.
1 parent fab31ab commit a5ceca7

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

server/src/main/java/org/elasticsearch/http/HttpInfo.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class HttpInfo implements Writeable, ToXContentFragment {
4545

4646
private final BoundTransportAddress address;
4747
private final long maxContentLength;
48-
private final boolean cnameInPublishHost;
48+
private final boolean cnameInPublishHostProperty;
4949

5050
public HttpInfo(StreamInput in) throws IOException {
5151
this(new BoundTransportAddress(in), in.readLong(), CNAME_IN_PUBLISH_HOST);
@@ -55,10 +55,10 @@ public HttpInfo(BoundTransportAddress address, long maxContentLength) {
5555
this(address, maxContentLength, CNAME_IN_PUBLISH_HOST);
5656
}
5757

58-
HttpInfo(BoundTransportAddress address, long maxContentLength, boolean cnameInPublishHost) {
58+
HttpInfo(BoundTransportAddress address, long maxContentLength, boolean cnameInPublishHostProperty) {
5959
this.address = address;
6060
this.maxContentLength = maxContentLength;
61-
this.cnameInPublishHost = cnameInPublishHost;
61+
this.cnameInPublishHostProperty = cnameInPublishHostProperty;
6262
}
6363

6464
@Override
@@ -83,13 +83,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
8383
String publishAddressString = publishAddress.toString();
8484
String hostString = publishAddress.address().getHostString();
8585
if (InetAddresses.isInetAddress(hostString) == false) {
86-
if (cnameInPublishHost) {
87-
publishAddressString = hostString + '/' + publishAddress.toString();
88-
} else {
86+
publishAddressString = hostString + '/' + publishAddress.toString();
87+
if (cnameInPublishHostProperty) {
8988
deprecationLogger.deprecated(
90-
"[http.publish_host] was printed as [ip:port] instead of [hostname/ip:port]. "
91-
+ "This format is deprecated and will change to [hostname/ip:port] in a future version. "
92-
+ "Use -Des.http.cname_in_publish_address=true to enforce non-deprecated formatting."
89+
"es.http.cname_in_publish_address system property is deprecated and no longer affects http.publish_address " +
90+
"formatting. Remove this property to get rid of this deprecation warning."
9391
);
9492
}
9593
}

server/src/test/java/org/elasticsearch/http/HttpInfoTests.java

+13-10
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,25 @@ public void testCorrectlyDisplayPublishedCname() throws Exception {
4040
new BoundTransportAddress(
4141
new TransportAddress[]{new TransportAddress(localhost, port)},
4242
new TransportAddress(localhost, port)
43-
), 0L, true
43+
), 0L, false
4444
), "localhost/" + NetworkAddress.format(localhost) + ':' + port
4545
);
4646
}
4747

48-
public void hideCnameIfDeprecatedFormat() throws Exception {
48+
public void testDeprecatedWarningIfPropertySpecified() throws Exception {
4949
InetAddress localhost = InetAddress.getByName("localhost");
5050
int port = 9200;
5151
assertPublishAddress(
52-
new HttpInfo(
53-
new BoundTransportAddress(
54-
new TransportAddress[]{new TransportAddress(localhost, port)},
55-
new TransportAddress(localhost, port)
56-
), 0L, false
57-
), NetworkAddress.format(localhost) + ':' + port
52+
new HttpInfo(
53+
new BoundTransportAddress(
54+
new TransportAddress[]{new TransportAddress(localhost, port)},
55+
new TransportAddress(localhost, port)
56+
), 0L, true
57+
), "localhost/" + NetworkAddress.format(localhost) + ':' + port
5858
);
59+
assertWarnings(
60+
"es.http.cname_in_publish_address system property is deprecated and no longer affects http.publish_address " +
61+
"formatting. Remove this property to get rid of this deprecation warning.");
5962
}
6063

6164
public void testCorrectDisplayPublishedIp() throws Exception {
@@ -66,7 +69,7 @@ public void testCorrectDisplayPublishedIp() throws Exception {
6669
new BoundTransportAddress(
6770
new TransportAddress[]{new TransportAddress(localhost, port)},
6871
new TransportAddress(localhost, port)
69-
), 0L, true
72+
), 0L, false
7073
), NetworkAddress.format(localhost) + ':' + port
7174
);
7275
}
@@ -77,7 +80,7 @@ public void testCorrectDisplayPublishedIpv6() throws Exception {
7780
new TransportAddress(InetAddress.getByName(NetworkAddress.format(InetAddress.getByName("0:0:0:0:0:0:0:1"))), port);
7881
assertPublishAddress(
7982
new HttpInfo(
80-
new BoundTransportAddress(new TransportAddress[]{localhost}, localhost), 0L, true
83+
new BoundTransportAddress(new TransportAddress[]{localhost}, localhost), 0L, false
8184
), localhost.toString()
8285
);
8386
}

0 commit comments

Comments
 (0)