Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions stub/src/test/java/io/grpc/stub/BlockingClientCallTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -357,31 +357,19 @@ public void testReadsAndWritesInterleaved_BlockingWrites() throws Exception {
}

@Test
public void testWriteCompleted() throws Exception {
public void testWriteAfterCloseThrows() throws Exception {
testMethod.disableAutoRequest();
biDiStream = ClientCalls.blockingBidiStreamingCall(channel, BIDI_STREAMING_METHOD,
CallOptions.DEFAULT);

// Verify pending write released
long start = System.currentTimeMillis();
delayedVoidMethod(DELAY_MILLIS, biDiStream::halfClose);
assertFalse(biDiStream.write(1)); // should block until writeComplete is triggered
long end = System.currentTimeMillis();
assertThat(end - start).isAtLeast(DELAY_MILLIS);

// verify new writes throw an illegalStateException
biDiStream.halfClose();
try {
assertFalse(biDiStream.write(2));
fail("write did not throw an exception when called after halfClose");
} catch (IllegalStateException e) {
assertThat(e.getMessage()).containsMatch("after.*halfClose.*cancel");
}

// verify pending write with timeout released
biDiStream = ClientCalls.blockingBidiStreamingCall(channel, BIDI_STREAMING_METHOD,
CallOptions.DEFAULT);
delayedVoidMethod(DELAY_MILLIS, biDiStream::halfClose);
assertFalse(biDiStream.write(3, 2 * DELAY_MILLIS, TimeUnit.MILLISECONDS));
}

@Test
Expand Down