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

Fix completeWith exception handling #51734

Conversation

henningandersen
Copy link
Contributor

ActionListener.completeWith would catch exceptions from
listener.onResponse and deliver them to lister.onFailure, essentially
double notifying the listener. Instead we now assert that listeners do
not throw when using ActionListener.completeWith.

Relates #50886

ActionListener.completeWith would catch exceptions from
listener.onResponse and deliver them to lister.onFailure, essentially
double notifying the listener. Instead we now assert that listeners do
not throw when using ActionListener.completeWith.

Relates elastic#50886
@henningandersen henningandersen added >non-issue :Core/Infra/Core Core issues without another label :Distributed Indexing/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. v8.0.0 v7.7.0 labels Jan 31, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Core)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/Distributed)

Copy link
Member

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

LGTM, just one comment on the future I'm imagining :D

}
try {
listener.onResponse(response);
} catch (RuntimeException ex) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm starting to wonder ... maybe (as the eventual goal of our efforts here, don't think it's possible right now), we should just make ActionListener an abstract class and enforce that nothing is thrown in onResponse and onFailure by simply making these lines call some protected innerOnResponse or so.
It seems just enforcing the not throwing in onComplete and map is simply a small part of the overall issue of enforcing the callbacks to handle their own exceptions and we could just dry things up that way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I agree to this, but unfortunately it does not free us from avoiding for instance wrap, since it delegates failures from inner calls to listener.onResponse to onFailure in production (i.e., without assertions).

@henningandersen henningandersen merged commit 7470dcd into elastic:master Feb 3, 2020
henningandersen added a commit that referenced this pull request Feb 3, 2020
ActionListener.completeWith would catch exceptions from
listener.onResponse and deliver them to lister.onFailure, essentially
double notifying the listener. Instead we now assert that listeners do
not throw when using ActionListener.completeWith.

Relates #50886
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label :Distributed Indexing/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. >non-issue v7.7.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants