BewareMyPower commented on code in PR #22858:
URL: https://github.com/apache/pulsar/pull/22858#discussion_r1629343304


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java:
##########
@@ -744,6 +745,21 @@ public void close() throws PulsarClientException {
         }
     }
 
+    private void closeUrlLookupMap() {
+        Map<String, LookupService> closedUrlLookupServices = new 
HashMap(urlLookupMap.size());
+        urlLookupMap.entrySet().forEach(e -> {
+            try {
+                e.getValue().close();
+            } catch (Exception ex) {
+                log.error("Error closing lookup service {}", e.getKey(), ex);
+            }
+            closedUrlLookupServices.put(e.getKey(), e.getValue());
+        });
+        closedUrlLookupServices.entrySet().forEach(e -> {

Review Comment:
   Why did you retain the lookup services that failed to `close`? It seems that 
there is no chance to close these lookup services again.
   
   I mean, what's the issue with the following simple implementation.
   
   ```java
       private void closeUrlLookupMap() {
           urlLookupMap.forEach((serviceUrl, lookupService) -> {
               try {
                   lookupService.close();
               } catch (Exception e) {
                   log.error("Error closing lookup service {}", serviceUrl, e);
               }
           });
           urlLookupMap.clear();
       }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to