docs: @SuppressWarnings("unchecked")
    protected <T extends RaftRequest> void handleResponse(T request, BiFunction sender, int count, int selectionId, MemberId node, RaftResponse response, Throwable error, CompletableFuture future) {
      if (error == null) {
        log.trace("Received {} from {}", response, node);
        if (COMPLETE_PREDICATE.test(response)) {
          future.complete(response);
          selector.reset();
        } else {
          retryRequest(response.error().createException(), request, sender, count + 1, selectionId, future);
        }
      } else {
        if (error instanceof CompletionException) {
          error = error.getCause();
        }
        log.debug("{} failed! Reason: {}", request, error);
        if (error instanceof SocketException || error instanceof TimeoutException || error instanceof ClosedChannelException) {
          if (count < selector.members().size() + 1) {
            retryRequest(error, request, sender, count + 1, selectionId, future);
          } else {
            future.completeExceptionally(error);
          }
        } else {
          future.completeExceptionally(error);
        }
      }
    }