Skip to content

Commit

Permalink
core: enable retry by default (#8402)
Browse files Browse the repository at this point in the history
Stabilize `enableRetry()` and `disableRetry()`.

Disable retry in `ManagedChannelImplTest` because each call attempt will fork the headers to a new instance, and add a ClientStreamTracer.Factory for bufferSizeLimit in CallOptions, which makes verification not straightforward.
  • Loading branch information
dapengzhang0 committed Aug 11, 2021
1 parent 2a63642 commit bdf9a96
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions api/src/main/java/io/grpc/ManagedChannelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ public T perRpcBufferLimit(long bytes) {
* @return this
* @since 1.11.0
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/3982")
public T disableRetry() {
throw new UnsupportedOperationException();
}
Expand All @@ -482,7 +481,6 @@ public T disableRetry() {
* @return this
* @since 1.11.0
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/3982")
public T enableRetry() {
throw new UnsupportedOperationException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static ManagedChannelBuilder<?> forTarget(String target) {
int maxHedgedAttempts = 5;
long retryBufferSize = DEFAULT_RETRY_BUFFER_SIZE_IN_BYTES;
long perRpcBufferLimit = DEFAULT_PER_RPC_BUFFER_LIMIT_IN_BYTES;
boolean retryEnabled = false; // TODO(zdapeng): default to true
boolean retryEnabled = true;

InternalChannelz channelz = InternalChannelz.instance();
int maxTraceEvents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ public void close() throws SecurityException {

channelBuilder = new ManagedChannelImplBuilder(TARGET,
new UnsupportedClientTransportFactoryBuilder(), new FixedPortProvider(DEFAULT_PORT));
channelBuilder.disableRetry();
configureBuilder(channelBuilder);
}

Expand Down Expand Up @@ -1881,6 +1882,7 @@ public void oobChannelHasNoChannelCallCredentials() {
TARGET, InsecureChannelCredentials.create(),
new FakeCallCredentials(metadataKey, channelCredValue),
new UnsupportedClientTransportFactoryBuilder(), new FixedPortProvider(DEFAULT_PORT));
channelBuilder.disableRetry();
configureBuilder(channelBuilder);
createChannel();

Expand Down Expand Up @@ -1933,6 +1935,7 @@ public void oobChannelHasNoChannelCallCredentials() {
new FakeNameResolverFactory.Builder(URI.create("oobauthority")).build())
.defaultLoadBalancingPolicy(MOCK_POLICY_NAME)
.idleTimeout(ManagedChannelImplBuilder.IDLE_MODE_MAX_TIMEOUT_DAYS, TimeUnit.DAYS)
.disableRetry() // irrelevant to what we test, disable retry to make verification easy
.build();
oob.getState(true);
ArgumentCaptor<Helper> helperCaptor = ArgumentCaptor.forClass(Helper.class);
Expand Down Expand Up @@ -1980,6 +1983,7 @@ public SwapChannelCredentialsResult answer(InvocationOnMock invocation) {
TARGET, InsecureChannelCredentials.create(),
new FakeCallCredentials(metadataKey, channelCredValue),
new UnsupportedClientTransportFactoryBuilder(), new FixedPortProvider(DEFAULT_PORT));
channelBuilder.disableRetry();
configureBuilder(channelBuilder);
createChannel();

Expand Down Expand Up @@ -2017,6 +2021,7 @@ public SwapChannelCredentialsResult answer(InvocationOnMock invocation) {
new FakeNameResolverFactory.Builder(URI.create("fake://oobauthority/")).build())
.defaultLoadBalancingPolicy(MOCK_POLICY_NAME)
.idleTimeout(ManagedChannelImplBuilder.IDLE_MODE_MAX_TIMEOUT_DAYS, TimeUnit.DAYS)
.disableRetry() // irrelevant to what we test, disable retry to make verification easy
.build();
oob.getState(true);
ArgumentCaptor<Helper> helperCaptor = ArgumentCaptor.forClass(Helper.class);
Expand Down

0 comments on commit bdf9a96

Please sign in to comment.