private void retry()

in folsom/src/main/java/com/spotify/folsom/reconnect/ReconnectingClient.java [216:263]


  private void retry() {
    try {
      final CompletionStage<RawMemcacheClient> future = connector.connect();
      future.whenComplete(
          (newClient, t) -> {
            if (t != null) {
              this.reconnectionListener.connectionFailure(t);

              if (t instanceof CompletionException
                  && t.getCause() instanceof MemcacheAuthenticationException) {
                connectionFailure = t.getCause();
                shutdown();
                return;
              }
              ReconnectingClient.this.onFailure(t);
            } else {
              reconnectionListener.reconnectionSuccessful(address, reconnectCount, stayConnected);
              reconnectCount = 0;
              client.shutdown();
              client = newClient;

              // Protection against races with shutdown()
              if (!stayConnected) {
                reconnectionListener.reconnectionCancelled();
                newClient.shutdown();
                notifyConnectionChange();
                return;
              }

              notifyConnectionChange();
              newClient
                  .disconnectFuture()
                  .whenComplete(
                      (unused, throwable) ->
                          reconnectionListener.connectionLost(throwable, address))
                  .thenRun(
                      () -> {
                        notifyConnectionChange();
                        if (stayConnected) {
                          retry();
                        }
                      });
            }
          });
    } catch (final Exception e) {
      ReconnectingClient.this.onFailure(e);
    }
  }