stanfordnlp/CoreNLP · error · RuntimeIOException

RuntimeIOException wrapping IOException from write

Error message

RuntimeIOException wrapping IOException from write

What it means

TreeRecorder.evaluate writes each parse tree line to the wrapped BufferedWriter; if the underlying write fails with a checked IOException it is rethrown as an unchecked RuntimeIOException. This keeps the evaluator API free of checked exceptions while signaling an I/O failure during recording.

Solutions

  1. Check free disk space on the output volume before starting a long recording run
  2. Ensure nothing deletes or truncates the output file while TreeRecorder is open
  3. Catch RuntimeIOException around evaluate() and persist partial state or abort cleanly
  4. Write to a local, reliable filesystem rather than a flaky network mount

Example fix

// before
recorder.evaluate(query, goldTree, pw);
// after
try {
  recorder.evaluate(query, goldTree, pw);
} catch (RuntimeIOException e) {
  System.err.println("Tree recording failed: " + e.getMessage());
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before long runs
long usable = p.toFile().getUsableSpace();
if (usable < requiredBytes) throw new IllegalStateException("insufficient disk space: " + usable);

Try / catch

try {
  recorder.evaluate(query, gold, pw);
} catch (RuntimeIOException e) {
  log.severe("Write failed while recording trees: " + e.getMessage());
  throw e;
}

Prevention

When it happens

Trigger: Calling recorder.evaluate(parserQuery, goldTree, pw) (or writeNewFile contents) after the output file/stream has become unwritable — disk full, file deleted/closed externally, underlying filesystem error.

Common situations: Long evaluation runs filling the disk mid-write; output file removed while the recorder is open; NFS/network filesystem dropped mid-session.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/parser/shiftreduce/TreeRecorder.java:56

    if (!(query instanceof ShiftReduceParserQuery)) {
      throw new IllegalArgumentException("This evaluator only works for the ShiftReduceParser");
    }
    
    ShiftReduceParserQuery srquery = (ShiftReduceParserQuery) query;
    try {
      switch (mode) {
      case BINARIZED:
        out.write(srquery.getBestBinarizedParse().toString());
        break;
      case DEBINARIZED:
        out.write(srquery.debinarized.toString());
        break;
      default:
        throw new IllegalArgumentException("Unknown mode " + mode);
      }
      out.newLine();
    } catch (IOException e) {
      throw new RuntimeIOException(e);
    }
  }

  public void display(boolean verbose, PrintWriter pw) {
    try {
      out.close();
    } catch (IOException e) {
      throw new RuntimeIOException(e);
    }
  }
  
}

View on GitHub (pinned to 1b7edd19c4)