Skip to content

Cleanup Various Uses of ActionListener #40126

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

Conversation

original-brownbear
Copy link
Member

  • Use shorter map, runAfter or wrap where functionally equivalent to anonymous class
  • Use ActionRunnable where functionally equivalent

* Use shorter `map`, `runAfter` or `wrap` where functionally equivalent to anonymous class
* Use ActionRunnable where functionally equivalent
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

listener.onFailure(e);
}
});
rewriteShardRequest(request, ActionListener.map(listener, r -> executeDfsPhase(r, task)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently stumbled upon a subtle difference between ActionListener.wrap (called by ActionListener.map) compared to how we generally instantiate an action listener like here: there are places where we don't call onFailure in case onResponse throws (here we do , so everything is fine). This has subtle consequences depending on how the listener is used: say you use a CountDown and wait for a response from N nodes, if you call countDown on both onFailure and onResponse, you may end up counting down twice for the same node in case anything goes wrong while executing onResponse. Maybe an edge case, but it may be easy to miss when moving over to wrap or map whenever we wait for a response from multiple nodes.

Copy link
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Thanks @original-brownbear.

@original-brownbear
Copy link
Member Author

thanks @dnhatn !

@original-brownbear original-brownbear merged commit fdcbf05 into elastic:master May 20, 2019
@original-brownbear original-brownbear deleted the server-lister-no-delegate-cleanup branch May 20, 2019 16:33
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request May 20, 2019
…der-permit-primary-mode-only

* elastic/master:
  Validate non-secure settings are not in keystore (elastic#42209)
  Cleanup Various Uses of ActionListener (elastic#40126)
  Update api links per context (elastic#42033)
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request May 21, 2019
* Cleanup Various Uses of ActionListener

* Use shorter `map`, `runAfter` or `wrap` where functionally equivalent to anonymous class
* Use ActionRunnable where functionally equivalent
original-brownbear added a commit that referenced this pull request May 21, 2019
* Cleanup Various Uses of ActionListener

* Use shorter `map`, `runAfter` or `wrap` where functionally equivalent to anonymous class
* Use ActionRunnable where functionally equivalent
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
* Cleanup Various Uses of ActionListener

* Use shorter `map`, `runAfter` or `wrap` where functionally equivalent to anonymous class
* Use ActionRunnable where functionally equivalent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants