Skip to content

Commit

Permalink
[Issue 9549] Add friendly comment for topic compactor tool. (apache#9563
Browse files Browse the repository at this point in the history
)

fix apache#9549 

when `pulsar topic compact -t topic` without setting `--broker-conf`

origin logic will read the `current path + /conf/broker.conf`.

which can cause zookeeperServers blank and throw NPE.
  • Loading branch information
lifepuzzlefun authored Feb 13, 2021
1 parent f5b1cb5 commit 590a27c
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,21 @@ public static void main(String[] args) throws Exception {
jcommander.usage();
throw new IllegalArgumentException("Need to specify a configuration file for broker");
} else {
log.info(String.format("read configuration file %s", arguments.brokerConfigFile));
brokerConfig = PulsarConfigurationLoader.create(
arguments.brokerConfigFile, ServiceConfiguration.class);
}


if (isBlank(brokerConfig.getZookeeperServers())) {
throw new IllegalArgumentException(
String.format("Need to specify `zookeeperServers` in configuration file \n"
+ "or specify configuration file path from command line.\n"
+ "now configuration file path is=[%s]\n",
arguments.brokerConfigFile)
);
}

ClientBuilder clientBuilder = PulsarClient.builder();

if (isNotBlank(brokerConfig.getBrokerClientAuthenticationPlugin())) {
Expand All @@ -86,6 +97,8 @@ public static void main(String[] args) throws Exception {


if (brokerConfig.getBrokerServicePortTls().isPresent()) {
log.info("Found `brokerServicePortTls` in configuration file. \n"
+ "Will connect pulsar use TLS.");
clientBuilder
.serviceUrl(PulsarService.brokerUrlTls(PulsarService.advertisedAddress(brokerConfig),
brokerConfig.getBrokerServicePortTls().get()))
Expand Down

0 comments on commit 590a27c

Please sign in to comment.