asafm commented on code in PR #16758:
URL: https://github.com/apache/pulsar/pull/16758#discussion_r958488458


##########
pulsar-transaction/coordinator/src/main/java/org/apache/pulsar/transaction/coordinator/impl/TxnLogBufferedWriter.java:
##########
@@ -374,46 +373,42 @@ private void doFlush(){
     /**
      * Release resources and cancel pending tasks.
      */
-    @Override
-    public void close() {
+    public CompletableFuture<Void> close() {
         // If batch feature is disabled, there is nothing to close, so set the 
stat only.
         if (!batchEnabled) {
             STATE_UPDATER.compareAndSet(this, State.OPEN, State.CLOSED);
-            return;
+            return CompletableFuture.completedFuture(null);
         }
         // If other thread already called "close()", so do nothing.
         if (!STATE_UPDATER.compareAndSet(this, State.OPEN, State.CLOSING)){
-            return;
+            return CompletableFuture.completedFuture(null);
         }
+        CompletableFuture closeFuture = new CompletableFuture();
         // Cancel pending tasks and release resources.
         singleThreadExecutorForWrite.execute(() -> {
             try {
                 if (state == State.CLOSED) {
+                    closeFuture.complete(null);
                     return;
                 }
                 // If some requests are flushed, BK will trigger these 
callbacks, and the remaining requests in should
                 // fail.
-                failureCallbackByContextAndRecycle(flushContext, 
BUFFERED_WRITER_CLOSED_EXCEPTION);
+                failureCallbackByContextAndRecycle(flushContext,

Review Comment:
   Sounds good



-- 
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