languagetool-org/languagetool · error · IllegalArgumentException
Invalid value for cacheSize: , use 0 to deactivate cache
Error message
Invalid value for cacheSize: , use 0 to deactivate cache
What it means
The 'cacheSize' server property controls the size of LanguageTool's result cache and must be >= 0 (0 disables the cache). A negative value is rejected with this IllegalArgumentException during server configuration parsing.
Source
Thrown at languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java:396
throw new IllegalArgumentException("The AfterTheDeadline mode is not supported anymore in LanguageTool 3.8 or later");
}
String rulesConfigFilePath = getOptionalProperty(props, "rulesFile", null);
if (rulesConfigFilePath != null) {
rulesConfigFile = new File(rulesConfigFilePath);
if (!rulesConfigFile.exists() || !rulesConfigFile.isFile()) {
throw new RuntimeException("Rules Configuration file cannot be found: " + rulesConfigFile);
}
}
String remoteRulesConfigFilePath = getOptionalProperty(props, "remoteRulesFile", null);
if (remoteRulesConfigFilePath != null) {
remoteRulesConfigFile = new File(remoteRulesConfigFilePath);
if (!remoteRulesConfigFile.exists() || !remoteRulesConfigFile.isFile()) {
throw new RuntimeException("Remote rules configuration file cannot be found: " + remoteRulesConfigFile);
}
}
cacheSize = Integer.parseInt(getOptionalProperty(props, "cacheSize", "0"));
if (cacheSize < 0) {
throw new IllegalArgumentException("Invalid value for cacheSize: " + cacheSize + ", use 0 to deactivate cache");
}
if (props.containsKey("cacheTTLSeconds") && !props.containsKey("cacheSize")) {
throw new IllegalArgumentException("Use of cacheTTLSeconds without also setting cacheSize has no effect.");
}
cacheTTLSeconds = Integer.parseInt(getOptionalProperty(props, "cacheTTLSeconds", "300"));
maxErrorsPerWordRate = Float.parseFloat(getOptionalProperty(props, "maxErrorsPerWordRate", "0"));
suggestionsEnabled = Boolean.parseBoolean(getOptionalProperty(props, "suggestionsEnabled", "true"));
maxSpellingSuggestions = Integer.parseInt(getOptionalProperty(props, "maxSpellingSuggestions", "0"));
blockedReferrers = Arrays.asList(getOptionalProperty(props, "blockedReferrers", "").split(",\\s*"));
setTrustedSources(getOptionalProperty(props, "trustedSources", null));
String premiumAlwaysValue = props.getProperty("premiumAlways");
if (premiumAlwaysValue != null) {
premiumAlways = Boolean.parseBoolean(premiumAlwaysValue.trim());
if (premiumAlways) {
System.out.println("*** Running in PREMIUM-ALWAYS mode");
}
}
premiumOnly = Boolean.valueOf(getOptionalProperty(props, "premiumOnly", "false").trim());View on GitHub (pinned to 2e990059ce)
Solutions
- Set 'cacheSize=0' in server.properties to disable the cache
- Use a positive value (e.g. cacheSize=1000) to enable the cache with that entry count
- Re-validate provisioning templates that substitute the cacheSize value
Example fix
// before (server.properties) cacheSize=-1 // after (server.properties) cacheSize=0
Defensive patterns
Strategy: validation
Validate before calling
String v = props.getProperty("cacheSize");
if (v != null && Integer.parseInt(v.trim()) < 0) {
throw new IllegalStateException("cacheSize must be >= 0 (0 disables cache)");
} Try / catch
try {
serverConfig = new HTTPServerConfig(props);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Invalid value for cacheSize")) {
props.setProperty("cacheSize", "0");
serverConfig = new HTTPServerConfig(props);
} else { throw e; }
} Prevention
- Remember cacheSize=0 (not -1) disables the cache
- Validate numeric properties after template rendering in provisioning
- Keep a documented, minimal server.properties reference
When it happens
Trigger: Starting the HTTP server with 'cacheSize' set to a negative number (e.g. cacheSize=-1) in the server properties file.
Common situations: Copy-pasted tuning advice that used -1 as 'disabled' (the correct value is 0); variable interpolation in provisioning templates resolving to a negative default.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Use of cacheTTLSeconds without also setting cacheSize has no
- The AfterTheDeadline mode is not supported anymore in Langua
- Rules Configuration file cannot be found:
- Remote rules configuration file cannot be found:
- Cannot use premiumOnly=true with non-premium version
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/86551cb925d6e084.
Report an issue: GitHub.