[ https://issues.apache.org/jira/browse/KAFKA-16589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17839724#comment-17839724 ]
PoAn Yang edited comment on KAFKA-16589 at 4/22/24 2:56 PM: ------------------------------------------------------------ Hi [~chia7712], is this ticket about removing `createAdminClient` from `ClusterInstance` to encourage developer to create admin by `Admin.create` directly? Thanks. was (Author: JIRAUSER300229): Hi [~chia7712], is this ticket try to `createAdminClient` from `ClusterInstance` to encourage developer to create admin by `Admin.create` directly? Thanks. > 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: Chia-Ping Tsai > 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)