{"record":{"id":"e23d2f740412e36b","repo":"languagetool-org/languagetool","slug":"varname-cannot-be-empty-or-whitespace-only","errorCode":null,"errorMessage":"${varName} cannot be empty or whitespace only","messagePattern":"(.+?) cannot be empty or whitespace only","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/tools/StringTools.java","lineNumber":139,"sourceCode":"      \"kein\", \"keines\", \"keinem\", \"keinen\", \"keiner\", \"keine\"))\n  );\n  private static final Set<String> DUTCH_TITLECASE_EXCEPTIONS = Collections.unmodifiableSet(\n    new HashSet<>(Arrays.asList(\"van\", \"in\", \"de\", \"het\", \"een\", \"en\", \"of\"))\n  );\n\n  private static final Set<String> ALL_TITLECASE_EXCEPTIONS = collectAllTitleCaseExceptions();\n\n  private StringTools() {\n    // only static stuff\n  }\n\n  /**\n   * Throw exception if the given string is null or empty or only whitespace.\n   */\n  public static void assureSet(String s, String varName) {\n    Objects.requireNonNull(varName);\n    if (isEmpty(s.trim())) {\n      throw new IllegalArgumentException(varName + \" cannot be empty or whitespace only\");\n    }\n  }\n\n  /**\n   * Read the text stream using the given encoding.\n   *\n   * @param stream InputStream the stream to be read\n   * @param encoding the stream's character encoding, e.g. {@code utf-8}, or {@code null} to use the system encoding\n   * @return a string with the stream's content, lines separated by {@code \\n} (note that {@code \\n} will\n   *  be added to the last line even if it is not in the stream)\n   * @since 2.3\n   */\n  public static String readStream(InputStream stream, String encoding) throws IOException {\n    InputStreamReader isr = null;\n    StringBuilder sb = new StringBuilder();\n    try {\n      if (encoding == null) {\n        isr = new InputStreamReader(stream);","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/tools/StringTools.java#L121-L157","documentation":"A guard in StringTools.assureSet that rejects a required argument: the variable named by varName was null, empty, or only whitespace when a non-blank value is mandatory.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/tools/StringTools.java:139 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-empty, non-whitespace-only value for the offending argument","Validate user input before calling assureSet and prompt for a real value"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}