From 3829f15d2a1babfa91a07e49a0ead9f4931aa6d0 Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Fri, 17 Mar 2023 15:41:50 -0700 Subject: [PATCH] Finally figured out the generics (or lack thereof) Signed-off-by: Daniel Widdis --- .../main/java/org/opensearch/action/ActionModule.java | 9 ++++----- .../main/java/org/opensearch/client/node/NodeClient.java | 3 +-- server/src/main/java/org/opensearch/node/Node.java | 5 +---- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/ActionModule.java b/server/src/main/java/org/opensearch/action/ActionModule.java index 1cb96a08999da..99147e213aad2 100644 --- a/server/src/main/java/org/opensearch/action/ActionModule.java +++ b/server/src/main/java/org/opensearch/action/ActionModule.java @@ -976,8 +976,7 @@ public ActionFilters getActionFilters() { return actionFilters; } - @SuppressWarnings("unchecked") - public DynamicActionRegistry getDynamicActionRegistry() { + public DynamicActionRegistry getDynamicActionRegistry() { return dynamicActionRegistry; } @@ -992,7 +991,7 @@ public RestController getRestController() { * * @opensearch.internal */ - public static class DynamicActionRegistry { + public static class DynamicActionRegistry { // the immutable map of injected transport actions private Map actions = Collections.emptyMap(); // the dynamic map which can be updated over time @@ -1058,9 +1057,9 @@ public void unregisterExtensionAction(ExtensionAction extensionAction) { * @return the corresponding {@link TransportAction} if it is registered, null otherwise. */ @SuppressWarnings("unchecked") - public TransportAction get(ActionType action) { + public TransportAction get(ActionType action) { if (action instanceof ExtensionAction) { - return (TransportAction) registry.get((ExtensionAction) action); + return registry.get((ExtensionAction) action); } return actions.get(action); } diff --git a/server/src/main/java/org/opensearch/client/node/NodeClient.java b/server/src/main/java/org/opensearch/client/node/NodeClient.java index 68d17e1af65d5..944a1fe80bcf8 100644 --- a/server/src/main/java/org/opensearch/client/node/NodeClient.java +++ b/server/src/main/java/org/opensearch/client/node/NodeClient.java @@ -146,8 +146,7 @@ private Transpo if (actionRegistry == null) { throw new IllegalStateException("NodeClient has not been initialized"); } - // Get from action map if it exists - TransportAction transportAction = actionRegistry.get(action); + TransportAction transportAction = (TransportAction) actionRegistry.get(action); if (transportAction == null) { throw new IllegalStateException("failed to find action [" + action + "] to execute"); } diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index 6363b4acf63a9..8b9f2758b847f 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -59,8 +59,6 @@ import org.opensearch.Version; import org.opensearch.action.ActionModule; import org.opensearch.action.ActionModule.DynamicActionRegistry; -import org.opensearch.action.ActionRequest; -import org.opensearch.action.ActionResponse; import org.opensearch.action.ActionType; import org.opensearch.action.admin.cluster.snapshots.status.TransportNodesSnapshotsStatus; import org.opensearch.action.search.SearchExecutionStatsCollector; @@ -1115,8 +1113,7 @@ protected Node( resourcesToClose.addAll(pluginLifecycleComponents); resourcesToClose.add(injector.getInstance(PeerRecoverySourceService.class)); this.pluginLifecycleComponents = Collections.unmodifiableList(pluginLifecycleComponents); - DynamicActionRegistry dynamicActionRegistry = actionModule - .getDynamicActionRegistry(); + DynamicActionRegistry dynamicActionRegistry = actionModule.getDynamicActionRegistry(); dynamicActionRegistry.initialize(injector.getInstance(new Key>() { }), actionModule.getActionFilters(), transportService, extensionsManager); client.initialize(