heesung-sn commented on code in PR #22589:
URL: https://github.com/apache/pulsar/pull/22589#discussion_r1580122532


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java:
##########
@@ -110,11 +111,13 @@ public SystemTopicBasedTopicPoliciesService(PulsarService 
pulsarService) {
         this.writerCaches = Caffeine.newBuilder()
                 .expireAfterAccess(5, TimeUnit.MINUTES)
                 .removalListener((namespaceName, writer, cause) -> {
-                    ((SystemTopicClient.Writer) 
writer).closeAsync().exceptionally(ex -> {
-                        log.error("[{}] Close writer error.", namespaceName, 
ex);
-                        return null;
-                    });
+                    try {
+                        ((SystemTopicClient.Writer) writer).close();
+                    } catch (IOException e) {

Review Comment:
   Maybe catching `Exception` might be safer?



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicTxnBufferSnapshotService.java:
##########
@@ -142,8 +143,26 @@ private SystemTopicClient<T> 
getTransactionBufferSystemTopicClient(NamespaceName
 
     public void close() throws Exception {
         for (Map.Entry<NamespaceName, SystemTopicClient<T>> entry : 
clients.entrySet()) {
-            entry.getValue().close();
+            try {
+                entry.getValue().close();
+            } catch (Exception e) {
+                log.error("Failed to close system topic client for namespace 
{}", entry.getKey(), e);
+            }
+        }
+        clients.clear();
+        for (Map.Entry<NamespaceName, ReferenceCountedWriter<T>> entry : 
refCountedWriterMap.entrySet()) {
+            CompletableFuture<SystemTopicClient.Writer<T>> future = 
entry.getValue().getFuture();
+            if (!future.isCompletedExceptionally()) {
+                future.thenAccept(writer -> {
+                    try {
+                        writer.close();
+                    } catch (IOException e) {

Review Comment:
   Maybe catching `Exception` might be safer?



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java:
##########
@@ -740,4 +743,21 @@ protected AsyncLoadingCache<NamespaceName, 
SystemTopicClient.Writer<PulsarEvent>
     }
 
     private static final Logger log = 
LoggerFactory.getLogger(SystemTopicBasedTopicPoliciesService.class);
+
+    @Override
+    public void close() throws Exception {
+        writerCaches.synchronous().invalidateAll();
+        readerCaches.values().forEach(future -> {
+            if (future != null && !future.isCompletedExceptionally()) {
+                future.thenAccept(reader -> {
+                    try {
+                        reader.close();
+                    } catch (IOException e) {

Review Comment:
   Maybe catching `Exception` might be safer?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to