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