Skip to content

Commit 351cae0

Browse files
Delete unused response-deserialization code
With the transport client gone, lots of these constructors have become unused. Removing this dead code also allows making a lot of fields final as an added bonus.
1 parent 0f3ac36 commit 351cae0

File tree

78 files changed

+247
-539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+247
-539
lines changed

modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateResponse.java

-21
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.elasticsearch.action.ActionResponse;
1515
import org.elasticsearch.common.Strings;
1616
import org.elasticsearch.common.collect.Iterators;
17-
import org.elasticsearch.common.io.stream.StreamInput;
1817
import org.elasticsearch.common.io.stream.StreamOutput;
1918
import org.elasticsearch.common.io.stream.Writeable;
2019
import org.elasticsearch.core.AbstractRefCounted;
@@ -38,16 +37,6 @@ public static class Item implements Writeable {
3837
private final SearchTemplateResponse response;
3938
private final Exception exception;
4039

41-
private Item(StreamInput in) throws IOException {
42-
if (in.readBoolean()) {
43-
this.response = new SearchTemplateResponse(in);
44-
this.exception = null;
45-
} else {
46-
exception = in.readException();
47-
this.response = null;
48-
}
49-
}
50-
5140
public Item(SearchTemplateResponse response, Exception exception) {
5241
this.response = response;
5342
this.exception = exception;
@@ -114,16 +103,6 @@ protected void closeInternal() {
114103
}
115104
});
116105

117-
MultiSearchTemplateResponse(StreamInput in) throws IOException {
118-
super(in);
119-
items = in.readArray(Item::new, Item[]::new);
120-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_0_0)) {
121-
tookInMillis = in.readVLong();
122-
} else {
123-
tookInMillis = -1L;
124-
}
125-
}
126-
127106
MultiSearchTemplateResponse(Item[] items, long tookInMillis) {
128107
this.items = items;
129108
this.tookInMillis = tookInMillis;

modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateResponse.java

-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.elasticsearch.action.ActionResponse;
1212
import org.elasticsearch.action.search.SearchResponse;
1313
import org.elasticsearch.common.bytes.BytesReference;
14-
import org.elasticsearch.common.io.stream.StreamInput;
1514
import org.elasticsearch.common.io.stream.StreamOutput;
1615
import org.elasticsearch.common.xcontent.ChunkedToXContent;
1716
import org.elasticsearch.core.AbstractRefCounted;
@@ -46,12 +45,6 @@ protected void closeInternal() {
4645

4746
SearchTemplateResponse() {}
4847

49-
SearchTemplateResponse(StreamInput in) throws IOException {
50-
super(in);
51-
source = in.readOptionalBytesReference();
52-
response = in.readOptionalWriteable(SearchResponse::new);
53-
}
54-
5548
public BytesReference getSource() {
5649
return source;
5750
}

modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextAction.java

-6
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ public Response(List<String> scriptContextNames, PainlessContextInfo painlessCon
108108
this.painlessContextInfo = painlessContextInfo;
109109
}
110110

111-
public Response(StreamInput in) throws IOException {
112-
super(in);
113-
scriptContextNames = in.readStringCollectionAsList();
114-
painlessContextInfo = in.readOptionalWriteable(PainlessContextInfo::new);
115-
}
116-
117111
@Override
118112
public void writeTo(StreamOutput out) throws IOException {
119113
out.writeStringCollection(scriptContextNames);

modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessExecuteAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ static boolean needDocumentAndIndex(ScriptContext<?> scriptContext) {
462462

463463
public static class Response extends ActionResponse implements ToXContentObject {
464464

465-
private Object result;
465+
private final Object result;
466466

467467
Response(Object result) {
468468
this.result = result;

modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalResponse.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
public class RankEvalResponse extends ActionResponse implements ToXContentObject {
3131

3232
/** The overall evaluation result. */
33-
private double metricScore;
33+
private final double metricScore;
3434
/** details about individual ranking evaluation queries, keyed by their id */
35-
private Map<String, EvalQueryQuality> details;
35+
private final Map<String, EvalQueryQuality> details;
3636
/** exceptions for specific ranking evaluation queries, keyed by their id */
37-
private Map<String, Exception> failures;
37+
private final Map<String, Exception> failures;
3838

3939
public RankEvalResponse(double metricScore, Map<String, EvalQueryQuality> partialResults, Map<String, Exception> failures) {
4040
this.metricScore = metricScore;

server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
public class ClusterAllocationExplainResponse extends ActionResponse implements ChunkedToXContentObject {
2424

25-
private ClusterAllocationExplanation cae;
25+
private final ClusterAllocationExplanation cae;
2626

2727
public ClusterAllocationExplainResponse(StreamInput in) throws IOException {
2828
super(in);

server/src/main/java/org/elasticsearch/action/admin/cluster/remote/RemoteInfoResponse.java

-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package org.elasticsearch.action.admin.cluster.remote;
1010

1111
import org.elasticsearch.action.ActionResponse;
12-
import org.elasticsearch.common.io.stream.StreamInput;
1312
import org.elasticsearch.common.io.stream.StreamOutput;
1413
import org.elasticsearch.transport.RemoteConnectionInfo;
1514
import org.elasticsearch.xcontent.ToXContentObject;
@@ -23,11 +22,6 @@ public final class RemoteInfoResponse extends ActionResponse implements ToXConte
2322

2423
private final List<RemoteConnectionInfo> infos;
2524

26-
RemoteInfoResponse(StreamInput in) throws IOException {
27-
super(in);
28-
infos = in.readCollectionAsImmutableList(RemoteConnectionInfo::new);
29-
}
30-
3125
public RemoteInfoResponse(Collection<RemoteConnectionInfo> infos) {
3226
this.infos = List.copyOf(infos);
3327
}

server/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
*/
2424
public class ClusterStateResponse extends ActionResponse {
2525

26-
private ClusterName clusterName;
27-
private ClusterState clusterState;
28-
private boolean waitForTimedOut = false;
26+
private final ClusterName clusterName;
27+
private final ClusterState clusterState;
28+
private final boolean waitForTimedOut;
2929

3030
public ClusterStateResponse(StreamInput in) throws IOException {
3131
super(in);

server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public class GetStoredScriptResponse extends ActionResponse implements ToXConten
2626
public static final ParseField FOUND_PARSE_FIELD = new ParseField("found");
2727
public static final ParseField SCRIPT = new ParseField("script");
2828

29-
private String id;
30-
private StoredScriptSource source;
29+
private final String id;
30+
private final StoredScriptSource source;
3131

3232
public GetStoredScriptResponse(StreamInput in) throws IOException {
3333
super(in);

server/src/main/java/org/elasticsearch/action/get/MultiGetItemResponse.java

-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
package org.elasticsearch.action.get;
1010

11-
import org.elasticsearch.common.io.stream.StreamInput;
1211
import org.elasticsearch.common.io.stream.StreamOutput;
1312
import org.elasticsearch.common.io.stream.Writeable;
1413

@@ -27,16 +26,6 @@ public MultiGetItemResponse(GetResponse response, MultiGetResponse.Failure failu
2726
this.failure = failure;
2827
}
2928

30-
MultiGetItemResponse(StreamInput in) throws IOException {
31-
if (in.readBoolean()) {
32-
failure = new MultiGetResponse.Failure(in);
33-
response = null;
34-
} else {
35-
response = new GetResponse(in);
36-
failure = null;
37-
}
38-
}
39-
4029
/**
4130
* The index name of the document.
4231
*/

server/src/main/java/org/elasticsearch/action/get/MultiGetResponse.java

-5
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ public MultiGetResponse(MultiGetItemResponse[] responses) {
109109
this.responses = responses;
110110
}
111111

112-
MultiGetResponse(StreamInput in) throws IOException {
113-
super(in);
114-
responses = in.readArray(MultiGetItemResponse::new, MultiGetItemResponse[]::new);
115-
}
116-
117112
public MultiGetItemResponse[] getResponses() {
118113
return this.responses;
119114
}

server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import java.util.List;
2121

2222
public class SimulatePipelineResponse extends ActionResponse implements ToXContentObject {
23-
private String pipelineId;
23+
private final String pipelineId;
2424
private boolean verbose;
25-
private List<SimulateDocumentResult> results;
25+
private final List<SimulateDocumentResult> results;
2626

2727
public SimulatePipelineResponse(StreamInput in) throws IOException {
2828
super(in);

server/src/main/java/org/elasticsearch/action/search/ClearScrollResponse.java

-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package org.elasticsearch.action.search;
1010

1111
import org.elasticsearch.action.ActionResponse;
12-
import org.elasticsearch.common.io.stream.StreamInput;
1312
import org.elasticsearch.common.io.stream.StreamOutput;
1413
import org.elasticsearch.rest.RestStatus;
1514
import org.elasticsearch.xcontent.ParseField;
@@ -34,12 +33,6 @@ public ClearScrollResponse(boolean succeeded, int numFreed) {
3433
this.numFreed = numFreed;
3534
}
3635

37-
public ClearScrollResponse(StreamInput in) throws IOException {
38-
super(in);
39-
succeeded = in.readBoolean();
40-
numFreed = in.readVInt();
41-
}
42-
4336
/**
4437
* @return Whether the attempt to clear a scroll was successful.
4538
*/

server/src/main/java/org/elasticsearch/action/search/ClosePointInTimeResponse.java

-7
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88

99
package org.elasticsearch.action.search;
1010

11-
import org.elasticsearch.common.io.stream.StreamInput;
1211
import org.elasticsearch.rest.RestStatus;
1312

14-
import java.io.IOException;
15-
1613
import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
1714
import static org.elasticsearch.rest.RestStatus.OK;
1815

@@ -21,10 +18,6 @@ public ClosePointInTimeResponse(boolean succeeded, int numFreed) {
2118
super(succeeded, numFreed);
2219
}
2320

24-
public ClosePointInTimeResponse(StreamInput in) throws IOException {
25-
super(in);
26-
}
27-
2821
@Override
2922
public RestStatus status() {
3023
if (isSucceeded() || getNumFreed() > 0) {

server/src/main/java/org/elasticsearch/action/search/OpenPointInTimeResponse.java

-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package org.elasticsearch.action.search;
1010

1111
import org.elasticsearch.action.ActionResponse;
12-
import org.elasticsearch.common.io.stream.StreamInput;
1312
import org.elasticsearch.common.io.stream.StreamOutput;
1413
import org.elasticsearch.xcontent.ToXContentObject;
1514
import org.elasticsearch.xcontent.XContentBuilder;
@@ -24,11 +23,6 @@ public OpenPointInTimeResponse(String pointInTimeId) {
2423
this.pointInTimeId = Objects.requireNonNull(pointInTimeId, "Point in time parameter must be not null");
2524
}
2625

27-
public OpenPointInTimeResponse(StreamInput in) throws IOException {
28-
super(in);
29-
pointInTimeId = in.readString();
30-
}
31-
3226
@Override
3327
public void writeTo(StreamOutput out) throws IOException {
3428
out.writeString(pointInTimeId);

server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1183,8 +1183,8 @@ public PendingReplicationActions getPendingReplicationActions() {
11831183
}
11841184

11851185
public static class ReplicaResponse extends ActionResponse implements ReplicationOperation.ReplicaResponse {
1186-
private long localCheckpoint;
1187-
private long globalCheckpoint;
1186+
private final long localCheckpoint;
1187+
private final long globalCheckpoint;
11881188

11891189
ReplicaResponse(StreamInput in) throws IOException {
11901190
super(in);

server/src/main/java/org/elasticsearch/action/support/tasks/BaseTasksResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public class BaseTasksResponse extends ActionResponse {
3535
public static final String TASK_FAILURES = "task_failures";
3636
public static final String NODE_FAILURES = "node_failures";
3737

38-
private List<TaskOperationFailure> taskFailures;
39-
private List<ElasticsearchException> nodeFailures;
38+
private final List<TaskOperationFailure> taskFailures;
39+
private final List<ElasticsearchException> nodeFailures;
4040

4141
public BaseTasksResponse(List<TaskOperationFailure> taskFailures, List<? extends ElasticsearchException> nodeFailures) {
4242
this.taskFailures = taskFailures == null ? Collections.emptyList() : List.copyOf(taskFailures);

server/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsResponse.java

-5
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ public MultiTermVectorsResponse(MultiTermVectorsItemResponse[] responses) {
9191
this.responses = responses;
9292
}
9393

94-
public MultiTermVectorsResponse(StreamInput in) throws IOException {
95-
super(in);
96-
responses = in.readArray(MultiTermVectorsItemResponse::new, MultiTermVectorsItemResponse[]::new);
97-
}
98-
9994
public MultiTermVectorsItemResponse[] getResponses() {
10095
return this.responses;
10196
}

server/src/main/java/org/elasticsearch/index/reindex/BulkByScrollResponse.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
* Response used for actions that index many documents using a scroll request.
3131
*/
3232
public class BulkByScrollResponse extends ActionResponse implements ToXContentFragment {
33-
private TimeValue took;
34-
private BulkByScrollTask.Status status;
35-
private List<Failure> bulkFailures;
36-
private List<ScrollableHitSource.SearchFailure> searchFailures;
33+
private final TimeValue took;
34+
private final BulkByScrollTask.Status status;
35+
private final List<Failure> bulkFailures;
36+
private final List<ScrollableHitSource.SearchFailure> searchFailures;
3737
private boolean timedOut;
3838

3939
static final String TOOK_FIELD = "took";

server/src/main/java/org/elasticsearch/persistent/PersistentTaskResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Response upon a successful start or an persistent task
2020
*/
2121
public class PersistentTaskResponse extends ActionResponse {
22-
private PersistentTask<?> task;
22+
private final PersistentTask<?> task;
2323

2424
public PersistentTaskResponse(StreamInput in) throws IOException {
2525
super(in);

x-pack/plugin/core/src/main/java/org/elasticsearch/license/GetBasicStatusResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
public class GetBasicStatusResponse extends ActionResponse implements ToXContentObject {
1919

20-
private boolean eligibleToStartBasic;
20+
private final boolean eligibleToStartBasic;
2121

2222
GetBasicStatusResponse(StreamInput in) throws IOException {
2323
super(in);

x-pack/plugin/core/src/main/java/org/elasticsearch/license/GetTrialStatusResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
public class GetTrialStatusResponse extends ActionResponse implements ToXContentObject {
1919

20-
private boolean eligibleToStartTrial;
20+
private final boolean eligibleToStartTrial;
2121

2222
GetTrialStatusResponse(StreamInput in) throws IOException {
2323
super(in);

x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartTrialResponse.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ RestStatus getRestStatus() {
4848

4949
}
5050

51-
private Status status;
52-
private Map<String, String[]> acknowledgeMessages;
53-
private String acknowledgeMessage;
51+
private final Status status;
52+
private final Map<String, String[]> acknowledgeMessages;
53+
private final String acknowledgeMessage;
5454

5555
PostStartTrialResponse(StreamInput in) throws IOException {
5656
super(in);

x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/XPackInfoResponse.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public class XPackInfoResponse extends ActionResponse implements ToXContentObjec
3838
// TODO move this constant to License.java once we move License.java to the protocol jar
3939

4040
@Nullable
41-
private BuildInfo buildInfo;
41+
private final BuildInfo buildInfo;
4242
@Nullable
43-
private LicenseInfo licenseInfo;
43+
private final LicenseInfo licenseInfo;
4444
@Nullable
45-
private FeatureSetsInfo featureSetsInfo;
45+
private final FeatureSetsInfo featureSetsInfo;
4646

4747
public XPackInfoResponse(StreamInput in) throws IOException {
4848
super(in);

0 commit comments

Comments
 (0)