Repository navigation
Conversation
…acts - Fix inaccurate RetrySettings class Javadoc claims on rpcTimeoutMultiplier and server-streaming timeouts. - Clarify maxAttempts total-attempt semantics (0 vs 1 vs >1), zero initialRpcTimeoutDuration behavior, and Builder.merge/newBuilder defaults. - Correct LRO polling RPC timeout claims and document ExponentialRetryAlgorithm scaling and termination rules.
There was a problem hiding this comment.
Code Review
This pull request updates and refactors the Javadoc documentation in ExponentialRetryAlgorithm and RetrySettings to provide clearer, more accurate explanations of the retry logic, including the behavior of maximum attempts, RPC timeouts, and builder methods. The review feedback correctly identifies a discrepancy in the Javadoc for the merge method regarding how maxAttempts is handled during a merge, and suggests a correction to ensure the documentation matches the actual implementation.
| * Copies non-null duration fields, multipliers {@code >= 1.0}, {@code maxAttempts}, and {@code | ||
| * jittered} from {@code newSettings} onto this builder. | ||
| * | ||
| * <p>Because {@link RetrySettings#newBuilder()} initializes all durations to {@link | ||
| * java.time.Duration#ZERO}, multipliers to {@code 1.0}, and {@code maxAttempts} to {@code 0}, | ||
| * merging a fresh builder resets unset fields to those defaults. Mutate {@link | ||
| * RetrySettings#toBuilder()} directly when changing a subset of fields. |
There was a problem hiding this comment.
The Javadoc states that merging a fresh builder resets unset fields to their defaults, including maxAttempts to 0. However, in the implementation of merge(RetrySettings.Builder), maxAttempts is only copied if it is non-zero (newSettings.getMaxAttempts() != 0). Since a fresh builder initializes maxAttempts to 0, merging it will not reset maxAttempts to 0 on the target builder. We should clarify this in the Javadoc.
* Copies non-null duration fields, multipliers {@code >= 1.0}, non-zero {@code maxAttempts}, and
* {@code jittered} from {@code newSettings} onto this builder.
*
* <p>Because {@link RetrySettings#newBuilder()} initializes all durations to {@link
* java.time.Duration#ZERO}, multipliers to {@code 1.0}, and {@code jittered} to {@code true},
* merging a fresh builder resets those fields to their defaults. However, since only non-zero
* {@code maxAttempts} are merged, {@code maxAttempts} is not reset to {@code 0}. Mutate {@link
* RetrySettings#toBuilder()} directly when changing a subset of fields.References
- Update stale Javadoc comments to reflect new method behavior for improved clarity, rather than removing them.
Updates
RetrySettingsandExponentialRetryAlgorithmJavadocs ingax:RetrySettings: fixes inaccurate failure-vs-timeout scaling and server-streaming timeout claims, clarifiesmaxAttemptstotal-attempt semantics (0,1, and> 1), documents zeroinitialRpcTimeoutDurationand LRO per-poll RPC timeout behavior, and documentsnewBuilder(),setLogicalTimeout(),build(), andmerge()contracts.ExponentialRetryAlgorithm: documents initial attempt timeout capping, retry delay and RPC timeout scaling, and termination rules on the class,createNextAttempt(), andshouldRetry().