stanfordnlp/CoreNLP · warning · IllegalArgumentException

Deleting more than 100 files; you should do this manually

Error message

Deleting more than 100 files; you should do this manually

What it means

deleteRecursively counts the files it is about to remove; if more than 100 files would be deleted it throws this IllegalArgumentException, forcing the developer to delete large trees manually rather than by accident.

Solutions

  1. Delete the directory manually (e.g. rm -rf or Files.walk + delete in your own code) after verifying contents
  2. Split the deletion into smaller batches under 100 files each
  3. Write your own recursive delete without this guard if the bulk deletion is intentional

Example fix

// before
IOUtils.deleteRecursively(largeCacheDir); // 10000 files
// after
java.nio.file.Files.walk(largeCacheDir.toPath())
  .sorted(java.util.Comparator.reverseOrder())
  .forEach(p -> p.toFile().delete());
Defensive patterns

Strategy: try-catch

Validate before calling

int n = 0; try (var s = Files.walk(dir.toPath())) { n = (int) s.filter(Files::isRegularFile).count(); } if (n > 100) { /* delete manually */ }

Try / catch

try { IOUtils.deleteRecursively(dir); } catch (IllegalArgumentException e) { if (e.getMessage().contains("more than 100 files")) { /* manual or batched deletion */ } else throw e; }

Prevention

When it happens

Trigger: IOUtils.deleteRecursively on a directory whose recursive file count exceeds 100.

Common situations: Cleanup of build output, caches, or dataset directories that grew past 100 files; pointing the deleter at a large project folder instead of a small scratch dir.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/73d4a58bb271382c. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/io/IOUtils.java:2036

   *   <li>More than 100 files cannot be removed with this function.</li>
   *   <li>More than 10GB cannot be removed with this function.</li>
   * </ul>
   *
   * @param file The file or directory to delete.
   */
  public static void deleteRecursively(File file) {
    // Sanity checks
    if (blockListPathsToRemove.contains(file.getPath())) {
      throw new IllegalArgumentException("You're trying to delete " + file + "! I _really_ don't think you want to do that...");
    }
    int count = 0;
    long size = 0;
    for (File f : iterFilesRecursive(file)) {
      count += 1;
      size += f.length();
    }
    if (count > 100) {
      throw new IllegalArgumentException("Deleting more than 100 files; you should do this manually");
    }
    if (size > 10000000000L) {  // 10 GB
      throw new IllegalArgumentException("Deleting more than 10GB; you should do this manually");
    }
    // Do delete
    if (file.isDirectory()) {
      File[] children = file.listFiles();
      if (children != null) {
        for (File child : children) {
          deleteRecursively(child);
        }
      }
    }
    //noinspection ResultOfMethodCallIgnored
    file.delete();
  }

  /**

View on GitHub (pinned to 1b7edd19c4)