Skip to content

Commit

Permalink
Defer admin client creation for switchEmptyCase
Browse files Browse the repository at this point in the history
  • Loading branch information
germanosin committed Feb 28, 2025
1 parent 1682872 commit fae0628
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Mono<ReactiveAdminClient> get(KafkaCluster cluster) {
}

private Mono<ReactiveAdminClient> createAdminClient(KafkaCluster cluster) {
return Mono.fromFuture(CompletableFuture.supplyAsync(() -> {
return Mono.defer(() -> Mono.fromFuture(CompletableFuture.supplyAsync(() -> {
Properties properties = new Properties();
KafkaClientSslPropertiesUtil.addKafkaSslProperties(cluster.getOriginalProperties().getSsl(), properties);
properties.putAll(cluster.getProperties());
Expand All @@ -52,7 +52,7 @@ private Mono<ReactiveAdminClient> createAdminClient(KafkaCluster cluster) {
"kafbat-ui-admin-" + Instant.now().getEpochSecond() + "-" + CLIENT_ID_SEQ.incrementAndGet()
);
return AdminClient.create(properties);
})).flatMap(ac -> ReactiveAdminClient.create(ac).doOnError(th -> ac.close()))
}))).flatMap(ac -> ReactiveAdminClient.create(ac).doOnError(th -> ac.close()))
.onErrorMap(th -> new IllegalStateException(
"Error while creating AdminClient for the cluster " + cluster.getName(), th));
}
Expand Down

0 comments on commit fae0628

Please sign in to comment.