Program: 145395
Project: 145395
Buggy source:
public int executeUpdate(SqlCompiledQuery aQuery,Consumer<Integer> onSuccess,Consumer<Exception> onFailure) throws Exception {
  Callable<Integer> doWork=() -> {
    int rowsAffected=0;
    DataSource dataSource=obtainDataSource(aQuery.getDatasourceName());
    if (dataSource != null) {
      try (Connection connection=dataSource.getConnection();PreparedStatement stmt=connection.prepareStatement(aQuery.getSqlClause())){
        connection.setAutoCommit(false);
        Parameters params=aQuery.getParameters();
        for (int i=1; i <= params.getParametersCount(); i++) {
          Parameter param=params.get(i);
          int jdbcType=JdbcFlowProvider.assumeJdbcType(param.getValue());
          JdbcFlowProvider.assign(param.getValue(),i,stmt,jdbcType,null);
        }
        try {
          rowsAffected+=stmt.executeUpdate();
          connection.commit();
        }
 catch (        SQLException ex) {
          connection.rollback();
          throw ex;
        }
      }
     }
    return rowsAffected;
  }
;
  if (onSuccess != null) {
    Scripts.Space space=Scripts.getSpace();
    startJdbcTask(() -> {
      try {
        Integer affected=doWork.call();
        space.process(() -> {
          onSuccess.accept(affected);
        }
);
      }
 catch (      Exception ex) {
        if (onFailure != null) {
          space.process(() -> {
            onFailure.accept(ex);
          }
);
        }
      }
    }
);
    return 0;
  }
 else {
    return doWork.call();
  }
}

Fixed version (ground truth):
public int executeUpdate(SqlCompiledQuery aQuery,Consumer<Integer> onSuccess,Consumer<Exception> onFailure) throws Exception {
  Callable<Integer> doWork=() -> {
    int rowsAffected=0;
    DataSource dataSource=obtainDataSource(aQuery.getDatasourceName());
    if (dataSource != null) {
      try (Connection connection=dataSource.getConnection()){
        boolean autoCommit=connection.getAutoCommit();
        try {
          connection.setAutoCommit(false);
          try (PreparedStatement stmt=connection.prepareStatement(aQuery.getSqlClause())){
            Parameters params=aQuery.getParameters();
            for (int i=1; i <= params.getParametersCount(); i++) {
              Parameter param=params.get(i);
              int jdbcType=JdbcFlowProvider.assumeJdbcType(param.getValue());
              JdbcFlowProvider.assign(param.getValue(),i,stmt,jdbcType,null);
            }
            try {
              rowsAffected+=stmt.executeUpdate();
              connection.commit();
            }
 catch (            SQLException ex) {
              connection.rollback();
              throw ex;
            }
          }
         }
  finally {
          connection.setAutoCommit(autoCommit);
        }
      }
     }
    return rowsAffected;
  }
;
  if (onSuccess != null) {
    Scripts.Space space=Scripts.getSpace();
    startJdbcTask(() -> {
      try {
        Integer affected=doWork.call();
        space.process(() -> {
          onSuccess.accept(affected);
        }
);
      }
 catch (      Exception ex) {
        if (onFailure != null) {
          space.process(() -> {
            onFailure.accept(ex);
          }
);
        }
      }
    }
);
    return 0;
  }
 else {
    return doWork.call();
  }
}