Skip to content

Commit

Permalink
Remove generic types as they are incompatible with Guice injection
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Mar 22, 2023
1 parent d43c5c6 commit c2a57d7
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions server/src/main/java/org/opensearch/action/ActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ public static class DynamicActionRegistry {
// This is the unmodifiable actions map created during node bootstrap, which
// will continue to link ActionType and TransportAction pairs from core and plugin
// action handler registration.
private Map<ActionType<?>, TransportAction<?, ?>> actions = Collections.emptyMap();
private Map<ActionType, TransportAction> actions = Collections.emptyMap();
// A dynamic registry to add or remove ActionType / TransportAction pairs
// at times other than node bootstrap.
private final Map<ActionType<?>, TransportAction<?, ?>> registry = new ConcurrentHashMap<>();
Expand All @@ -1005,7 +1005,7 @@ public static class DynamicActionRegistry {
*
* @param actions The injected map of {@link ActionType} to {@link TransportAction}
*/
public void registerUnmodifiableActionMap(Map<ActionType<?>, TransportAction<?, ?>> actions) {
public void registerUnmodifiableActionMap(Map<ActionType, TransportAction> actions) {
this.actions = actions;
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ protected Node(
resourcesToClose.add(injector.getInstance(PeerRecoverySourceService.class));
this.pluginLifecycleComponents = Collections.unmodifiableList(pluginLifecycleComponents);
DynamicActionRegistry dynamicActionRegistry = actionModule.getDynamicActionRegistry();
dynamicActionRegistry.registerUnmodifiableActionMap(injector.getInstance(new Key<Map<ActionType<?>, TransportAction<?, ?>>>() {
dynamicActionRegistry.registerUnmodifiableActionMap(injector.getInstance(new Key<Map<ActionType, TransportAction>>() {
}));
client.initialize(
dynamicActionRegistry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ public List<Route> routes() {

public void testDynamicActionRegistry() {
ActionFilters emptyFilters = new ActionFilters(Collections.emptySet());
Map<ActionType<?>, TransportAction<?, ?>> testMap = Map.of(
TestAction.INSTANCE,
new TestTransportAction("test-action", emptyFilters, null)
);
Map<ActionType, TransportAction> testMap = Map.of(TestAction.INSTANCE, new TestTransportAction("test-action", emptyFilters, null));

DynamicActionRegistry dynamicActionRegistry = new DynamicActionRegistry();
dynamicActionRegistry.registerUnmodifiableActionMap(testMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected Client buildClient(Settings headersSettings, ActionType[] testedAction
return client;
}

private static class Actions extends HashMap<ActionType<?>, TransportAction<?, ?>> {
private static class Actions extends HashMap<ActionType, TransportAction> {

private Actions(Settings settings, ThreadPool threadPool, ActionType<?>[] actions) {
for (ActionType<?> action : actions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void stubValidateQueryAction() {
protected void doExecute(Task task, ActionRequest request, ActionListener listener) {}
};

final Map<ActionType<?>, TransportAction<?, ?>> actions = new HashMap<>();
final Map<ActionType, TransportAction> actions = new HashMap<>();
actions.put(ValidateQueryAction.INSTANCE, transportAction);

DynamicActionRegistry dynamicActionRegistry = new DynamicActionRegistry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ public void onFailure(final Exception e) {
RetentionLeaseSyncer.EMPTY,
SegmentReplicationCheckpointPublisher.EMPTY
);
Map<ActionType<?>, TransportAction<?, ?>> actions = new HashMap<>();
Map<ActionType, TransportAction> actions = new HashMap<>();
final SystemIndices systemIndices = new SystemIndices(emptyMap());
final ShardLimitValidator shardLimitValidator = new ShardLimitValidator(settings, clusterService, systemIndices);
final MetadataCreateIndexService metadataCreateIndexService = new MetadataCreateIndexService(
Expand Down

0 comments on commit c2a57d7

Please sign in to comment.