{"record":{"id":"206e73134b08b297","repo":"languagetool-org/languagetool","slug":"throw-new-runtimeexception-e","errorCode":null,"errorMessage":"throw new RuntimeException(e)","messagePattern":"throw new RuntimeException\\(e\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/UpperCaseNgramRule.java","lineNumber":542,"sourceCode":"    addExamplePair(Example.wrong(\"This <marker>Prototype</marker> was developed by Miller et al.\"),\n                   Example.fixed(\"This <marker>prototype</marker> was developed by Miller et al.\"));\n    antiPatterns = cacheAntiPatterns(lang, ANTI_PATTERNS);\n\n    initTrie();\n    initSpeller();\n    if (userConfig != null && linguServices == null) {\n      linguServices = userConfig.getLinguServices();\n    }\n  }\n\n  private void initSpeller() {\n    if (spellerRule == null) {\n      synchronized (UpperCaseNgramRule.class) {\n        if (spellerRule == null) {\n          try {\n            spellerRule = new MorfologikAmericanSpellerRule(messages, lang);\n          } catch (IOException e) {\n            throw new RuntimeException(e);\n          }\n        }\n      }\n    }\n  }\n\n  private void initTrie() {\n    if (exceptionTrie == null) {\n      synchronized (UpperCaseNgramRule.class) {\n        if (exceptionTrie == null) {\n          exceptionTrie = new AhoCorasickDoubleArrayTrie<>();\n          CachingWordListLoader cachingWordListLoader = new CachingWordListLoader();\n          List<String> words = new ArrayList<>();\n          words.addAll(cachingWordListLoader.loadWords(\"en/specific_case.txt\"));\n          words.addAll(cachingWordListLoader.loadWords(\"spelling_global.txt\"));\n          Map<String,String> map = new HashMap<>();\n          for (String word : words) {\n            map.put(word, word);","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/UpperCaseNgramRule.java#L524-L560","documentation":"UpperCaseNgramRule.initSpeller lazily creates a MorfologikAmericanSpellerRule inside a double-checked locking block; if constructing that rule throws an IOException (e.g. while loading its binary dictionary resource from the classpath), the IOException is wrapped in a RuntimeException with no additional message.","triggerScenarios":"Building an English LanguageTool instance (which constructs UpperCaseNgramRule) when the Morfologik speller dictionary resource cannot be loaded: corrupted/partial jar, missing resource after a custom build, or I/O error reading the packaged dictionary.","commonSituations":"Rebuilding LanguageTool without running the dictionary-preparation steps; running with a stripped/downsized jar that omitted en spelling data; classloader issues in application servers embedding LanguageTool.","solutions":["Use a complete, official languagetool-language-modules/en artifact/jar containing the Morfologik dictionary","Rebuild the module fully (including spelling resource generation) if building from source","Inspect the wrapped cause e for the underlying IOException (resource not found / corrupted)","Verify classpath integrity: the en dictionary .dict file is present and readable"],"exampleFix":"// before\n<dependency>en module built with -DskipTests and resource filtering removed dict</dependency>\n// after\n<dependency>\n  <groupId>org.languagetool</groupId>\n  <artifactId>language-en</artifactId>\n  <version>matching-full-release-version</version>\n</dependency>","handlingStrategy":"try-catch","validationCode":"// verify the en dictionary resource is on the classpath before building the language\nString dict = \"/org/languagetool/resource/en/hunspell/en_US.dict\"; // adjust to morfologik resource\nif (UpperCaseNgramRule.class.getResource(dict) == null) {\n  throw new IllegalStateException(\"English spelling data missing from classpath\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  LanguageToolRuleSet rules = ...; // constructs English including UpperCaseNgramRule\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof IOException) {\n    log.error(\"Morfologik speller init failed — check en module jar/resources\", e.getCause());\n  } else throw e;\n}","preventionTips":["Ship the full official language-en artifact; never strip spelling resources","Run a smoke test constructing the English language at deploy time","When building from source, complete all dictionary-generation steps"],"tags":["java","initialization","speller"],"backgroundTag":"module-init-failed","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}