Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

fix: fix watchdog NPE red herring #1344

Merged
merged 4 commits into from Apr 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions gax/src/test/java/com/google/api/gax/rpc/WatchdogTest.java
Expand Up @@ -128,6 +128,20 @@ public void testIdleTimeout() throws InterruptedException {
assertThat(actualError).isInstanceOf(WatchdogTimeoutException.class);
}

@Test
public void testTimedOutBeforeStart() {
MockServerStreamingCallable<String, String> callable1 = new MockServerStreamingCallable<>();
AccumulatingObserver<String> downstreamObserver1 = new AccumulatingObserver<>();
ResponseObserver observer = watchdog.watch(downstreamObserver1, waitTime, idleTime);
clock.incrementNanoTime(idleTime.toNanos() + 1);
// This should not remove callable1 from watched list
watchdog.run();
callable1.call("request", observer);
// This should cancel callable1
watchdog.run();
assertThat(callable1.popLastCall().getController().isCancelled()).isTrue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use of truth here feels gratuitous since assertTrue is simple and obvious

}

@Test
public void testMultiple() throws Exception {
// Start stream1
Expand Down