tisonkun commented on code in PR #20595:
URL: https://github.com/apache/pulsar/pull/20595#discussion_r1241702589
##########
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:
Although generally the timer will schedule the reconnect after
`handleNewConnection` finished, I'm thinking of building an explicit
happens-before order bwteen these two calls.
What if we retain `connectionOpened` and `connectionFailed` but change them
to async and handle them separately in `thenAccept` and `exceptionally`? It
seems easier to reason.
--
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]