Skip to content

Commit 8a270c0

Browse files
committed
Fixes a potential race condition with logging
This fixes a potential race condition where a test runs a thread in the executor that does some logging. Without waiting for threads to finish, another test can be run while that background thread is still executing. This can cause flaky issues with tests that only think that their test code is executing.
1 parent 650603d commit 8a270c0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

okhttp/src/test/java/io/grpc/okhttp/OkHttpClientTransportTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ public class OkHttpClientTransportTest {
192192

193193
@After
194194
public void tearDown() {
195-
executor.shutdownNow();
195+
try {
196+
executor.shutdownNow();
197+
executor.awaitTermination(10, TimeUnit.SECONDS);
198+
} catch (InterruptedException e) {
199+
// Ignore in a test and continue on as normal.
200+
}
196201
}
197202

198203
private void initTransport() throws Exception {

0 commit comments

Comments
 (0)