stanfordnlp/CoreNLP · error · RuntimeException

Attempt to make ObjectBank with empty file list

Error message

Attempt to make ObjectBank with empty file list

What it means

makeObjectBankFromFiles requires a non-empty collection of input files; an empty collection would yield an ObjectBank over nothing, so it throws a RuntimeException immediately. It is an explicit input sanity check.

Solutions

  1. Check files.isEmpty() (and that each File exists/can be read) before calling
  2. Fix the upstream file-collection logic so it actually finds the input files
  3. If zero files can legitimately happen, guard the call site and skip or report instead of invoking

Example fix

// before
classifier.makeObjectBankFromFiles(files, rw);
// after
if (files == null || files.isEmpty()) {
  throw new IllegalArgumentException("No input files provided");
}
classifier.makeObjectBankFromFiles(files, rw);
Defensive patterns

Strategy: validation

Validate before calling

if (files == null || files.isEmpty() || files.stream().anyMatch(f -> !f.canRead()))
  throw new IllegalArgumentException("Input file list must be non-empty and readable");

Type guard

boolean usable = files != null && !files.isEmpty();

Try / catch

try { bank = classifier.makeObjectBankFromFiles(files, rw); }
catch (RuntimeException e) { if (e.getMessage().contains("empty file list")) { /* handle no-input case */ } throw e; }

Prevention

When it happens

Trigger: Calling classifier.makeObjectBankFromFiles(Collections.emptyList(), readerAndWriter), or passing the result of a directory scan that matched nothing.

Common situations: File list built by filtering that discarded everything (wrong extensions); caller passed an unset/never-populated list; upstream file discovery returned empty due to path mistakes.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java:907

        files.add(file);
      }
    }

    if (files.isEmpty()) {
      throw new RuntimeException("No matching files: " + baseDir + '\t' + filePattern);
    }
    // return new ObjectBank<List<IN>>(new
    // ResettableReaderIteratorFactory(files, flags.inputEncoding),
    // readerAndWriter);
    // TODO get rid of ObjectBankWrapper
    return new ObjectBankWrapper<>(flags, new ObjectBank<>(new ResettableReaderIteratorFactory(files,
            flags.inputEncoding), readerAndWriter), knownLCWords);
  }

  public ObjectBank<List<IN>> makeObjectBankFromFiles(Collection<File> files,
                                                      DocumentReaderAndWriter<IN> readerAndWriter) {
    if (files.isEmpty()) {
      throw new RuntimeException("Attempt to make ObjectBank with empty file list");
    }
    // return new ObjectBank<List<IN>>(new
    // ResettableReaderIteratorFactory(files, flags.inputEncoding),
    // readerAndWriter);
    // TODO get rid of ObjectBankWrapper
    return new ObjectBankWrapper<>(flags, new ObjectBank<>(new ResettableReaderIteratorFactory(files,
            flags.inputEncoding), readerAndWriter), knownLCWords);
  }

  /**
   * Set up an ObjectBank that will allow one to iterate over a collection of
   * documents obtained from the passed in Reader. Each document will be
   * represented as a list of IN. If the ObjectBank iterator() is called until
   * hasNext() returns false, then the Reader will be read till end of file, but
   * no reading is done at the time of this call. Reading is done using the
   * reading method specified in {@code flags.documentReader}, and for some
   * reader choices, the column mapping given in {@code flags.map}.
   *

View on GitHub (pinned to 1b7edd19c4)