Skip to content

Commit 3e69193

Browse files
committed
fix unit test
1 parent e028d86 commit 3e69193

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

servlet/src/main/java/io/grpc/servlet/ServletAdapter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static java.util.logging.Level.FINE;
2323
import static java.util.logging.Level.FINEST;
2424

25+
import com.google.common.annotations.VisibleForTesting;
2526
import com.google.common.io.BaseEncoding;
2627
import io.grpc.Attributes;
2728
import io.grpc.ExperimentalApi;
@@ -160,7 +161,8 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx
160161
/**
161162
* Deadlines are managed via Context, servlet async timeout is not supposed to happen.
162163
*/
163-
private static final long ASYNC_TIMEOUT_SAFETY_MARGIN = 5_000;
164+
@VisibleForTesting
165+
static final long ASYNC_TIMEOUT_SAFETY_MARGIN = 5_000;
164166

165167
// This method must use Enumeration and its members, since that is the only way to read headers
166168
// from the servlet api.

servlet/src/test/java/io/grpc/servlet/ServletServerBuilderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void scheduledExecutorService() throws Exception {
8080
ServletAdapter servletAdapter = serverBuilder.buildServletAdapter();
8181
servletAdapter.doPost(request, response);
8282

83-
verify(asyncContext).setTimeout(1);
83+
verify(asyncContext).setTimeout(1 + ServletAdapter.ASYNC_TIMEOUT_SAFETY_MARGIN);
8484

8585
// The following just verifies that scheduler is populated to the transport.
8686
// It doesn't matter what tasks (such as handshake timeout and request deadline) are actually

0 commit comments

Comments
 (0)