public T execute()

in wrapper/src/main/java/software/amazon/jdbc/plugin/failover/FailoverConnectionPlugin.java [220:275]


  public <T, E extends Exception> T execute(
      final Class<T> resultClass,
      final Class<E> exceptionClass,
      final Object methodInvokeOn,
      final String methodName,
      final JdbcCallable<T, E> jdbcMethodFunc,
      final Object[] jdbcMethodArgs)
      throws E {

    try {
      if (this.enableFailoverSetting
          && !this.canDirectExecute(methodName)
          && !this.closedExplicitly.get()
          && this.pluginService.getCurrentConnection() != null
          && this.pluginService.getCurrentConnection().isClosed()) {
        this.pickNewConnection();
      }
    } catch (SQLException ex) {
      throw WrapperUtils.wrapExceptionIfNeeded(exceptionClass, ex);
    }

    if (!this.enableFailoverSetting || canDirectExecute(methodName)) {
      T result = jdbcMethodFunc.call();
      if (METHOD_ABORT.equals(methodName) || METHOD_CLOSE.equals(methodName)) {
        this.closedExplicitly.set(true);
      }

      return result;
    }

    if (this.isClosed && !allowedOnClosedConnection(methodName)) {
      try {
        invalidInvocationOnClosedConnection();
      } catch (final SQLException ex) {
        throw WrapperUtils.wrapExceptionIfNeeded(exceptionClass, ex);
      }
    }

    T result = null;

    try {
      if (canUpdateTopology(methodName)) {
        updateTopology(false);
      }
      result = jdbcMethodFunc.call();
      if (METHOD_ABORT.equals(methodName) || METHOD_CLOSE.equals(methodName)) {
        this.closedExplicitly.set(true);
      }
    } catch (final IllegalStateException e) {
      dealWithIllegalStateException(e, exceptionClass);
    } catch (final Exception e) {
      this.dealWithOriginalException(e, null, exceptionClass);
    }

    return result;
  }