From 72339dacc9d554ea0d589f949921076b0d854cf7 Mon Sep 17 00:00:00 2001 From: Larry Safran Date: Mon, 13 Jan 2025 16:44:01 -0800 Subject: [PATCH] Eliminate invalid test cases where different threads were calling close from the thread writing. --- .../io/grpc/stub/BlockingClientCallTest.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/stub/src/test/java/io/grpc/stub/BlockingClientCallTest.java b/stub/src/test/java/io/grpc/stub/BlockingClientCallTest.java index 112b092eaed..1998c474648 100644 --- a/stub/src/test/java/io/grpc/stub/BlockingClientCallTest.java +++ b/stub/src/test/java/io/grpc/stub/BlockingClientCallTest.java @@ -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