Skip to content

Commit 91b8797

Browse files
author
Andrey Ershov
committed
Remove deprecated es.http.cname_in_publish_address setting
1 parent 66b8261 commit 91b8797

File tree

2 files changed

+5
-43
lines changed

2 files changed

+5
-43
lines changed

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919

2020
package org.elasticsearch.http;
2121

22-
import org.apache.logging.log4j.LogManager;
2322
import org.elasticsearch.common.io.stream.StreamInput;
2423
import org.elasticsearch.common.io.stream.StreamOutput;
2524
import org.elasticsearch.common.io.stream.Writeable;
26-
import org.elasticsearch.common.logging.DeprecationLogger;
2725
import org.elasticsearch.common.network.InetAddresses;
2826
import org.elasticsearch.common.transport.BoundTransportAddress;
2927
import org.elasticsearch.common.transport.TransportAddress;
@@ -33,32 +31,17 @@
3331

3432
import java.io.IOException;
3533

36-
import static org.elasticsearch.common.Booleans.parseBoolean;
37-
3834
public class HttpInfo implements Writeable, ToXContentFragment {
39-
40-
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(HttpInfo.class));
41-
42-
/** Whether to add hostname to publish host field when serializing. */
43-
private static final boolean CNAME_IN_PUBLISH_HOST =
44-
parseBoolean(System.getProperty("es.http.cname_in_publish_address"), true);
45-
4635
private final BoundTransportAddress address;
4736
private final long maxContentLength;
48-
private final boolean cnameInPublishHost;
4937

5038
public HttpInfo(StreamInput in) throws IOException {
51-
this(new BoundTransportAddress(in), in.readLong(), CNAME_IN_PUBLISH_HOST);
39+
this(new BoundTransportAddress(in), in.readLong());
5240
}
5341

5442
public HttpInfo(BoundTransportAddress address, long maxContentLength) {
55-
this(address, maxContentLength, CNAME_IN_PUBLISH_HOST);
56-
}
57-
58-
HttpInfo(BoundTransportAddress address, long maxContentLength, boolean cnameInPublishHost) {
5943
this.address = address;
6044
this.maxContentLength = maxContentLength;
61-
this.cnameInPublishHost = cnameInPublishHost;
6245
}
6346

6447
@Override
@@ -83,15 +66,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
8366
String publishAddressString = publishAddress.toString();
8467
String hostString = publishAddress.address().getHostString();
8568
if (InetAddresses.isInetAddress(hostString) == false) {
86-
if (cnameInPublishHost) {
87-
publishAddressString = hostString + '/' + publishAddress.toString();
88-
} else {
89-
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."
93-
);
94-
}
69+
publishAddressString = hostString + '/' + publishAddress.toString();
9570
}
9671
builder.field(Fields.PUBLISH_ADDRESS, publishAddressString);
9772
builder.humanReadableField(Fields.MAX_CONTENT_LENGTH_IN_BYTES, Fields.MAX_CONTENT_LENGTH, maxContentLength());

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

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,11 @@ 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
4444
), "localhost/" + NetworkAddress.format(localhost) + ':' + port
4545
);
4646
}
4747

48-
public void hideCnameIfDeprecatedFormat() throws Exception {
49-
InetAddress localhost = InetAddress.getByName("localhost");
50-
int port = 9200;
51-
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
58-
);
59-
}
60-
6148
public void testCorrectDisplayPublishedIp() throws Exception {
6249
InetAddress localhost = InetAddress.getByName(NetworkAddress.format(InetAddress.getByName("localhost")));
6350
int port = 9200;
@@ -66,7 +53,7 @@ public void testCorrectDisplayPublishedIp() throws Exception {
6653
new BoundTransportAddress(
6754
new TransportAddress[]{new TransportAddress(localhost, port)},
6855
new TransportAddress(localhost, port)
69-
), 0L, true
56+
), 0L
7057
), NetworkAddress.format(localhost) + ':' + port
7158
);
7259
}
@@ -77,7 +64,7 @@ public void testCorrectDisplayPublishedIpv6() throws Exception {
7764
new TransportAddress(InetAddress.getByName(NetworkAddress.format(InetAddress.getByName("0:0:0:0:0:0:0:1"))), port);
7865
assertPublishAddress(
7966
new HttpInfo(
80-
new BoundTransportAddress(new TransportAddress[]{localhost}, localhost), 0L, true
67+
new BoundTransportAddress(new TransportAddress[]{localhost}, localhost), 0L
8168
), localhost.toString()
8269
);
8370
}

0 commit comments

Comments
 (0)