Skip to content

Commit 7233077

Browse files
committed
Fake infinite timeout; 1s is not a good hard-coded timeout
Stubs don't have any timeout. However, MethodDescriptor does and requires a timeout. We really want "no timeout," which is infinite, but we use 10 years as the next best thing. CallOptions will end up fixing this hack as MethodDescriptor will no longer have timeout. Before, the hard-coded 1s didn't matter, because nobody was observing it. Since 77878a0 it is now being sent to servers, and some servers enforce it. Oops.
1 parent 05f5a4f commit 7233077

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

interop-testing/src/test/java/io/grpc/stub/StubConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void testConfigureTimeout() {
5555
// Create a default stub
5656
TestServiceGrpc.TestServiceBlockingStub stub =
5757
TestServiceGrpc.newBlockingStub(new FakeChannel());
58-
assertEquals(TimeUnit.SECONDS.toMicros(1),
58+
assertEquals(TimeUnit.DAYS.toMicros(10 * 365),
5959
stub.getServiceDescriptor().fullDuplexCall.getTimeout());
6060
// Reconfigure it
6161
stub = stub.configureNewStub()
@@ -65,7 +65,7 @@ public void testConfigureTimeout() {
6565
assertEquals(TimeUnit.SECONDS.toMicros(2),
6666
stub.getServiceDescriptor().fullDuplexCall.getTimeout());
6767
// Default config unchanged
68-
assertEquals(TimeUnit.SECONDS.toMicros(1),
68+
assertEquals(TimeUnit.DAYS.toMicros(10 * 365),
6969
TestServiceGrpc.CONFIG.fullDuplexCall.getTimeout());
7070
}
7171

stub/src/main/java/io/grpc/stub/ClientCalls.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static <RequestT, ResponseT> MethodDescriptor<RequestT, ResponseT> create
6969
// TODO(zhangkun83): if timeout is not defined in proto file, use a default timeout here.
7070
// If timeout is defined in proto file, Method should carry the timeout.
7171
return MethodDescriptor.create(method.getType(), fullServiceName + "/" + method.getName(),
72-
1, TimeUnit.SECONDS, method.getRequestMarshaller(), method.getResponseMarshaller());
72+
10 * 365, TimeUnit.DAYS, method.getRequestMarshaller(), method.getResponseMarshaller());
7373
}
7474

7575
/**

0 commit comments

Comments
 (0)