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 (apache#23911)

(cherry picked from commit 12b0579)
(cherry picked from commit c0ee989)
  • Loading branch information
merlimat authored and srinath-ctds committed Feb 3, 2025
1 parent 8d78269 commit c0f9210
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 @@ -253,6 +253,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 @@ -107,11 +107,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 c0f9210

Please sign in to comment.