{"record":{"id":"62c8bdcee9af4ba2","repo":"stanfordnlp/CoreNLP","slug":"runtimeioexception-wrapping-ioexception-from-close","errorCode":null,"errorMessage":"RuntimeIOException wrapping IOException from close","messagePattern":"RuntimeIOException wrapping IOException from close","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/parser/shiftreduce/TreeRecorder.java","lineNumber":64,"sourceCode":"        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":46,"sourceCodeEnd":69,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/shiftreduce/TreeRecorder.java#L46-L69","documentation":"TreeRecorder.display is the cleanup hook that closes the underlying BufferedWriter; a checked IOException during close is rethrown as RuntimeIOException. Close can fail when flushing buffered data to disk, so this error usually means earlier writes could not be fully persisted.","triggerScenarios":"Calling recorder.display(verbose, pw) (which calls out.close()) when the output stream cannot be flushed — disk full, stream already closed/corrupted, or filesystem failure.","commonSituations":"Disk filled during evaluation so the final buffer flush fails; double-closing the recorder after a prior failure; container filesystem that has gone read-only.","solutions":["Ensure adequate disk space before and during the recording run","Call display()/close() exactly once per TreeRecorder instance","Use try/finally so close is attempted and any RuntimeIOException is logged with context","Check the filesystem has not gone read-only (dmesg/mount output) if errors persist"],"exampleFix":"// before\nrecorder.display(verbose, pw);\n// after\ntry {\n  recorder.display(verbose, pw);\n} catch (RuntimeIOException e) {\n  System.err.println(\"Failed to close tree output: \" + e.getMessage());\n}","handlingStrategy":"try-catch","validationCode":"if (p.toFile().getUsableSpace() == 0) throw new IllegalStateException(\"disk full before close\");","typeGuard":null,"tryCatchPattern":"try {\n  recorder.display(verbose, pw);\n} catch (RuntimeIOException e) {\n  log.warning(\"Error closing TreeRecorder: \" + e.getMessage());\n}","preventionTips":["Close each recorder exactly once","Ensure sufficient disk space for buffered flushes","Use try/finally to guarantee close on all paths"],"tags":["java","io","resource-cleanup"],"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-17T15:17:12.973Z"}