{"record":{"id":"48dfc9ad92aa59a5","repo":"stanfordnlp/CoreNLP","slug":"attempt-to-make-objectbank-with-empty-file-list","errorCode":null,"errorMessage":"Attempt to make ObjectBank with empty file list","messagePattern":"Attempt to make ObjectBank with empty file list","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java","lineNumber":907,"sourceCode":"        files.add(file);\n      }\n    }\n\n    if (files.isEmpty()) {\n      throw new RuntimeException(\"No matching files: \" + baseDir + '\\t' + filePattern);\n    }\n    // return new ObjectBank<List<IN>>(new\n    // ResettableReaderIteratorFactory(files, flags.inputEncoding),\n    // readerAndWriter);\n    // TODO get rid of ObjectBankWrapper\n    return new ObjectBankWrapper<>(flags, new ObjectBank<>(new ResettableReaderIteratorFactory(files,\n            flags.inputEncoding), readerAndWriter), knownLCWords);\n  }\n\n  public ObjectBank<List<IN>> makeObjectBankFromFiles(Collection<File> files,\n                                                      DocumentReaderAndWriter<IN> readerAndWriter) {\n    if (files.isEmpty()) {\n      throw new RuntimeException(\"Attempt to make ObjectBank with empty file list\");\n    }\n    // return new ObjectBank<List<IN>>(new\n    // ResettableReaderIteratorFactory(files, flags.inputEncoding),\n    // readerAndWriter);\n    // TODO get rid of ObjectBankWrapper\n    return new ObjectBankWrapper<>(flags, new ObjectBank<>(new ResettableReaderIteratorFactory(files,\n            flags.inputEncoding), readerAndWriter), knownLCWords);\n  }\n\n  /**\n   * Set up an ObjectBank that will allow one to iterate over a collection of\n   * documents obtained from the passed in Reader. Each document will be\n   * represented as a list of IN. If the ObjectBank iterator() is called until\n   * hasNext() returns false, then the Reader will be read till end of file, but\n   * no reading is done at the time of this call. Reading is done using the\n   * reading method specified in {@code flags.documentReader}, and for some\n   * reader choices, the column mapping given in {@code flags.map}.\n   *","sourceCodeStart":889,"sourceCodeEnd":925,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java#L889-L925","documentation":"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.","triggerScenarios":"Calling classifier.makeObjectBankFromFiles(Collections.emptyList(), readerAndWriter), or passing the result of a directory scan that matched nothing.","commonSituations":"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.","solutions":["Check files.isEmpty() (and that each File exists/can be read) before calling","Fix the upstream file-collection logic so it actually finds the input files","If zero files can legitimately happen, guard the call site and skip or report instead of invoking"],"exampleFix":"// before\nclassifier.makeObjectBankFromFiles(files, rw);\n// after\nif (files == null || files.isEmpty()) {\n  throw new IllegalArgumentException(\"No input files provided\");\n}\nclassifier.makeObjectBankFromFiles(files, rw);","handlingStrategy":"validation","validationCode":"if (files == null || files.isEmpty() || files.stream().anyMatch(f -> !f.canRead()))\n  throw new IllegalArgumentException(\"Input file list must be non-empty and readable\");","typeGuard":"boolean usable = files != null && !files.isEmpty();","tryCatchPattern":"try { bank = classifier.makeObjectBankFromFiles(files, rw); }\ncatch (RuntimeException e) { if (e.getMessage().contains(\"empty file list\")) { /* handle no-input case */ } throw e; }","preventionTips":["Check collection size at the call site before invoking the pipeline","Fail fast when upstream discovery yields zero files","Log which filter dropped all files"],"tags":["io","empty-input","validation"],"backgroundTag":"empty-required-field","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}