Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ public Builder setRetryOptions(RpcRetryOptions o) {
setInitialInterval(
OptionsUtils.merge(initialInterval, o.getInitialInterval(), Duration.class));
setCongestionInitialInterval(
OptionsUtils.merge(congestionInitialInterval, o.getInitialInterval(), Duration.class));
OptionsUtils.merge(
congestionInitialInterval, o.getCongestionInitialInterval(), Duration.class));
setExpiration(OptionsUtils.merge(expiration, o.getExpiration(), Duration.class));
setMaximumInterval(
OptionsUtils.merge(maximumInterval, o.getMaximumInterval(), Duration.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.temporal.serviceclient;

import static org.junit.Assert.assertEquals;

import java.time.Duration;
import org.junit.Test;

public class RpcRetryOptionsTest {

/**
* congestionInitialInterval is the backoff used for RESOURCE_EXHAUSTED and is deliberately set
* much higher than initialInterval. Builder.setRetryOptions must merge it from the source's
* congestionInitialInterval, not from its initialInterval, otherwise that margin is silently
* collapsed.
*/
@Test
public void setRetryOptionsMergesCongestionInitialInterval() {
RpcRetryOptions source =
RpcRetryOptions.newBuilder()
.setInitialInterval(Duration.ofMillis(200))
.setCongestionInitialInterval(Duration.ofSeconds(7))
.validateBuildWithDefaults();

RpcRetryOptions merged =
RpcRetryOptions.newBuilder().setRetryOptions(source).validateBuildWithDefaults();

assertEquals(Duration.ofMillis(200), merged.getInitialInterval());
assertEquals(Duration.ofSeconds(7), merged.getCongestionInitialInterval());
}
}