Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.2k
RetryHelper can be configured to not retry on socket timeouts.#882
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
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
24 changes: 17 additions & 7 deletions
24 gcloud-java-core/src/main/java/com/google/gcloud/RetryHelper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 28 additions & 1 deletion
29 gcloud-java-core/src/test/java/com/google/gcloud/RetryHelperTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,6 +30,7 @@ | ||
| import org.junit.Test; | ||
| import java.io.IOException; | ||
| import java.net.SocketTimeoutException; | ||
| import java.util.Arrays; | ||
| import java.util.Iterator; | ||
| import java.util.concurrent.Callable; | ||
| @@ -194,14 +195,40 @@ public void testTriesNoMoreLongerThanTotalRetryPeriod() { | ||
| } | ||
| throw new RuntimeException(); | ||
| } | ||
| }), params, handler, stopwatch); | ||
| }), params, handler, stopwatch, true); | ||
| fail(); | ||
| } catch (RetriesExhaustedException expected) { | ||
| // verify timesCalled | ||
| assertEquals(sleepOnAttempt, timesCalled.get()); | ||
| } | ||
| } | ||
| @Test | ||
| public void testNoRetriesOnSocketTimeout() { | ||
| final FakeTicker ticker = new FakeTicker(); | ||
| Stopwatch stopwatch = Stopwatch.createUnstarted(ticker); | ||
| RetryParams params = RetryParams.builder().initialRetryDelayMillis(0) | ||
| .totalRetryPeriodMillis(999) | ||
| .retryMinAttempts(5) | ||
| .retryMaxAttempts(10) | ||
| .build(); | ||
| ExceptionHandler handler = ExceptionHandler.builder().retryOn(RuntimeException.class).build(); | ||
| final AtomicInteger timesCalled = new AtomicInteger(0); | ||
| try { | ||
| RetryHelper.runWithRetries(callable(new Runnable() { | ||
| @Override public void run() { | ||
| timesCalled.incrementAndGet(); | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| throw new RetryHelper.RetryHelperException( | ||
| new SocketTimeoutException("Simulated socket timeout")); | ||
| } | ||
| }), params, handler, stopwatch, false); | ||
| fail(); | ||
| } catch (RetryHelper.RetryHelperException expected) { | ||
| // verify timesCalled | ||
| assertEquals(1, timesCalled.get()); | ||
| } | ||
| } | ||
| @Test | ||
| public void testBackoffIsExponential() { | ||
| // Total retry period set to 60 seconds so as to not factor into test | ||
6 changes: 3 additions & 3 deletions
6 gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.