Skip to content

Commit

Permalink
fix: add awaitTermination for test cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumin8 committed May 10, 2024
1 parent 64ac5a7 commit 428f5ce
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.grpc.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -50,6 +51,7 @@ public class ITApiVersionHeaders {
private static final String EXPECTED_EXCEPTION_MESSAGE =
"Header provider can't override the header: "
+ ApiClientHeaderProvider.API_VERSION_HEADER_KEY;
private static final int DEFAULT_AWAIT_TERMINATION_SEC = 10;

// Implement a client interceptor to retrieve the trailing metadata from response.
private static class GrpcCapturingClientInterceptor implements ClientInterceptor {
Expand Down Expand Up @@ -182,11 +184,16 @@ public void createClients() throws Exception {
}

@After
public void destroyClient() {
public void destroyClient() throws InterruptedException {
grpcClient.close();
httpJsonClient.close();
grpcComplianceClient.close();
httpJsonComplianceClient.close();

grpcClient.awaitTermination(DEFAULT_AWAIT_TERMINATION_SEC, TimeUnit.SECONDS);
httpJsonClient.awaitTermination(DEFAULT_AWAIT_TERMINATION_SEC, TimeUnit.SECONDS);
grpcComplianceClient.awaitTermination(DEFAULT_AWAIT_TERMINATION_SEC, TimeUnit.SECONDS);
httpJsonComplianceClient.awaitTermination(DEFAULT_AWAIT_TERMINATION_SEC, TimeUnit.SECONDS);
}

@Test
Expand Down

0 comments on commit 428f5ce

Please sign in to comment.