Skip to content

Commit 3c680f2

Browse files
committed
Remove unused FakeRestChannel#latch (#144837)
If a latch counts down but nobody awaits it, does it make a sound?
1 parent adefa25 commit 3c680f2

25 files changed

+41
-46
lines changed

server/src/test/java/org/elasticsearch/action/synonyms/PutSynonymRuleActionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void testEmptyRequestBody() throws Exception {
2626
.withParams(Map.of("synonymsSet", "testSet", "synonymRuleId", "testRule"))
2727
.build();
2828

29-
FakeRestChannel channel = new FakeRestChannel(request, true, 0);
29+
FakeRestChannel channel = new FakeRestChannel(request, true);
3030
try (var threadPool = createThreadPool()) {
3131
final var nodeClient = new NoOpNodeClient(threadPool);
3232
expectThrows(IllegalArgumentException.class, () -> action.handleRequest(request, channel, nodeClient));

server/src/test/java/org/elasticsearch/action/synonyms/PutSynonymsActionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void testEmptyRequestBody() throws Exception {
2626
.withParams(Map.of("synonymsSet", "test"))
2727
.build();
2828

29-
FakeRestChannel channel = new FakeRestChannel(request, true, 0);
29+
FakeRestChannel channel = new FakeRestChannel(request, true);
3030
try (var threadPool = createThreadPool()) {
3131
final var nodeClient = new NoOpNodeClient(threadPool);
3232
expectThrows(IllegalArgumentException.class, () -> action.handleRequest(request, channel, nodeClient));

server/src/test/java/org/elasticsearch/rest/BaseRestHandlerTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public List<Route> routes() {
7373
params.put("consumed", randomAlphaOfLength(8));
7474
params.put("unconsumed", randomAlphaOfLength(8));
7575
RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build();
76-
RestChannel channel = new FakeRestChannel(request, true, 1);
76+
RestChannel channel = new FakeRestChannel(request, true);
7777
final IllegalArgumentException e = expectThrows(
7878
IllegalArgumentException.class,
7979
() -> handler.handleRequest(request, channel, mockClient)
@@ -108,7 +108,7 @@ public List<Route> routes() {
108108
params.put("unconsumed-first", randomAlphaOfLength(8));
109109
params.put("unconsumed-second", randomAlphaOfLength(8));
110110
RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build();
111-
RestChannel channel = new FakeRestChannel(request, true, 1);
111+
RestChannel channel = new FakeRestChannel(request, true);
112112
final IllegalArgumentException e = expectThrows(
113113
IllegalArgumentException.class,
114114
() -> handler.handleRequest(request, channel, mockClient)
@@ -155,7 +155,7 @@ public List<Route> routes() {
155155
params.put("very_close_to_parametre", randomAlphaOfLength(8));
156156
params.put("very_far_from_every_consumed_parameter", randomAlphaOfLength(8));
157157
RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build();
158-
RestChannel channel = new FakeRestChannel(request, true, 1);
158+
RestChannel channel = new FakeRestChannel(request, true);
159159
final IllegalArgumentException e = expectThrows(
160160
IllegalArgumentException.class,
161161
() -> handler.handleRequest(request, channel, mockClient)
@@ -206,7 +206,7 @@ public List<Route> routes() {
206206
params.put("consumed", randomAlphaOfLength(8));
207207
params.put("response_param", randomAlphaOfLength(8));
208208
RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build();
209-
RestChannel channel = new FakeRestChannel(request, true, 1);
209+
RestChannel channel = new FakeRestChannel(request, true);
210210
handler.handleRequest(request, channel, mockClient);
211211
assertTrue(restChannelConsumer.executed);
212212
assertTrue(restChannelConsumer.closed);
@@ -238,7 +238,7 @@ public List<Route> routes() {
238238
params.put("human", null);
239239
params.put("error_trace", randomFrom("true", "false", null));
240240
RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build();
241-
RestChannel channel = new FakeRestChannel(request, true, 1);
241+
RestChannel channel = new FakeRestChannel(request, true);
242242
handler.handleRequest(request, channel, mockClient);
243243
assertTrue(restChannelConsumer.executed);
244244
assertTrue(restChannelConsumer.closed);
@@ -283,7 +283,7 @@ public List<Route> routes() {
283283
params.put("size", randomAlphaOfLength(8));
284284
params.put("time", randomAlphaOfLength(8));
285285
RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build();
286-
RestChannel channel = new FakeRestChannel(request, true, 1);
286+
RestChannel channel = new FakeRestChannel(request, true);
287287
handler.handleRequest(request, channel, mockClient);
288288
assertTrue(restChannelConsumer.executed);
289289
assertTrue(restChannelConsumer.closed);
@@ -314,7 +314,7 @@ public List<Route> routes() {
314314
new BytesArray(builder.toString()),
315315
XContentType.JSON
316316
).build();
317-
final RestChannel channel = new FakeRestChannel(request, true, 1);
317+
final RestChannel channel = new FakeRestChannel(request, true);
318318
handler.handleRequest(request, channel, mockClient);
319319
assertTrue(restChannelConsumer.executed);
320320
assertTrue(restChannelConsumer.closed);
@@ -341,7 +341,7 @@ public List<Route> routes() {
341341
};
342342

343343
final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).build();
344-
final RestChannel channel = new FakeRestChannel(request, true, 1);
344+
final RestChannel channel = new FakeRestChannel(request, true);
345345
handler.handleRequest(request, channel, mockClient);
346346
assertTrue(restChannelConsumer.executed);
347347
assertTrue(restChannelConsumer.closed);
@@ -371,7 +371,7 @@ public List<Route> routes() {
371371
new BytesArray(builder.toString()),
372372
XContentType.JSON
373373
).build();
374-
final RestChannel channel = new FakeRestChannel(request, true, 1);
374+
final RestChannel channel = new FakeRestChannel(request, true);
375375
final IllegalArgumentException e = expectThrows(
376376
IllegalArgumentException.class,
377377
() -> handler.handleRequest(request, channel, mockClient)

server/src/test/java/org/elasticsearch/rest/ChunkedRestResponseBodyPartTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public void testEncodesChunkedXContentCorrectly() throws IOException {
5656
ToXContent.EMPTY_PARAMS,
5757
new FakeRestChannel(
5858
new FakeRestRequest.Builder(xContentRegistry()).withContent(BytesArray.EMPTY, randomXContent.type()).build(),
59-
true,
60-
1
59+
true
6160
)
6261
);
6362

server/src/test/java/org/elasticsearch/rest/RestHttpResponseHeadersTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void testUnsupportedMethodResponseHttpHeader() throws Exception {
9797
RestRequest restRequest = fakeRestRequestBuilder.build();
9898

9999
// Send the request and verify the response status code
100-
FakeRestChannel restChannel = new FakeRestChannel(restRequest, true, 1);
100+
FakeRestChannel restChannel = new FakeRestChannel(restRequest, true);
101101
restController.dispatchRequest(restRequest, restChannel, new ThreadContext(Settings.EMPTY));
102102
assertThat(restChannel.capturedResponse().status().getStatus(), is(405));
103103

server/src/test/java/org/elasticsearch/rest/action/RestBuilderListenerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class RestBuilderListenerTests extends ESTestCase {
2929
public void testXContentBuilderClosedInBuildResponse() throws Exception {
3030
AtomicReference<XContentBuilder> builderAtomicReference = new AtomicReference<>();
3131
RestBuilderListener<ActionResponse.Empty> builderListener = new RestBuilderListener<Empty>(
32-
new FakeRestChannel(new FakeRestRequest(), true, 1)
32+
new FakeRestChannel(new FakeRestRequest(), true)
3333
) {
3434
@Override
3535
public RestResponse buildResponse(Empty empty, XContentBuilder builder) {
@@ -47,7 +47,7 @@ public RestResponse buildResponse(Empty empty, XContentBuilder builder) {
4747
public void testXContentBuilderNotClosedInBuildResponseAssertionsDisabled() throws Exception {
4848
AtomicReference<XContentBuilder> builderAtomicReference = new AtomicReference<>();
4949
RestBuilderListener<ActionResponse.Empty> builderListener = new RestBuilderListener<Empty>(
50-
new FakeRestChannel(new FakeRestRequest(), true, 1)
50+
new FakeRestChannel(new FakeRestRequest(), true)
5151
) {
5252
@Override
5353
public RestResponse buildResponse(Empty empty, XContentBuilder builder) {
@@ -71,7 +71,7 @@ public void testXContentBuilderNotClosedInBuildResponseAssertionsEnabled() {
7171
assumeTrue("tests are not being run with assertions", RestBuilderListener.class.desiredAssertionStatus());
7272

7373
RestBuilderListener<ActionResponse.Empty> builderListener = new RestBuilderListener<Empty>(
74-
new FakeRestChannel(new FakeRestRequest(), true, 1)
74+
new FakeRestChannel(new FakeRestRequest(), true)
7575
) {
7676
@Override
7777
public RestResponse buildResponse(Empty empty, XContentBuilder builder) {

server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryActionTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void testRestValidateQueryAction() throws Exception {
110110
""";
111111

112112
final RestRequest request = createRestRequest(content);
113-
final FakeRestChannel channel = new FakeRestChannel(request, true, 0);
113+
final FakeRestChannel channel = new FakeRestChannel(request, true);
114114

115115
// WHEN
116116
action.handleRequest(request, channel, client);
@@ -126,7 +126,7 @@ public void testRestValidateQueryAction_emptyQuery() throws Exception {
126126
final String content = "{\"query\":{}}";
127127

128128
final RestRequest request = createRestRequest(content);
129-
final FakeRestChannel channel = new FakeRestChannel(request, true, 0);
129+
final FakeRestChannel channel = new FakeRestChannel(request, true);
130130

131131
// WHEN
132132
action.handleRequest(request, channel, client);
@@ -142,7 +142,7 @@ public void testRestValidateQueryAction_malformedQuery() throws Exception {
142142
final String content = "{malformed_json}";
143143

144144
final RestRequest request = createRestRequest(content);
145-
final FakeRestChannel channel = new FakeRestChannel(request, true, 0);
145+
final FakeRestChannel channel = new FakeRestChannel(request, true);
146146

147147
// WHEN
148148
action.handleRequest(request, channel, client);
@@ -188,7 +188,7 @@ public void testTypeParameter() {
188188
}
189189

190190
private void performRequest(RestRequest request) {
191-
RestChannel channel = new FakeRestChannel(request, true, 1);
191+
RestChannel channel = new FakeRestChannel(request, true);
192192
ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
193193
controller.dispatchRequest(request, channel, threadContext);
194194
}

server/src/test/java/org/elasticsearch/rest/action/cat/RestCatComponentTemplateActionTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void testRestCatComponentAction() throws Exception {
7777
FakeRestRequest getCatComponentTemplateRequest = new FakeRestRequest.Builder(xContentRegistry()).withMethod(RestRequest.Method.GET)
7878
.withPath("_cat/component_templates")
7979
.build();
80-
FakeRestChannel channel = new FakeRestChannel(getCatComponentTemplateRequest, true, 0);
80+
FakeRestChannel channel = new FakeRestChannel(getCatComponentTemplateRequest, true);
8181

8282
// execute action
8383
try (var threadPool = createThreadPool()) {
@@ -96,7 +96,7 @@ public void testRestCatComponentActionWithParam() throws Exception {
9696
.withPath("_cat/component_templates")
9797
.withParams(singletonMap("name", "test"))
9898
.build();
99-
FakeRestChannel channel = new FakeRestChannel(getCatComponentTemplateRequest, true, 0);
99+
FakeRestChannel channel = new FakeRestChannel(getCatComponentTemplateRequest, true);
100100

101101
// execute action
102102
try (var threadPool = createThreadPool()) {

server/src/test/java/org/elasticsearch/rest/action/cat/RestTasksActionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void testConsumesParameters() throws Exception {
3434
FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY).withParams(
3535
Map.of("parent_task_id", "the node:3", "nodes", "node1,node2", "actions", "*")
3636
).build();
37-
FakeRestChannel fakeRestChannel = new FakeRestChannel(fakeRestRequest, true, 1);
37+
FakeRestChannel fakeRestChannel = new FakeRestChannel(fakeRestRequest, true);
3838
try (var threadPool = createThreadPool()) {
3939
final var nodeClient = buildNodeClient(threadPool);
4040
action.handleRequest(fakeRestRequest, fakeRestChannel, nodeClient);

server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public void next() {
223223
})
224224
.withHeaders(Map.of("Content-Type", Collections.singletonList("application/json")))
225225
.build();
226-
FakeRestChannel channel = new FakeRestChannel(request, true, 1);
226+
FakeRestChannel channel = new FakeRestChannel(request, true);
227227

228228
IndexingPressure indexingPressure = new IndexingPressure(Settings.EMPTY);
229229
RestBulkAction.ChunkHandler chunkHandler = new RestBulkAction.ChunkHandler(true, request, () -> {

0 commit comments

Comments
 (0)