[ https://issues.apache.org/jira/browse/KAFKA-16589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17839731#comment-17839731 ]
Chia-Ping Tsai commented on KAFKA-16589: ---------------------------------------- {quote} is this ticket about removing `createAdminClient` from `ClusterInstance` to encourage developer to create admin by `Admin.create` directly? Thanks. {quote} yep, I'd like to make the `creation` be more consistent. For example, why ClusterInstance don't have `createConsumer` which can manage all created consumers? However, it could cause the error if `ClusterInstance` do close consumers in teardown since the consumers don't leave group in running the test case. Furthermore, it will cause a lot of false warnings that the created admins don't get closed. > 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)