Skip to content
Permalink
Browse files
feat!: deprecate RetrySettings.isJittered [gax-java] (#1308)
* feat!: deprecate RetrySettings.isJittered

* fix: Address comments
  • Loading branch information
miraleung committed Feb 19, 2021
1 parent ee370f6 commit 68644a4e24f29223f8f533a3d353dff7457d9737
@@ -187,7 +187,7 @@ public boolean shouldRetry(TimedAttemptSettings nextAttemptSettings) {

// Injecting Random is not possible here, as Random does not provide nextLong(long bound) method
protected long nextRandomLong(long bound) {
return bound > 0 && globalSettings.isJittered()
return bound > 0 && globalSettings.isJittered() // Jitter check needed for testing purposes.
? ThreadLocalRandom.current().nextLong(bound)
: bound;
}
@@ -30,6 +30,7 @@
package com.google.api.gax.retrying;

import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import java.io.Serializable;
import org.threeten.bp.Duration;

@@ -112,7 +113,11 @@ public abstract class RetrySettings implements Serializable {
* <pre>{@code actualDelay = rand_between(0, min(maxRetryDelay, delay))}</pre>
*
* The default value is {@code true}.
*
* @deprecated Retries always jitter.
*/
@Deprecated
@VisibleForTesting
public abstract boolean isJittered();

/**
@@ -194,13 +199,17 @@ public abstract static class Builder {
public abstract Builder setMaxAttempts(int maxAttempts);

/**
* Jitter determines if the delay time should be randomized. In most cases, if jitter is set to
* {@code true} the actual delay time is calculated in the following way:
* Jitter determines if the delay time should be randomized. If jitter is set to {@code true}
* the actual delay time is calculated in the following way:
*
* <pre>{@code actualDelay = rand_between(0, min(maxRetryDelay, exponentialDelay))}</pre>
*
* The default value is {@code true}.
* The default value is {@code true}, and this method will be a no-op soon.
*
* @deprecated Retries always jitter.
*/
@Deprecated
@VisibleForTesting
public abstract Builder setJittered(boolean jittered);

/**

0 comments on commit 68644a4

Please sign in to comment.