{"record":{"id":"86551cb925d6e084","repo":"languagetool-org/languagetool","slug":"invalid-value-for-cachesize-use-0-to-deactivate","errorCode":null,"errorMessage":"Invalid value for cacheSize: , use 0 to deactivate cache","messagePattern":"Invalid value for cacheSize: , use 0 to deactivate cache","errorType":"console","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java","lineNumber":396,"sourceCode":"          throw new IllegalArgumentException(\"The AfterTheDeadline mode is not supported anymore in LanguageTool 3.8 or later\");\n        }\n        String rulesConfigFilePath = getOptionalProperty(props, \"rulesFile\", null);\n        if (rulesConfigFilePath != null) {\n          rulesConfigFile = new File(rulesConfigFilePath);\n          if (!rulesConfigFile.exists() || !rulesConfigFile.isFile()) {\n            throw new RuntimeException(\"Rules Configuration file cannot be found: \" + rulesConfigFile);\n          }\n        }\n        String remoteRulesConfigFilePath = getOptionalProperty(props, \"remoteRulesFile\", null);\n        if (remoteRulesConfigFilePath != null) {\n          remoteRulesConfigFile = new File(remoteRulesConfigFilePath);\n          if (!remoteRulesConfigFile.exists() || !remoteRulesConfigFile.isFile()) {\n            throw new RuntimeException(\"Remote rules configuration file cannot be found: \" + remoteRulesConfigFile);\n          }\n        }\n        cacheSize = Integer.parseInt(getOptionalProperty(props, \"cacheSize\", \"0\"));\n        if (cacheSize < 0) {\n          throw new IllegalArgumentException(\"Invalid value for cacheSize: \" + cacheSize + \", use 0 to deactivate cache\");\n        }\n        if (props.containsKey(\"cacheTTLSeconds\") && !props.containsKey(\"cacheSize\")) {\n          throw new IllegalArgumentException(\"Use of cacheTTLSeconds without also setting cacheSize has no effect.\");\n        }\n        cacheTTLSeconds = Integer.parseInt(getOptionalProperty(props, \"cacheTTLSeconds\", \"300\"));\n        maxErrorsPerWordRate = Float.parseFloat(getOptionalProperty(props, \"maxErrorsPerWordRate\", \"0\"));\n        suggestionsEnabled = Boolean.parseBoolean(getOptionalProperty(props, \"suggestionsEnabled\", \"true\"));\n        maxSpellingSuggestions = Integer.parseInt(getOptionalProperty(props, \"maxSpellingSuggestions\", \"0\"));\n        blockedReferrers = Arrays.asList(getOptionalProperty(props, \"blockedReferrers\", \"\").split(\",\\\\s*\"));\n        setTrustedSources(getOptionalProperty(props, \"trustedSources\", null));\n        String premiumAlwaysValue = props.getProperty(\"premiumAlways\");\n        if (premiumAlwaysValue != null) {\n          premiumAlways = Boolean.parseBoolean(premiumAlwaysValue.trim());\n          if (premiumAlways) {\n            System.out.println(\"*** Running in PREMIUM-ALWAYS mode\");\n          }\n        }\n        premiumOnly = Boolean.valueOf(getOptionalProperty(props, \"premiumOnly\", \"false\").trim());","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java#L378-L414","documentation":"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.","triggerScenarios":"Starting the HTTP server with 'cacheSize' set to a negative number (e.g. cacheSize=-1) in the server properties file.","commonSituations":"Copy-pasted tuning advice that used -1 as 'disabled' (the correct value is 0); variable interpolation in provisioning templates resolving to a negative default.","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"],"exampleFix":"// before (server.properties)\ncacheSize=-1\n\n// after (server.properties)\ncacheSize=0","handlingStrategy":"validation","validationCode":"String v = props.getProperty(\"cacheSize\");\nif (v != null && Integer.parseInt(v.trim()) < 0) {\n    throw new IllegalStateException(\"cacheSize must be >= 0 (0 disables cache)\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    serverConfig = new HTTPServerConfig(props);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid value for cacheSize\")) {\n        props.setProperty(\"cacheSize\", \"0\");\n        serverConfig = new HTTPServerConfig(props);\n    } else { throw e; }\n}","preventionTips":["Remember cacheSize=0 (not -1) disables the cache","Validate numeric properties after template rendering in provisioning","Keep a documented, minimal server.properties reference"],"tags":["java","languagetool","invalid-value","cache","server-config"],"backgroundTag":"invalid-config-value","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"}