[
https://issues.apache.org/jira/browse/KAFKA-16589?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Chia-Ping Tsai reassigned KAFKA-16589:
--------------------------------------
Assignee: PoAn Yang (was: Chia-Ping Tsai)
> Consider removing `ClusterInstance#createAdminClient` since callers are not
> sure whether they need to call close
> ----------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-16589
> URL: https://issues.apache.org/jira/browse/KAFKA-16589
> Project: Kafka
> Issue Type: Improvement
> Reporter: Chia-Ping Tsai
> Assignee: PoAn Yang
> Priority: Minor
>
> Sometimes we close the admin created by `createAdminClient`, and sometimes we
> don't. That is not a true problem since the `ClusterInstance` will call
> `close` when stopping.
> However, that cause a lot of inconsistent code, and in fact it does not save
> much time since creating a Admin is not a hard work. We can get
> `bootstrapServers` and `bootstrapControllers` from `ClusterInstance` easily.
>
> {code:java}
> // before
> try (Admin admin = cluster.createAdminClient()) { }
> // after v0
> try (Admin admin = Admin.create(Collections.singletonMap(
> CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG,
> cluster.bootstrapServers()))) {}
> {code}
> Personally, the `after` version is not verbose, but we can have alternatives:
> `Map<String, Object> clientConfigs`.
>
> {code:java}
> // after v1
> try (Admin admin = Admin.create(cluster.clientConfigs())) {}{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)