Skip to content

Commit 34251cf

Browse files
authored
Flush response stream in Ec2DiscoveryTests (#114101) (#114114)
This is apparently necessary when running with JDK23. Also cleans up some warnings in the same test suite. Closes #114088 Closes #114089 Closes #114090
1 parent 12bfd44 commit 34251cf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class Ec2DiscoveryTests extends AbstractEC2MockAPITestCase {
5858
private static final String PREFIX_PUBLIC_IP = "8.8.8.";
5959
private static final String PREFIX_PRIVATE_IP = "10.0.0.";
6060

61-
private Map<String, TransportAddress> poorMansDNS = new ConcurrentHashMap<>();
61+
private final Map<String, TransportAddress> poorMansDNS = new ConcurrentHashMap<>();
6262

6363
protected MockTransportService createTransportService() {
6464
final Transport transport = new Netty4Transport(
@@ -132,7 +132,7 @@ protected List<TransportAddress> buildDynamicHosts(Settings nodeSettings, int no
132132
.stream()
133133
.filter(t -> t.getKey().equals(entry.getKey()))
134134
.map(Tag::getValue)
135-
.collect(Collectors.toList())
135+
.toList()
136136
.containsAll(entry.getValue())
137137
)
138138
)
@@ -143,6 +143,7 @@ protected List<TransportAddress> buildDynamicHosts(Settings nodeSettings, int no
143143
exchange.getResponseHeaders().set("Content-Type", "text/xml; charset=UTF-8");
144144
exchange.sendResponseHeaders(HttpStatus.SC_OK, responseBody.length);
145145
exchange.getResponseBody().write(responseBody);
146+
exchange.getResponseBody().flush();
146147
return;
147148
}
148149
}
@@ -159,14 +160,14 @@ protected List<TransportAddress> buildDynamicHosts(Settings nodeSettings, int no
159160
}
160161
}
161162

162-
public void testDefaultSettings() throws InterruptedException {
163+
public void testDefaultSettings() {
163164
int nodes = randomInt(10);
164165
Settings nodeSettings = Settings.builder().build();
165166
List<TransportAddress> discoveryNodes = buildDynamicHosts(nodeSettings, nodes);
166167
assertThat(discoveryNodes, hasSize(nodes));
167168
}
168169

169-
public void testPrivateIp() throws InterruptedException {
170+
public void testPrivateIp() {
170171
int nodes = randomInt(10);
171172
for (int i = 0; i < nodes; i++) {
172173
poorMansDNS.put(PREFIX_PRIVATE_IP + (i + 1), buildNewFakeTransportAddress());
@@ -182,7 +183,7 @@ public void testPrivateIp() throws InterruptedException {
182183
}
183184
}
184185

185-
public void testPublicIp() throws InterruptedException {
186+
public void testPublicIp() {
186187
int nodes = randomInt(10);
187188
for (int i = 0; i < nodes; i++) {
188189
poorMansDNS.put(PREFIX_PUBLIC_IP + (i + 1), buildNewFakeTransportAddress());
@@ -198,7 +199,7 @@ public void testPublicIp() throws InterruptedException {
198199
}
199200
}
200201

201-
public void testPrivateDns() throws InterruptedException {
202+
public void testPrivateDns() {
202203
int nodes = randomInt(10);
203204
for (int i = 0; i < nodes; i++) {
204205
String instanceId = "node" + (i + 1);
@@ -216,7 +217,7 @@ public void testPrivateDns() throws InterruptedException {
216217
}
217218
}
218219

219-
public void testPublicDns() throws InterruptedException {
220+
public void testPublicDns() {
220221
int nodes = randomInt(10);
221222
for (int i = 0; i < nodes; i++) {
222223
String instanceId = "node" + (i + 1);
@@ -234,14 +235,14 @@ public void testPublicDns() throws InterruptedException {
234235
}
235236
}
236237

237-
public void testInvalidHostType() throws InterruptedException {
238+
public void testInvalidHostType() {
238239
Settings nodeSettings = Settings.builder().put(AwsEc2Service.HOST_TYPE_SETTING.getKey(), "does_not_exist").build();
239240

240241
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> { buildDynamicHosts(nodeSettings, 1); });
241242
assertThat(exception.getMessage(), containsString("does_not_exist is unknown for discovery.ec2.host_type"));
242243
}
243244

244-
public void testFilterByTags() throws InterruptedException {
245+
public void testFilterByTags() {
245246
int nodes = randomIntBetween(5, 10);
246247
Settings nodeSettings = Settings.builder().put(AwsEc2Service.TAG_SETTING.getKey() + "stage", "prod").build();
247248

@@ -264,7 +265,7 @@ public void testFilterByTags() throws InterruptedException {
264265
assertThat(dynamicHosts, hasSize(prodInstances));
265266
}
266267

267-
public void testFilterByMultipleTags() throws InterruptedException {
268+
public void testFilterByMultipleTags() {
268269
int nodes = randomIntBetween(5, 10);
269270
Settings nodeSettings = Settings.builder().putList(AwsEc2Service.TAG_SETTING.getKey() + "stage", "prod", "preprod").build();
270271

0 commit comments

Comments
 (0)