Skip to content

Commit

Permalink
Finally figured out the generics (or lack thereof)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Mar 17, 2023
1 parent 7893511 commit 3829f15
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
9 changes: 4 additions & 5 deletions server/src/main/java/org/opensearch/action/ActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,7 @@ public ActionFilters getActionFilters() {
return actionFilters;
}

@SuppressWarnings("unchecked")
public DynamicActionRegistry<? extends ActionRequest, ? extends ActionResponse> getDynamicActionRegistry() {
public DynamicActionRegistry getDynamicActionRegistry() {
return dynamicActionRegistry;
}

Expand All @@ -992,7 +991,7 @@ public RestController getRestController() {
*
* @opensearch.internal
*/
public static class DynamicActionRegistry<Request extends ActionRequest, Response extends ActionResponse> {
public static class DynamicActionRegistry {
// the immutable map of injected transport actions
private Map<ActionType, TransportAction> actions = Collections.emptyMap();
// the dynamic map which can be updated over time
Expand Down Expand Up @@ -1058,9 +1057,9 @@ public void unregisterExtensionAction(ExtensionAction extensionAction) {
* @return the corresponding {@link TransportAction} if it is registered, null otherwise.
*/
@SuppressWarnings("unchecked")
public TransportAction<Request, Response> get(ActionType<?> action) {
public TransportAction<? extends ActionRequest, ? extends ActionResponse> get(ActionType<?> action) {
if (action instanceof ExtensionAction) {
return (TransportAction<Request, Response>) registry.get((ExtensionAction) action);
return registry.get((ExtensionAction) action);
}
return actions.get(action);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ private <Request extends ActionRequest, Response extends ActionResponse> Transpo
if (actionRegistry == null) {
throw new IllegalStateException("NodeClient has not been initialized");
}
// Get from action map if it exists
TransportAction<Request, Response> transportAction = actionRegistry.get(action);
TransportAction<Request, Response> transportAction = (TransportAction<Request, Response>) actionRegistry.get(action);
if (transportAction == null) {
throw new IllegalStateException("failed to find action [" + action + "] to execute");
}
Expand Down
5 changes: 1 addition & 4 deletions server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1115,8 +1113,7 @@ protected Node(
resourcesToClose.addAll(pluginLifecycleComponents);
resourcesToClose.add(injector.getInstance(PeerRecoverySourceService.class));
this.pluginLifecycleComponents = Collections.unmodifiableList(pluginLifecycleComponents);
DynamicActionRegistry<? extends ActionRequest, ? extends ActionResponse> dynamicActionRegistry = actionModule
.getDynamicActionRegistry();
DynamicActionRegistry dynamicActionRegistry = actionModule.getDynamicActionRegistry();
dynamicActionRegistry.initialize(injector.getInstance(new Key<Map<ActionType, TransportAction>>() {
}), actionModule.getActionFilters(), transportService, extensionsManager);
client.initialize(
Expand Down

0 comments on commit 3829f15

Please sign in to comment.