Skip to content

Commit bdf9a96

Browse files
authored
core: enable retry by default (grpc#8402)
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.
1 parent 2a63642 commit bdf9a96

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

api/src/main/java/io/grpc/ManagedChannelBuilder.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ public T perRpcBufferLimit(long bytes) {
467467
* @return this
468468
* @since 1.11.0
469469
*/
470-
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/3982")
471470
public T disableRetry() {
472471
throw new UnsupportedOperationException();
473472
}
@@ -482,7 +481,6 @@ public T disableRetry() {
482481
* @return this
483482
* @since 1.11.0
484483
*/
485-
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/3982")
486484
public T enableRetry() {
487485
throw new UnsupportedOperationException();
488486
}

core/src/main/java/io/grpc/internal/ManagedChannelImplBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public static ManagedChannelBuilder<?> forTarget(String target) {
142142
int maxHedgedAttempts = 5;
143143
long retryBufferSize = DEFAULT_RETRY_BUFFER_SIZE_IN_BYTES;
144144
long perRpcBufferLimit = DEFAULT_PER_RPC_BUFFER_LIMIT_IN_BYTES;
145-
boolean retryEnabled = false; // TODO(zdapeng): default to true
145+
boolean retryEnabled = true;
146146

147147
InternalChannelz channelz = InternalChannelz.instance();
148148
int maxTraceEvents;

core/src/test/java/io/grpc/internal/ManagedChannelImplTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ public void close() throws SecurityException {
355355

356356
channelBuilder = new ManagedChannelImplBuilder(TARGET,
357357
new UnsupportedClientTransportFactoryBuilder(), new FixedPortProvider(DEFAULT_PORT));
358+
channelBuilder.disableRetry();
358359
configureBuilder(channelBuilder);
359360
}
360361

@@ -1881,6 +1882,7 @@ public void oobChannelHasNoChannelCallCredentials() {
18811882
TARGET, InsecureChannelCredentials.create(),
18821883
new FakeCallCredentials(metadataKey, channelCredValue),
18831884
new UnsupportedClientTransportFactoryBuilder(), new FixedPortProvider(DEFAULT_PORT));
1885+
channelBuilder.disableRetry();
18841886
configureBuilder(channelBuilder);
18851887
createChannel();
18861888

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

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

0 commit comments

Comments
 (0)