lordcheng10 commented on a change in pull request #12195:
URL: https://github.com/apache/pulsar/pull/12195#discussion_r720745166



##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
##########
@@ -843,72 +843,78 @@ protected WriteInEventLoopCallback 
newObject(Handle<WriteInEventLoopCallback> ha
 
     @Override
     public CompletableFuture<Void> closeAsync() {
-        final State currentState = getAndUpdateState(state -> {
-            if (state == State.Closed) {
-                return state;
-            }
-            return State.Closing;
-        });
-
-        if (currentState == State.Closed || currentState == State.Closing) {
-            return CompletableFuture.completedFuture(null);
-        }
-
-        Timeout timeout = sendTimeout;
-        if (timeout != null) {
-            timeout.cancel();
-            sendTimeout = null;
-        }
+        CompletableFuture<Void> flushAndCloseFuture = new 
CompletableFuture<>();
+        flushAsync().thenRun(() -> {
+            final State currentState = getAndUpdateState(state -> {
+                if (state == State.Closed) {
+                    return state;
+                }
+                return State.Closing;
+            });

Review comment:
       you are right!




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