ApiFuture clearTransactionManager()

in cloud-spanner-r2dbc/src/main/java/com/google/cloud/spanner/r2dbc/v2/DatabaseClientTransactionManager.java [106:127]


  ApiFuture<Void> clearTransactionManager() {
    this.txnContextFuture = null;
    this.lastStep = null;
    ApiFuture<Void> returnFuture = ApiFutures.immediateFuture(null);

    if (this.transactionManager != null) {
      // We don't close the transaction manager here if it has already been rolled back.
      // Rolling back a transaction manager automatically also closes it, and returns the underlying
      // session to the pool. Closing it a second time here, would cause it to be added to the pool
      // a second time.
      if (this.transactionManager.getState() != TransactionState.ROLLED_BACK) {
        returnFuture = this.transactionManager.closeAsync();
      }
      this.transactionManager = null;
    }

    if (isInReadonlyTransaction()) {
      closeReadOnlyTransaction();
    }

    return returnFuture;
  }