Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] SDKClient execute() fails with NPE #519

Closed
dbwiddis opened this issue Mar 3, 2023 · 1 comment · Fixed by #520
Closed

[BUG] SDKClient execute() fails with NPE #519

dbwiddis opened this issue Mar 3, 2023 · 1 comment · Fixed by #520
Assignees
Labels
bug Something isn't working

Comments

@dbwiddis
Copy link
Member

dbwiddis commented Mar 3, 2023

What is the bug?

SDKClient use of execute() implemented in #491 fails with NPE (actions is null) here:

TransportAction<Request, Response> transportAction = actions.get(action);

The root cause is that we incorrectly attempt to access an injected actions map:

// Used by client.execute
@SuppressWarnings("rawtypes")
@Inject
private Map<ActionType, TransportAction> actions;

However, the SDKClient was instantiated before injection so the map wasn't injected.

How can one reproduce the bug?

  1. Run an extension and use the execute() method from SDKClient or SDKRestClient.
  2. Observe REST error response that "actions" is null.

What is the expected behavior?

actions.get(action) returns an instance of a class implementing TransportAction.

Do you have any additional context?

The implementation was ported from NodeClient with this field populated by the initialize() method (and not by injection):

private Map<ActionType, TransportAction> actions;

This code from Node.java was not included in ExtensionsRunner shortly after injection completes, so porting it should fix this bug:

client.initialize(injector.getInstance(new Key<Map<ActionType, TransportAction>>() {}));
@dbwiddis dbwiddis added bug Something isn't working untriaged labels Mar 3, 2023
@dbwiddis dbwiddis self-assigned this Mar 3, 2023
@dbwiddis dbwiddis removed the untriaged label Mar 3, 2023
@dbwiddis
Copy link
Member Author

dbwiddis commented Mar 3, 2023

A couple things were happening here:

  • (This bug) Injection wasn't working because SDKClient was instantiated before the injection. This wasn't seen in the HelloWorld test case because of the initialization order was different.
  • (Other bugs) The Injector was becoming unreachable due to GC and we were losing reference to all injected objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant