@Contract("_, _, !null -> fail")
  public static void closeAll(@NotNull AutoCloseable @NotNull [] cleanupArray, boolean reversed,
                              @Nullable Throwable throwable) throws Exception {
    for (int i = 0; i < cleanupArray.length; i++) {
      AutoCloseable closeable = cleanupArray[reversed ? cleanupArray.length - 1 - i : i];
      try {
        closeable.close();
      }
      catch (Throwable t) {
        if (throwable == null) {
          throwable = t;
        }
        else {
          throwable.addSuppressed(t);
        }
      }
    }
    if (throwable instanceof Exception) {
      throw (Exception)throwable;
    }
    ExceptionUtil.rethrowAllAsUnchecked(throwable);
  }
@Contract("_, _, !null -> fail")
  public static void closeAll(@NotNull AutoCloseable @NotNull [] cleanupArray, boolean reversed,
                              @Nullable Throwable throwable)