This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 27a820234d2 [fix][client] Fix thread leak in reloadLookUp method which
is used by ServiceUrlProvider (#24794)
27a820234d2 is described below
commit 27a820234d290985589e05d8387509d40a584c47
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 5f5239131a8..a09e11cf1f5 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
@@ -117,7 +117,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
@@ -1212,7 +1212,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
{