code: private void requestCompleteCallback(CompletableFuture<ConnectionWrapper> connectionFuture, 
                                           Throwable e) {
          // when processing completes, return the connection back to connection manager asynchronously.
          // Note: If result future is complete, connectionFuture is definitely complete. if connectionFuture had failed,
          // we would not have received a connection object anyway. 
          if (e != null) {
              Throwable unwrap = Exceptions.unwrap(e);
              if (hasConnectionFailed(unwrap)) {
                  connectionFuture.thenAccept(connectionObject -> {
                      connectionObject.failConnection();
                      connectionObject.close();
                  });
              } else {
                  connectionFuture.thenAccept(ConnectionWrapper::close);
              }
          } else {
              connectionFuture.thenAccept(ConnectionWrapper::close);
          }
      }
docs: Request Complete callback is invoked when the request is complete, either by sending and receiving a response from
  segment store or by way of failure of connection.
  This is responsible for returning the connection back to the connection pool.
  @param connectionFuture conection future that when completed successfully holds the connection object taken from the pool.
  @param e Exception, if any, thrown from the request processing.