Skip to content

Commit ea9bdab

Browse files
authored
services: use Durations.toNanos instead of Duration.getNanos (#5059)
getNanos will return the fractional nanos of the duration, which is not the same as toNanos for durations larger than 1s.
1 parent 02f0dca commit ea9bdab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

services/src/test/java/io/grpc/services/BinlogHelperTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,8 @@ public ServerCall.Listener<byte[]> startCall(
966966
eq(CALL_ID),
967967
isNull(SocketAddress.class));
968968
verifyNoMoreInteractions(mockSinkWriter);
969-
assertThat(TimeUnit.SECONDS.toNanos(1) - timeoutCaptor.getValue().getNanos())
969+
Duration timeout = timeoutCaptor.getValue();
970+
assertThat(TimeUnit.SECONDS.toNanos(1) - Durations.toNanos(timeout))
970971
.isAtMost(TimeUnit.MILLISECONDS.toNanos(250));
971972
}
972973

0 commit comments

Comments
 (0)