-
Notifications
You must be signed in to change notification settings - Fork 741
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
Retry when SocketException with some sleep #674
Conversation
@v1v
You can change
Then for the mocking, you'll need use the Do note you don't have do all this in code, you can record json files and construct scenarios that way too. Do whatever makes the most sense to you. Finally, if it comes down to it, you could make some of the private methods package accessible and then use Mockito to mock/or spy them. I'm open to ideas.
I'm not sure. What is your opinion? |
And you can change
|
For instance: connection reset by peer
Awesome! Thanks for the tips, I think I did manage to have something in place, not sure if the UTs I just coded are good enough, the stacktrace when running locally already shows the retries to work as expected
I think being more defensive might help when the third party systems don't behave as expected. So I'd prefer to retry again even if there is a reset by peer issue or something else. A couple of questions:
|
@@ -87,6 +87,9 @@ protected void initializeServers() { | |||
@Override | |||
protected void before() { | |||
super.before(); | |||
this.apiServer() |
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'd rather you do this in the test class. Override before
and add this code there.
@@ -923,7 +939,11 @@ private void retryInvalidCached404Response() throws IOException { | |||
// scenarios. If GitHub ever fixes their issue and/or begins providing accurate ETags to | |||
// their 404 responses, this will result in at worst two requests being made for each 404 | |||
// responses. However, only the second request will count against rate limit. | |||
int responseCode = uc.getResponseCode(); | |||
int responseCode = 0; |
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.
Cool thanks. Take a look at #678. When you get a chance. You don't have to change this, just meant as an FYI.
@v1v Take a look at my changes and tell me what you think. |
@bitwiseman thanks for your support and guide. I've just reviewed the changes and they do cover all the other cases when there could be a timeout so it looks fabulous. I actually learned how to mock the scenario with retry and success. 💯 |
Description
Fixes #539
Use the sleep approach as stated in #373
Edit from @bitwiseman:
Questions
I've been trying different approaches to test this particular scenario, the main issue is regarding the
retryInvalidCached404Response
method, that's called from the_fetch
method in theRequester
class since it does validate the response and therefore I'm not sure how I can mock/reproduce the timeout.Before submitting a PR:
We love getting PRs, but we hate asking people for the same basic changes every time.
master
. Create your PR from that branch.mvn -P ci install site
locally. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI.