tisonkun commented on code in PR #20595:
URL: https://github.com/apache/pulsar/pull/20595#discussion_r1241705321


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionHandler.java:
##########
@@ -81,31 +91,44 @@ protected void grabCnx() {
             } else {
                 cnxFuture = state.client.getConnection(state.topic); //
             }
-            cnxFuture.thenAccept(cnx -> connection.connectionOpened(cnx)) //
-                    .exceptionally(this::handleConnectionError);
+            cnxFuture.whenComplete((cnx, e) -> {
+                try {
+                    final CompletableFuture<Void> future = 
connection.handleNewConnection(cnx, convertThrowable(e));
+                    if (e != null) {
+                        State state = this.state.getState();
+                        if (state == State.Uninitialized || state == 
State.Connecting || state == State.Ready) {
+                            reconnectLater(e);

Review Comment:
   That is, `reconnectLater` calls `CLIENT_CNX_UPDATER.set(this, null);` while 
`handleNewConnection` calls `CLIENT_CNX_UPDATER.set(this, clientCnx);` on 
normal case. It's not quite intuitive but depend on implement details so I'm 
concerned that it can be brittle.



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