languagetool-org/languagetool · error · IllegalArgumentException
${varName} cannot be empty or whitespace only
Error message
${varName} cannot be empty or whitespace only What it means
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.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/tools/StringTools.java:139
"kein", "keines", "keinem", "keinen", "keiner", "keine"))
);
private static final Set<String> DUTCH_TITLECASE_EXCEPTIONS = Collections.unmodifiableSet(
new HashSet<>(Arrays.asList("van", "in", "de", "het", "een", "en", "of"))
);
private static final Set<String> ALL_TITLECASE_EXCEPTIONS = collectAllTitleCaseExceptions();
private StringTools() {
// only static stuff
}
/**
* Throw exception if the given string is null or empty or only whitespace.
*/
public static void assureSet(String s, String varName) {
Objects.requireNonNull(varName);
if (isEmpty(s.trim())) {
throw new IllegalArgumentException(varName + " cannot be empty or whitespace only");
}
}
/**
* Read the text stream using the given encoding.
*
* @param stream InputStream the stream to be read
* @param encoding the stream's character encoding, e.g. {@code utf-8}, or {@code null} to use the system encoding
* @return a string with the stream's content, lines separated by {@code \n} (note that {@code \n} will
* be added to the last line even if it is not in the stream)
* @since 2.3
*/
public static String readStream(InputStream stream, String encoding) throws IOException {
InputStreamReader isr = null;
StringBuilder sb = new StringBuilder();
try {
if (encoding == null) {
isr = new InputStreamReader(stream);View on GitHub (pinned to 2e990059ce)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/tools/StringTools.java:139 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/e23d2f740412e36b.
Report an issue: GitHub.