{"record":{"id":"5a2a98c60d14bf5b","repo":"stanfordnlp/CoreNLP","slug":"runtimeioexception","errorCode":null,"errorMessage":"RuntimeIOException","messagePattern":"RuntimeIOException","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/dcoref/SieveCoreferenceSystem.java","lineNumber":1045,"sourceCode":"    }\n    for (int removeId : removeClusterSet){\n      document.corefClusters.remove(removeId);\n    }\n    for(Mention m : removeSet){\n      document.positions.remove(m);\n    }\n  }\n\n  public static LogisticClassifier<String, String> getSingletonPredictorFromSerializedFile(String serializedFile) {\n    try {\n      ObjectInputStream ois = IOUtils.readStreamFromString(serializedFile);\n      Object o = ois.readObject();\n      if (o instanceof LogisticClassifier<?, ?>) {\n        return (LogisticClassifier<String, String>) o;\n      }\n      throw new ClassCastException(\"Wanted SingletonPredictor, got \" + o.getClass());\n    } catch (IOException e) {\n      throw new RuntimeIOException(e);\n    } catch (ClassNotFoundException e) {\n      throw new RuntimeException(e);\n    }\n  }\n\n  /** Remove singleton clusters */\n  public static List<List<Mention>> filterMentionsWithSingletonClusters(Document document, List<List<Mention>> mentions)\n  {\n\n    List<List<Mention>> res = new ArrayList<>(mentions.size());\n    for (List<Mention> ml:mentions) {\n      List<Mention> filtered = new ArrayList<>();\n      for (Mention m:ml) {\n        CorefCluster cluster = document.corefClusters.get(m.corefClusterID);\n        if (cluster != null && cluster.getCorefMentions().size() > 1) {\n          filtered.add(m);\n        }\n      }","sourceCodeStart":1027,"sourceCodeEnd":1063,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/dcoref/SieveCoreferenceSystem.java#L1027-L1063","documentation":"RuntimeIOException (a RuntimeException wrapper) is thrown when reading the serialized singleton predictor model file fails with an IOException — e.g. the file cannot be opened, is missing, or I/O fails mid-read. It surfaces IO problems from IOUtils.readStreamFromString / ObjectInputStream as an unchecked exception.","triggerScenarios":"Calling the singleton predictor loader with a serializedFile path that does not exist, is not readable, is a directory, or whose stream errors during deserialization.","commonSituations":"Wrong model path in dcoref properties; model file not shipped/downloaded; running from a jar/resource path that doesn't resolve; permission problems on the model file.","solutions":["Check the model file path exists and is readable (ls / canRead)","Correct the singletonModel (or equivalent) property to the right resource path","Regenerate or re-download the model file if it is truncated/corrupt","Catch RuntimeIOException around model loading to give a clearer user-facing error"],"exampleFix":"// before\nSingletonPredictor predictor = SieveCoreferenceSystem.loadSingletonPredictor(\"models/single.ser\");\n// after\nFile f = new File(\"models/single.ser\");\nif (!f.exists() || !f.canRead()) throw new IllegalArgumentException(\"Missing singleton model: \" + f);\nSingletonPredictor predictor = SieveCoreferenceSystem.loadSingletonPredictor(f.getPath());","handlingStrategy":"try-catch","validationCode":"File f = new File(path);\nif (!f.exists()) throw new FileNotFoundException(\"Singleton model missing: \" + path);\nif (!f.canRead()) throw new IOException(\"No read permission: \" + path);","typeGuard":null,"tryCatchPattern":"try {\n  SingletonPredictor p = SieveCoreferenceSystem.loadSingletonPredictor(path);\n} catch (RuntimeIOException e) {\n  throw new IllegalStateException(\"Failed to load singleton predictor model at \" + path, e);\n}","preventionTips":["Verify model file paths at application startup","Ship model files with the application or fail fast with clear messages","Check file permissions in deployment environments","Validate resource strings you pass to IOUtils.readStreamFromString"],"tags":["java","ioexception","file-read","dcoref"],"backgroundTag":"file-read-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"}