{"record":{"id":"4f6a5ee00f722268","repo":"stanfordnlp/CoreNLP","slug":"java-lang-exception","errorCode":null,"errorMessage":"java.lang.Exception","messagePattern":"java\\.lang\\.Exception","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/quoteattribution/ExtractQuotesUtil.java","lineNumber":39,"sourceCode":"  //return true if one is contained in the other.\n  public static boolean rangeContains(Pair<Integer, Integer> r1, Pair<Integer, Integer> r2) {\n    return ((r1.first <= r2.first && r1.second >= r2.first) || (r1.first <= r2.second && r1.second >= r2.second));\n  }\n  public static Annotation readSerializedProtobufFile(File fileIn)\n  {\n    Annotation annotation;\n    try {\n      ProtobufAnnotationSerializer pas = new ProtobufAnnotationSerializer();\n      InputStream is = new BufferedInputStream(new FileInputStream(fileIn));\n      Pair<Annotation, InputStream> pair = pas.read(is);\n      pair.second.close();\n      annotation = pair.first;\n      IOUtils.closeIgnoringExceptions(is);\n      return annotation;\n    }\n    catch(Exception e)\n    {\n      throw new RuntimeException(e);\n    }\n  }\n\n}\n","sourceCodeStart":21,"sourceCodeEnd":44,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/quoteattribution/ExtractQuotesUtil.java#L21-L44","documentation":"readSerializedProtobufFile deserializes an Annotation from a protobuf file and, on ANY Exception during reading/parsing/closing, wraps it in a RuntimeException at src/edu/stanford/nlp/quoteattribution/ExtractQuotesUtil.java:39. The message is generic because the original exception is only attached as the cause, so the real failure (IO error, protobuf parse failure, class mismatch) must be read from getCause().","triggerScenarios":"Calling ExtractQuotesUtil.readSerializedProtobufFile(path) where the file does not exist, is not a valid protobuf Annotation stream, was produced by an incompatible CoreNLP version, or the input stream fails mid-read.","commonSituations":"Pointing the quote attribution annotator at a serialized file saved by a different CoreNLP version; truncated or hand-edited .ser protobuf files; wrong file path passed as -quoteAttachment.","solutions":["Inspect the cause chain (getCause()) to find the real underlying error.","Verify the file path exists and is readable before calling.","Regenerate the serialized protobuf file with the exact CoreNLP version in use.","Wrap the call in try-catch for RuntimeException and re-read the source file as plain text through the XML pipeline instead."],"exampleFix":"// before\nAnnotation doc = ExtractQuotesUtil.readSerializedProtobufFile(\"quotes.ser\");\n// after\ntry {\n  Annotation doc = ExtractQuotesUtil.readSerializedProtobufFile(\"quotes.ser\");\n} catch (RuntimeException e) {\n  throw new IllegalStateException(\"Bad serialized quotes file: \" + e.getCause(), e);\n}","handlingStrategy":"try-catch","validationCode":"File f = new File(path);\nif (!f.isFile() || f.length() == 0) throw new FileNotFoundException(path);","typeGuard":null,"tryCatchPattern":"try {\n  return ExtractQuotesUtil.readSerializedProtobufFile(path);\n} catch (RuntimeException e) {\n  throw new IllegalStateException(\"Bad serialized file: \" + e.getCause(), e);\n}","preventionTips":["Serialize and deserialize with the same CoreNLP version","Checksum serialized files and verify before loading","Always log e.getCause(), not the wrapper"],"tags":["java","serialization","protobuf","io"],"backgroundTag":"json-unmarshal-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"}