{"record":{"id":"da7eb1a2fbddc3bb","repo":"stanfordnlp/CoreNLP","slug":"runtimeexception-wrapping-ioexception","errorCode":null,"errorMessage":"RuntimeException wrapping IOException","messagePattern":"RuntimeException wrapping IOException","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/dcoref/CoNLLMentionExtractor.java","lineNumber":172,"sourceCode":"\n    // Initialize gold mentions\n    List<List<Mention>> allGoldMentions = extractGoldMentions(conllDoc);\n\n    List<List<Mention>> allPredictedMentions;\n    if (Constants.USE_GOLD_MENTIONS) {\n      //allPredictedMentions = allGoldMentions;\n      // Make copy of gold mentions since mentions may be later merged, mentionID's changed and stuff\n      allPredictedMentions = makeCopy(allGoldMentions);\n    } else if (Constants.USE_GOLD_MENTION_BOUNDARIES) {\n      allPredictedMentions = ((RuleBasedCorefMentionFinder) mentionFinder).filterPredictedMentions(allGoldMentions, anno, dictionaries);\n    } else {\n      allPredictedMentions = mentionFinder.extractPredictedMentions(anno, maxID, dictionaries);\n    }\n\n    try {\n      recallErrors(allGoldMentions,allPredictedMentions,anno);\n    } catch (IOException e) {\n      throw new RuntimeException(e);\n    }\n    Document doc = arrange(anno, allWords, allTrees, allPredictedMentions, allGoldMentions, true);\n    doc.conllDoc = conllDoc;\n    return doc;\n  }\n\n  private static List<List<Mention>> makeCopy(List<List<Mention>> mentions) {\n    List<List<Mention>> copy = new ArrayList<>(mentions.size());\n    for (List<Mention> sm:mentions) {\n      List<Mention> sm2 = new ArrayList<>(sm.size());\n      for (Mention m:sm) {\n        Mention m2 = new Mention();\n        m2.goldCorefClusterID = m.goldCorefClusterID;\n        m2.mentionID = m.mentionID;\n        m2.startIndex = m.startIndex;\n        m2.endIndex = m.endIndex;\n        m2.originalSpan = m.originalSpan;\n        m2.dependency = m.dependency;","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/dcoref/CoNLLMentionExtractor.java#L154-L190","documentation":"In CoNLLMentionExtractor.nextDoc, the recallErrors debugging call performs IO (writing gold-vs-predicted mention comparison output). Any IOException it throws is wrapped in a plain RuntimeException so nextDoc's signature stays unchecked. The real problem is the IO performed by recallErrors, not coreference processing itself.","triggerScenarios":"Calling nextDoc with the recallErrors logging enabled (dcoref recall errors output configured) while the target output file/stream cannot be written — bad path, unwritable directory, or already-closed stream.","commonSituations":"Setting the recall error output path to a non-existent directory; running with read-only working directories or restricted container filesystems; disk full while dumping error comparisons.","solutions":["Check the exception's cause (getCause()) for the actual IOException and fix that IO target (create the directory, fix permissions).","Verify the path configured for recall-error logging is writable, or disable recall error logging if not needed.","Ensure sufficient disk space in the output location.","Run in a working directory with write permissions, or redirect debug output to a writable location.","If recallErrors output isn't wanted, avoid enabling that option so no IO occurs in nextDoc."],"exampleFix":"// before\n// recallErrors output path points to /nonexistent/dir/err.txt\n\n// after\nnew File(\"/logs/dcoref\").mkdirs(); // ensure directory exists before running\nprops.setProperty(\"coref.debug.logANEList\", \"false\"); // or disable debug output","handlingStrategy":"try-catch","validationCode":"// Ensure recallErrors output location is writable before running\nFile outDir = new File(recallErrorsOutputDir);\nif (!outDir.exists() && !outDir.mkdirs())\n  throw new IllegalStateException(\"Cannot create recall-errors dir\");\nif (!outDir.canWrite()) throw new IllegalStateException(\"Not writable: \" + outDir);","typeGuard":null,"tryCatchPattern":"try {\n  Document doc = mentionExtractor.nextDoc();\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof IOException) {\n    logger.severe(\"recallErrors IO failed: \" + e.getCause());\n  }\n  throw e;\n}","preventionTips":["Disable recall-error debug logging unless actively debugging.","Guarantee the working directory is writable in deployment (containers often are not).","Monitor disk space on output volumes.","Always log getCause() when catching wrapper RuntimeExceptions."],"tags":["java","io","checked-exception-wrapping","corenlp"],"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"}