KAFKA-12557: Fix hanging KafkaAdminClientTest (#10404)

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 <ijuma@apache.org>, Guozhang Wang <guozhang@apache.org>
This commit is contained in:
John Roesler 2021-03-30 11:36:13 -05:00 committed by GitHub
parent 0018c3c089
commit d02ad2c0e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import org.apache.kafka.common.Node;
import org.apache.kafka.common.utils.LogContext; import org.apache.kafka.common.utils.LogContext;
import org.apache.kafka.common.utils.Time; import org.apache.kafka.common.utils.Time;
import java.time.Duration;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -113,7 +114,10 @@ public class AdminClientUnitTestEnv implements AutoCloseable {
@Override @Override
public void close() { 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) { static Map<String, Object> clientConfigs(String... overrides) {