{"record":{"id":"11027c82e9b19e25","repo":"stanfordnlp/CoreNLP","slug":"memorytreebank-processfile-ioexception-in-file-fi","errorCode":null,"errorMessage":"MemoryTreebank.processFile IOException in file <file>","messagePattern":"MemoryTreebank\\.processFile IOException in file <file>","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/MemoryTreebank.java","lineNumber":305,"sourceCode":"//                       break;\n//                     }\n//                   }\n//                   if (allNone) {\n//                     fl.set(SRLIDAnnotation.class, SRL_ID.ALL_NO);\n//                   } else {\n//                     fl.set(SRLIDAnnotation.class, SRL_ID.NO);\n//                   }\n//                 }\n//               }\n//              parseTrees.add(t);\n            }\n          }\n        }\n\n        sentIndex++;\n      }\n    } catch (IOException e) {\n      throw new RuntimeIOException(\"MemoryTreebank.processFile IOException in file \" + file, e);\n    } finally {\n      IOUtils.closeIgnoringExceptions(tr);\n    }\n  }\n\n\n  /**\n   * Load a collection of parse trees from a Reader.\n   * Each tree may optionally be encased in parens to allow for Penn\n   * Treebank style trees.\n   *\n   * @param r The reader to read trees from.  (If you want it buffered,\n   *    you should already have buffered it!)\n   */\n  public void load(Reader r) {\n    load(r, null);\n  }\n","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/MemoryTreebank.java#L287-L323","documentation":"MemoryTreebank.processFile reads parse trees from a file, and any IOException raised while reading (disk error, unreadable file, premature EOF mid-tree) is wrapped in a RuntimeIOException identifying the offending file. The library converts the checked exception to runtime form so treebank processing can proceed unchecked.","triggerScenarios":"Calling MemoryTreebank.load/processFile/loadPath on a file that disappears or becomes unreadable during reading, an I/O device error, or a truncated/corrupt file causing the underlying reader to fail mid-tree.","commonSituations":"Reading from network mounts or removable drives that drop the file; permission changes mid-run; files listed by loadPath deleted before processing; NFS stale handles.","solutions":["Verify the file exists and is readable (ls -l, permissions) and re-run; catch RuntimeIOException around load calls to skip bad files.","Check disk/network health if the file is on a mount; re-copy the file locally before processing.","Validate the file is complete (not truncated) — compare size/checksum with the source corpus.","If files may vanish during batch processing, snapshot the file list and check File.canRead() before load."],"exampleFix":"// before\nMemoryTreebank tb = new MemoryTreebank();\ntb.loadPath(path); // throws RuntimeIOException on bad file\n// after\nMemoryTreebank tb = new MemoryTreebank();\nFile f = new File(path);\nif (!f.canRead()) { log.warn(\"Skipping unreadable file: \" + path); return; }\ntry { tb.load(f); } catch (RuntimeIOException e) { log.error(\"Skipping: \" + path, e); }","handlingStrategy":"try-catch","validationCode":"File f = new File(path);\nif (!f.isFile() || !f.canRead()) {\n  throw new IllegalArgumentException(\"Unreadable treebank file: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  treebank.load(new File(path));\n} catch (RuntimeIOException e) {\n  log.error(\"Failed to read treebank file \" + path + \": \" + e.getMessage());\n  // skip or retry with a local copy\n}","preventionTips":["Copy corpus files to local disk before batch processing instead of reading from network shares.","Check File.canRead() and file integrity (size/checksum) before loading.","Wrap per-file loads so one bad file doesn't abort the whole treebank run."],"tags":["io","file-read","treebank","runtime-io-exception"],"backgroundTag":"file-read-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}