Skip to content

Commit

Permalink
[fix] Avoid NPE when closing an uninitialized SameAuthParamsLookupAut…
Browse files Browse the repository at this point in the history
…oClusterFailover
  • Loading branch information
merlimat committed Jan 29, 2025
1 parent c5173d5 commit 4a6ac8e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ private PulsarClientImpl(ClientConfigurationData conf, EventLoopGroup eventLoopG
this::reduceConsumerReceiverQueueSize);
state.set(State.Open);
} catch (Throwable t) {
// Log the exception first, or it could be missed if there are any subsequent exceptions in the
// shutdown sequence
log.error("Failed to create Pulsar client instance.", t);
shutdown();
shutdownEventLoopGroup(eventLoopGroupReference);
closeCnxPool(connectionPoolReference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,21 @@ public String getServiceUrl() {

@Override
public void close() throws Exception {
if (closed) {
return;
}

log.info("Closing service url provider. Current pulsar service: [{}] {}", currentPulsarServiceIndex,
pulsarServiceUrlArray[currentPulsarServiceIndex]);
if (scheduledCheckTask != null) {
scheduledCheckTask.cancel(false);
}

if (executor != null) {
executor.shutdownNow();
}

closed = true;
scheduledCheckTask.cancel(false);
executor.shutdownNow();
}

private int firstHealthyPulsarService() {
Expand Down

0 comments on commit 4a6ac8e

Please sign in to comment.