-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Fix completeWith exception handling #51734
Conversation
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
Pinging @elastic/es-core-infra (:Core/Infra/Core) |
Pinging @elastic/es-distributed (:Distributed/Distributed) |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
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 #50886