stanfordnlp/CoreNLP · error · RuntimeIOException

MemoryTreebank.processFile IOException in file

Error message

MemoryTreebank.processFile IOException in file <file>

What it means

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.

Solutions

  1. Verify the file exists and is readable (ls -l, permissions) and re-run; catch RuntimeIOException around load calls to skip bad files.
  2. Check disk/network health if the file is on a mount; re-copy the file locally before processing.
  3. Validate the file is complete (not truncated) — compare size/checksum with the source corpus.
  4. If files may vanish during batch processing, snapshot the file list and check File.canRead() before load.

Example fix

// before
MemoryTreebank tb = new MemoryTreebank();
tb.loadPath(path); // throws RuntimeIOException on bad file
// after
MemoryTreebank tb = new MemoryTreebank();
File f = new File(path);
if (!f.canRead()) { log.warn("Skipping unreadable file: " + path); return; }
try { tb.load(f); } catch (RuntimeIOException e) { log.error("Skipping: " + path, e); }
Defensive patterns

Strategy: try-catch

Validate before calling

File f = new File(path);
if (!f.isFile() || !f.canRead()) {
  throw new IllegalArgumentException("Unreadable treebank file: " + path);
}

Try / catch

try {
  treebank.load(new File(path));
} catch (RuntimeIOException e) {
  log.error("Failed to read treebank file " + path + ": " + e.getMessage());
  // skip or retry with a local copy
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/trees/MemoryTreebank.java:305

//                       break;
//                     }
//                   }
//                   if (allNone) {
//                     fl.set(SRLIDAnnotation.class, SRL_ID.ALL_NO);
//                   } else {
//                     fl.set(SRLIDAnnotation.class, SRL_ID.NO);
//                   }
//                 }
//               }
//              parseTrees.add(t);
            }
          }
        }

        sentIndex++;
      }
    } catch (IOException e) {
      throw new RuntimeIOException("MemoryTreebank.processFile IOException in file " + file, e);
    } finally {
      IOUtils.closeIgnoringExceptions(tr);
    }
  }


  /**
   * Load a collection of parse trees from a Reader.
   * Each tree may optionally be encased in parens to allow for Penn
   * Treebank style trees.
   *
   * @param r The reader to read trees from.  (If you want it buffered,
   *    you should already have buffered it!)
   */
  public void load(Reader r) {
    load(r, null);
  }

View on GitHub (pinned to 1b7edd19c4)