This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 90ef44285d2 [fix][client] Fix thread leak in reloadLookUp method which
is used by ServiceUrlProvider (#24794)
90ef44285d2 is described below
commit 90ef44285d2b83620d7f2d1fd715bbdf848fc48f
Author: Lari Hotari <[email protected]>
AuthorDate: Fri Oct 31 16:10:40 2025 +0200
[fix][client] Fix thread leak in reloadLookUp method which is used by
ServiceUrlProvider (#24794)
(cherry picked from commit fbc50b06ada0af9edf23b4b75b7bf2f96b0b1c67)
---
.../java/org/apache/pulsar/client/impl/PulsarClientImpl.java | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
index cfca20233f6..5e3807dbcaf 100644
---
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
+++
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
@@ -116,7 +116,7 @@ public class PulsarClientImpl implements PulsarClient {
private final boolean createdScheduledProviders;
private final boolean createdLookupProviders;
- private LookupService lookup;
+ private volatile LookupService lookup;
private Map<String, LookupService> urlLookupMap = new
ConcurrentHashMap<>();
private final ConnectionPool cnxPool;
@Getter
@@ -1175,7 +1175,16 @@ public class PulsarClientImpl implements PulsarClient {
}
public void reloadLookUp() throws PulsarClientException {
+ LookupService previousLookup = lookup;
lookup = createLookup(conf.getServiceUrl());
+ // close the previous lookup after the new lookup is created
successfully
+ if (previousLookup != null && previousLookup != lookup) {
+ try {
+ previousLookup.close();
+ } catch (Exception e) {
+ log.warn("Failed to close previous lookup service", e);
+ }
+ }
}
public LookupService createLookup(String url) throws PulsarClientException
{