Skip to content

Commit 991e80d

Browse files
authored
Remove unnecessary generic params from action classes (#126364)
Transport actions have associated request and response classes. However, the base type restrictions are not necessary to duplicate when creating a map of transport actions. Relatedly, the ActionHandler class doesn't actually need strongly typed action type and classes since they are lost when shoved into the node client map. This commit removes these type restrictions and generic parameters.
1 parent 9feac78 commit 991e80d

File tree

77 files changed

+627
-780
lines changed

Some content is hidden

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

77 files changed

+627
-780
lines changed

client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/NoopPlugin.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
*/
99
package org.elasticsearch.plugin.noop;
1010

11-
import org.elasticsearch.action.ActionRequest;
12-
import org.elasticsearch.action.ActionResponse;
1311
import org.elasticsearch.action.ActionType;
1412
import org.elasticsearch.action.bulk.BulkResponse;
1513
import org.elasticsearch.action.search.SearchResponse;
@@ -41,10 +39,10 @@ public class NoopPlugin extends Plugin implements ActionPlugin {
4139
public static final ActionType<BulkResponse> NOOP_BULK_ACTION = new ActionType<>("mock:data/write/bulk");
4240

4341
@Override
44-
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
42+
public List<ActionHandler> getActions() {
4543
return Arrays.asList(
46-
new ActionHandler<>(NOOP_BULK_ACTION, TransportNoopBulkAction.class),
47-
new ActionHandler<>(NOOP_SEARCH_ACTION, TransportNoopSearchAction.class)
44+
new ActionHandler(NOOP_BULK_ACTION, TransportNoopBulkAction.class),
45+
new ActionHandler(NOOP_SEARCH_ACTION, TransportNoopSearchAction.class)
4846
);
4947
}
5048

modules/data-streams/src/main/java/org/elasticsearch/datastreams/DataStreamsPlugin.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
import org.apache.lucene.util.SetOnce;
1212
import org.elasticsearch.ElasticsearchException;
13-
import org.elasticsearch.action.ActionRequest;
14-
import org.elasticsearch.action.ActionResponse;
1513
import org.elasticsearch.action.datastreams.CreateDataStreamAction;
1614
import org.elasticsearch.action.datastreams.DataStreamsStatsAction;
1715
import org.elasticsearch.action.datastreams.DeleteDataStreamAction;
@@ -225,24 +223,24 @@ public Collection<?> createComponents(PluginServices services) {
225223
}
226224

227225
@Override
228-
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
229-
List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> actions = new ArrayList<>();
230-
actions.add(new ActionHandler<>(CreateDataStreamAction.INSTANCE, CreateDataStreamTransportAction.class));
231-
actions.add(new ActionHandler<>(DeleteDataStreamAction.INSTANCE, DeleteDataStreamTransportAction.class));
232-
actions.add(new ActionHandler<>(GetDataStreamAction.INSTANCE, TransportGetDataStreamsAction.class));
233-
actions.add(new ActionHandler<>(DataStreamsStatsAction.INSTANCE, DataStreamsStatsTransportAction.class));
234-
actions.add(new ActionHandler<>(MigrateToDataStreamAction.INSTANCE, MigrateToDataStreamTransportAction.class));
235-
actions.add(new ActionHandler<>(PromoteDataStreamAction.INSTANCE, PromoteDataStreamTransportAction.class));
236-
actions.add(new ActionHandler<>(ModifyDataStreamsAction.INSTANCE, ModifyDataStreamsTransportAction.class));
237-
actions.add(new ActionHandler<>(PutDataStreamLifecycleAction.INSTANCE, TransportPutDataStreamLifecycleAction.class));
238-
actions.add(new ActionHandler<>(GetDataStreamLifecycleAction.INSTANCE, TransportGetDataStreamLifecycleAction.class));
239-
actions.add(new ActionHandler<>(DeleteDataStreamLifecycleAction.INSTANCE, TransportDeleteDataStreamLifecycleAction.class));
240-
actions.add(new ActionHandler<>(ExplainDataStreamLifecycleAction.INSTANCE, TransportExplainDataStreamLifecycleAction.class));
241-
actions.add(new ActionHandler<>(GetDataStreamLifecycleStatsAction.INSTANCE, TransportGetDataStreamLifecycleStatsAction.class));
226+
public List<ActionHandler> getActions() {
227+
List<ActionHandler> actions = new ArrayList<>();
228+
actions.add(new ActionHandler(CreateDataStreamAction.INSTANCE, CreateDataStreamTransportAction.class));
229+
actions.add(new ActionHandler(DeleteDataStreamAction.INSTANCE, DeleteDataStreamTransportAction.class));
230+
actions.add(new ActionHandler(GetDataStreamAction.INSTANCE, TransportGetDataStreamsAction.class));
231+
actions.add(new ActionHandler(DataStreamsStatsAction.INSTANCE, DataStreamsStatsTransportAction.class));
232+
actions.add(new ActionHandler(MigrateToDataStreamAction.INSTANCE, MigrateToDataStreamTransportAction.class));
233+
actions.add(new ActionHandler(PromoteDataStreamAction.INSTANCE, PromoteDataStreamTransportAction.class));
234+
actions.add(new ActionHandler(ModifyDataStreamsAction.INSTANCE, ModifyDataStreamsTransportAction.class));
235+
actions.add(new ActionHandler(PutDataStreamLifecycleAction.INSTANCE, TransportPutDataStreamLifecycleAction.class));
236+
actions.add(new ActionHandler(GetDataStreamLifecycleAction.INSTANCE, TransportGetDataStreamLifecycleAction.class));
237+
actions.add(new ActionHandler(DeleteDataStreamLifecycleAction.INSTANCE, TransportDeleteDataStreamLifecycleAction.class));
238+
actions.add(new ActionHandler(ExplainDataStreamLifecycleAction.INSTANCE, TransportExplainDataStreamLifecycleAction.class));
239+
actions.add(new ActionHandler(GetDataStreamLifecycleStatsAction.INSTANCE, TransportGetDataStreamLifecycleStatsAction.class));
242240
if (DataStream.isFailureStoreFeatureFlagEnabled()) {
243-
actions.add(new ActionHandler<>(GetDataStreamOptionsAction.INSTANCE, TransportGetDataStreamOptionsAction.class));
244-
actions.add(new ActionHandler<>(PutDataStreamOptionsAction.INSTANCE, TransportPutDataStreamOptionsAction.class));
245-
actions.add(new ActionHandler<>(DeleteDataStreamOptionsAction.INSTANCE, TransportDeleteDataStreamOptionsAction.class));
241+
actions.add(new ActionHandler(GetDataStreamOptionsAction.INSTANCE, TransportGetDataStreamOptionsAction.class));
242+
actions.add(new ActionHandler(PutDataStreamOptionsAction.INSTANCE, TransportPutDataStreamOptionsAction.class));
243+
actions.add(new ActionHandler(DeleteDataStreamOptionsAction.INSTANCE, TransportDeleteDataStreamOptionsAction.class));
246244
}
247245
return actions;
248246
}

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/IngestCommonPlugin.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.ingest.common;
1111

12-
import org.elasticsearch.action.ActionRequest;
13-
import org.elasticsearch.action.ActionResponse;
1412
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1513
import org.elasticsearch.cluster.node.DiscoveryNodes;
1614
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
@@ -81,8 +79,8 @@ public Map<String, Processor.Factory> getProcessors(Processor.Parameters paramet
8179
}
8280

8381
@Override
84-
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
85-
return List.of(new ActionHandler<>(GrokProcessorGetAction.INSTANCE, GrokProcessorGetAction.TransportAction.class));
82+
public List<ActionHandler> getActions() {
83+
return List.of(new ActionHandler(GrokProcessorGetAction.INSTANCE, GrokProcessorGetAction.TransportAction.class));
8684
}
8785

8886
@Override

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/IngestGeoIpPlugin.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
package org.elasticsearch.ingest.geoip;
1111

1212
import org.apache.lucene.util.SetOnce;
13-
import org.elasticsearch.action.ActionRequest;
14-
import org.elasticsearch.action.ActionResponse;
1513
import org.elasticsearch.client.internal.Client;
1614
import org.elasticsearch.cluster.NamedDiff;
1715
import org.elasticsearch.cluster.metadata.IndexMetadata;
@@ -182,12 +180,12 @@ public List<PersistentTasksExecutor<?>> getPersistentTasksExecutor(
182180
}
183181

184182
@Override
185-
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
183+
public List<ActionHandler> getActions() {
186184
return List.of(
187-
new ActionHandler<>(GeoIpStatsAction.INSTANCE, GeoIpStatsTransportAction.class),
188-
new ActionHandler<>(GetDatabaseConfigurationAction.INSTANCE, TransportGetDatabaseConfigurationAction.class),
189-
new ActionHandler<>(DeleteDatabaseConfigurationAction.INSTANCE, TransportDeleteDatabaseConfigurationAction.class),
190-
new ActionHandler<>(PutDatabaseConfigurationAction.INSTANCE, TransportPutDatabaseConfigurationAction.class)
185+
new ActionHandler(GeoIpStatsAction.INSTANCE, GeoIpStatsTransportAction.class),
186+
new ActionHandler(GetDatabaseConfigurationAction.INSTANCE, TransportGetDatabaseConfigurationAction.class),
187+
new ActionHandler(DeleteDatabaseConfigurationAction.INSTANCE, TransportDeleteDatabaseConfigurationAction.class),
188+
new ActionHandler(PutDatabaseConfigurationAction.INSTANCE, TransportPutDatabaseConfigurationAction.class)
191189
);
192190
}
193191

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.script.mustache;
1111

12-
import org.elasticsearch.action.ActionRequest;
13-
import org.elasticsearch.action.ActionResponse;
1412
import org.elasticsearch.action.ActionType;
1513
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1614
import org.elasticsearch.cluster.node.DiscoveryNodes;
@@ -49,10 +47,10 @@ public ScriptEngine getScriptEngine(Settings settings, Collection<ScriptContext<
4947
}
5048

5149
@Override
52-
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
50+
public List<ActionHandler> getActions() {
5351
return Arrays.asList(
54-
new ActionHandler<>(SEARCH_TEMPLATE_ACTION, TransportSearchTemplateAction.class),
55-
new ActionHandler<>(MULTI_SEARCH_TEMPLATE_ACTION, TransportMultiSearchTemplateAction.class)
52+
new ActionHandler(SEARCH_TEMPLATE_ACTION, TransportSearchTemplateAction.class),
53+
new ActionHandler(MULTI_SEARCH_TEMPLATE_ACTION, TransportMultiSearchTemplateAction.class)
5654
);
5755
}
5856

modules/lang-painless/src/main/java/org/elasticsearch/painless/PainlessPlugin.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
package org.elasticsearch.painless;
1111

1212
import org.apache.lucene.util.SetOnce;
13-
import org.elasticsearch.action.ActionRequest;
14-
import org.elasticsearch.action.ActionResponse;
1513
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1614
import org.elasticsearch.cluster.node.DiscoveryNodes;
1715
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
@@ -164,10 +162,10 @@ public List<ScriptContext<?>> getContexts() {
164162
}
165163

166164
@Override
167-
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
168-
List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> actions = new ArrayList<>();
169-
actions.add(new ActionHandler<>(PainlessExecuteAction.INSTANCE, PainlessExecuteAction.TransportAction.class));
170-
actions.add(new ActionHandler<>(PainlessContextAction.INSTANCE, PainlessContextAction.TransportAction.class));
165+
public List<ActionHandler> getActions() {
166+
List<ActionHandler> actions = new ArrayList<>();
167+
actions.add(new ActionHandler(PainlessExecuteAction.INSTANCE, PainlessExecuteAction.TransportAction.class));
168+
actions.add(new ActionHandler(PainlessContextAction.INSTANCE, PainlessContextAction.TransportAction.class));
171169
return actions;
172170
}
173171

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.index.rankeval;
1111

12-
import org.elasticsearch.action.ActionRequest;
13-
import org.elasticsearch.action.ActionResponse;
1412
import org.elasticsearch.action.ActionType;
1513
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1614
import org.elasticsearch.cluster.node.DiscoveryNodes;
@@ -38,8 +36,8 @@ public class RankEvalPlugin extends Plugin implements ActionPlugin {
3836
public static final ActionType<RankEvalResponse> ACTION = new ActionType<>("indices:data/read/rank_eval");
3937

4038
@Override
41-
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
42-
return Arrays.asList(new ActionHandler<>(ACTION, TransportRankEvalAction.class));
39+
public List<ActionHandler> getActions() {
40+
return Arrays.asList(new ActionHandler(ACTION, TransportRankEvalAction.class));
4341
}
4442

4543
@Override

modules/reindex/src/main/java/org/elasticsearch/reindex/ReindexPlugin.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.reindex;
1111

12-
import org.elasticsearch.action.ActionRequest;
13-
import org.elasticsearch.action.ActionResponse;
1412
import org.elasticsearch.action.ActionType;
1513
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
1614
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
@@ -47,12 +45,12 @@ public class ReindexPlugin extends Plugin implements ActionPlugin {
4745
public static final ActionType<ListTasksResponse> RETHROTTLE_ACTION = new ActionType<>("cluster:admin/reindex/rethrottle");
4846

4947
@Override
50-
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
48+
public List<ActionHandler> getActions() {
5149
return Arrays.asList(
52-
new ActionHandler<>(ReindexAction.INSTANCE, TransportReindexAction.class),
53-
new ActionHandler<>(UpdateByQueryAction.INSTANCE, TransportUpdateByQueryAction.class),
54-
new ActionHandler<>(DeleteByQueryAction.INSTANCE, TransportDeleteByQueryAction.class),
55-
new ActionHandler<>(RETHROTTLE_ACTION, TransportRethrottleAction.class)
50+
new ActionHandler(ReindexAction.INSTANCE, TransportReindexAction.class),
51+
new ActionHandler(UpdateByQueryAction.INSTANCE, TransportUpdateByQueryAction.class),
52+
new ActionHandler(DeleteByQueryAction.INSTANCE, TransportDeleteByQueryAction.class),
53+
new ActionHandler(RETHROTTLE_ACTION, TransportRethrottleAction.class)
5654
);
5755
}
5856

modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainRestPlugin.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.rest.root;
1111

12-
import org.elasticsearch.action.ActionRequest;
13-
import org.elasticsearch.action.ActionResponse;
1412
import org.elasticsearch.action.ActionType;
1513
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1614
import org.elasticsearch.cluster.node.DiscoveryNodes;
@@ -49,7 +47,7 @@ public List<RestHandler> getRestHandlers(
4947
}
5048

5149
@Override
52-
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
53-
return List.of(new ActionHandler<>(MAIN_ACTION, TransportMainAction.class));
50+
public List<ActionHandler> getActions() {
51+
return List.of(new ActionHandler(MAIN_ACTION, TransportMainAction.class));
5452
}
5553
}

modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/http/netty4/Netty4ChunkedContinuationsIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ public static class YieldsContinuationsPlugin extends Plugin implements ActionPl
340340
private static final ActionType<YieldsContinuationsPlugin.Response> TYPE = new ActionType<>("test:yields_continuations");
341341

342342
@Override
343-
public Collection<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
344-
return List.of(new ActionHandler<>(TYPE, TransportYieldsContinuationsAction.class));
343+
public Collection<ActionHandler> getActions() {
344+
return List.of(new ActionHandler(TYPE, TransportYieldsContinuationsAction.class));
345345
}
346346

347347
public static class Request extends ActionRequest {
@@ -521,8 +521,8 @@ public static class InfiniteContinuationsPlugin extends Plugin implements Action
521521
private static final ActionType<Response> TYPE = new ActionType<>("test:infinite_continuations");
522522

523523
@Override
524-
public Collection<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
525-
return List.of(new ActionHandler<>(TYPE, TransportInfiniteContinuationsAction.class));
524+
public Collection<ActionHandler> getActions() {
525+
return List.of(new ActionHandler(TYPE, TransportInfiniteContinuationsAction.class));
526526
}
527527

528528
public static class Request extends ActionRequest {

0 commit comments

Comments
 (0)