Fix hanging KafkaAdminClientTest
Fix a hanging test in KafkaAdminClientTest by forcing the admin client to shut down
whether or not there are pending requests once the test harness enters shutdown.
Reviewers: Ismael Juma Guozhang Wang
@@ -23,6 +23,7 @@ import org.apache.kafka.common.Node;
import org.apache.kafka.common.utils.LogContext;
import org.apache.kafka.common.utils.Time;
+import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -113,7 +114,10 @@ public class AdminClientUnitTestEnv implements AutoCloseable {
@Override
public void close() {
- this.adminClient.close();
+ // tell the admin client to close now
+ this.adminClient.close(Duration.ZERO);
+ // block for up to a minute until the internal threads shut down.
+ this.adminClient.close(Duration.ofMinutes(1));
}
static Map<String, Object> clientConfigs(String... overrides) {
