{"record":{"id":"1008e2f8b7403e94","repo":"languagetool-org/languagetool","slug":"could-not-load-coherency-data-from-path","errorCode":null,"errorMessage":"Could not load coherency data from \" + path","messagePattern":"Could not load coherency data from \" \\+ path","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"languagetool-core/src/main/java/org/languagetool/rules/WordCoherencyDataLoader.java","lineNumber":66,"sourceCode":"          continue;\n        }\n        String[] parts = line.split(\";\");\n        if (parts.length != 2) {\n          throw new IOException(\"Format error in file \" + path + \", line: \" + line);\n        }\n        if(map.containsKey(parts[0])) {\n          map.get(parts[0]).add(parts[1]);\n        } else {\n          map.put(parts[0], Stream.of(parts[1]).collect(Collectors.toCollection(ObjectOpenHashSet::new)));\n        }\n        if(map.containsKey(parts[1])) {\n          map.get(parts[1]).add(parts[0]);\n        } else {\n          map.put(parts[1], Stream.of(parts[0]).collect(Collectors.toCollection(ObjectOpenHashSet::new)));\n        }\n      }\n    } catch (IOException e) {\n      throw new RuntimeException(\"Could not load coherency data from \" + path, e);\n    }\n    return Collections.unmodifiableMap(map);\n  }\n\n}\n","sourceCodeStart":48,"sourceCodeEnd":72,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/WordCoherencyDataLoader.java#L48-L72","documentation":"WordCoherencyDataLoader.loadWords wraps any IOException raised while reading the coherency data file in this RuntimeException, keeping the original as cause. It signals the coherency data at 'path' could not be read at all (missing file, unreadable, I/O failure), as opposed to a single bad line.","triggerScenarios":"loadFromPath pointing at a non-existent or unreadable coherency data file; disk I/O error while BufferedReader reads the stream; resource path missing from the language's jar.","commonSituations":"Wrong language resource path in rule construction; file not packaged into the jar after renaming; permission issues in deployment environments.","solutions":["Check the cause (getCause()) for the underlying IOException — usually FileNotFoundException.","Verify the resource path exists on the classpath / filesystem for the given language.","Ensure the data file is included in the build/packaging and readable at runtime."],"exampleFix":"// before\nloader.loadWords(\"/en/coherency.txt\", language);\n// after: verify resource exists first\nif (getClass().getResource(\"/en/coherency.txt\") == null) throw new IllegalStateException(\"coherency data missing\");\nloader.loadWords(\"/en/coherency.txt\", language);","handlingStrategy":"try-catch","validationCode":"// verify resource exists before loading\nif (getClass().getResource(path) == null)\n    throw new IllegalStateException(\"Coherency data not on classpath: \" + path);","typeGuard":null,"tryCatchPattern":"try {\n    loader.loadWords(path, language);\n} catch (RuntimeException e) {\n    // inspect e.getCause() for the underlying IOException\n    throw new IllegalStateException(\"Cannot read coherency data \" + path, e);\n}","preventionTips":["Always inspect getCause() for the root IOException","Verify data files are packaged in the jar","Check file permissions in deployment environments"],"tags":["java","io","resource-loading","languagetool"],"backgroundTag":"file-read-failed","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}