{"record":{"id":"184b5ff03fe53625","repo":"stanfordnlp/CoreNLP","slug":"runtimeioexception-wrapping-ioexception-from-write","errorCode":null,"errorMessage":"RuntimeIOException wrapping IOException from write","messagePattern":"RuntimeIOException wrapping IOException from write","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/shiftreduce/TreeRecorder.java","lineNumber":56,"sourceCode":"    if (!(query instanceof ShiftReduceParserQuery)) {\n      throw new IllegalArgumentException(\"This evaluator only works for the ShiftReduceParser\");\n    }\n    \n    ShiftReduceParserQuery srquery = (ShiftReduceParserQuery) query;\n    try {\n      switch (mode) {\n      case BINARIZED:\n        out.write(srquery.getBestBinarizedParse().toString());\n        break;\n      case DEBINARIZED:\n        out.write(srquery.debinarized.toString());\n        break;\n      default:\n        throw new IllegalArgumentException(\"Unknown mode \" + mode);\n      }\n      out.newLine();\n    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    }\n  }\n\n  public void display(boolean verbose, PrintWriter pw) {\n    try {\n      out.close();\n    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    }\n  }\n  \n}\n","sourceCodeStart":38,"sourceCodeEnd":69,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/shiftreduce/TreeRecorder.java#L38-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"Long evaluation runs filling the disk mid-write; output file removed while the recorder is open; NFS/network filesystem dropped mid-session.","solutions":["Check free disk space on the output volume before starting a long recording run","Ensure nothing deletes or truncates the output file while TreeRecorder is open","Catch RuntimeIOException around evaluate() and persist partial state or abort cleanly","Write to a local, reliable filesystem rather than a flaky network mount"],"exampleFix":"// before\nrecorder.evaluate(query, goldTree, pw);\n// after\ntry {\n  recorder.evaluate(query, goldTree, pw);\n} catch (RuntimeIOException e) {\n  System.err.println(\"Tree recording failed: \" + e.getMessage());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// before long runs\nlong usable = p.toFile().getUsableSpace();\nif (usable < requiredBytes) throw new IllegalStateException(\"insufficient disk space: \" + usable);","typeGuard":null,"tryCatchPattern":"try {\n  recorder.evaluate(query, gold, pw);\n} catch (RuntimeIOException e) {\n  log.severe(\"Write failed while recording trees: \" + e.getMessage());\n  throw e;\n}","preventionTips":["Monitor free disk space during long evaluations","Never delete or truncate the output file while open","Write to reliable local filesystems"],"tags":["java","io","file-write"],"backgroundTag":"file-write-failed","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"}