-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
RestClient asynchronous execution should not throw exceptions #23307
RestClient asynchronous execution should not throw exceptions #23307
Conversation
The current implementation of RestClient.performAsync() methods can throw exceptions before the request is asynchronously executed. Since it only throws unchecked exceptions, it's easy for the user/dev to forget to catch them. Instead I think async methods should never throw exceptions and should always call the listener onFailure() method.
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.
left a small comment, LGTM otherwise
new HttpHost[]{new HttpHost("localhost", 9200)}, null, null); | ||
} | ||
|
||
class TestListener implements ResponseListener { |
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 you can use RestClient.SyncResponseListener
here instead
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.
Sure
I marked it as a bug, I think we should backport it too. |
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
The current implementation of RestClient.performAsync() methods can throw exceptions before the request is asynchronously executed. Since it only throws unchecked exceptions, it's easy for the user/dev to forget to catch them. Instead I think async methods should never throw exceptions and should always call the listener onFailure() method.
The current implementation of RestClient.performAsync() methods can throw exceptions before the request is asynchronously executed. Since it only throws unchecked exceptions, it's easy for the user/dev to forget to catch them. Instead I think async methods should never throw exceptions and should always call the listener onFailure() method.
The current implementation of RestClient.performAsync() methods can throw exceptions before the request is asynchronously executed. Since it only throws unchecked exceptions, it's easy for the user/dev to forget to catch them. Instead I think async methods should never throw exceptions and should always call the listener onFailure() method.
With #23307, the expected exception is wrapped two times into a RuntimeException instead of being thrown directly.
With #23307, the expected exception is wrapped two times into a RuntimeException instead of being thrown directly.
With #23307, the expected exception is wrapped two times into a RuntimeException instead of being thrown directly.
With #23307, the expected exception is wrapped two times into a RuntimeException instead of being thrown directly.
Removing 5.2.2 label as this issue has not been packaged with 5.2.2 |
The current implementation of
RestClient.performAsync()
methods can throw exceptions before the request is asynchronously executed. Since it only throws unchecked exceptions, it's easy for the user/dev to forget to catch them, leaving the listener in the wild... Instead I think async methods should never throw exceptions and should always call the listener onFailure() method.