{"record":{"id":"f9f7256747fd04ad","repo":"elastic/elasticsearch","slug":"cache-capacity-must-be-a-value-greater-than-0-but","errorCode":null,"errorMessage":"cache capacity must be a value greater than 0 but was {}","messagePattern":"cache capacity must be a value greater than 0 but was (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateProcessor.java","lineNumber":248,"sourceCode":"    static final class Cache {\n\n        private static final String CACHE_CAPACITY_SETTING = \"es.ingest.date_processor.cache_capacity\";\n        static final Cache INSTANCE;\n\n        static {\n            var cacheSizeStr = System.getProperty(CACHE_CAPACITY_SETTING, \"256\");\n            try {\n                INSTANCE = new Cache(Integer.parseInt(cacheSizeStr));\n            } catch (NumberFormatException e) {\n                throw new SettingsException(\"{} must be a valid number but was [{}]\", CACHE_CAPACITY_SETTING, cacheSizeStr);\n            }\n        }\n        private final ConcurrentMap<Key, SoftReference<Function<String, ZonedDateTime>>> map;\n        private final int capacity;\n\n        Cache(int capacity) {\n            if (capacity <= 0) {\n                throw new IllegalArgumentException(\"cache capacity must be a value greater than 0 but was \" + capacity);\n            }\n            this.capacity = capacity;\n            this.map = ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency(this.capacity);\n        }\n\n        Function<String, ZonedDateTime> getOrCompute(Key key, Supplier<Function<String, ZonedDateTime>> supplier) {\n            Function<String, ZonedDateTime> fn;\n            var element = map.get(key);\n            // element exist and wasn't GCed\n            if (element != null && (fn = element.get()) != null) {\n                return fn;\n            }\n            if (map.size() >= capacity) {\n                map.clear();\n            }\n            fn = supplier.get();\n            map.put(key, new SoftReference<>(fn));\n            return fn;","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateProcessor.java#L230-L266","documentation":"Thrown as IllegalArgumentException by the DateProcessor.Cache constructor when the supplied capacity is zero or negative. The constructor is invoked from the static initializer with the parsed int from the system property, so this fires at class-load time if the operator sets es.ingest.date_processor.cache_capacity to 0 or a negative number. Like 1132, it blocks DateProcessor class loading.","triggerScenarios":"Setting -Des.ingest.date_processor.cache_capacity=0 or any negative integer. The constructor explicitly rejects capacity <= 0.","commonSituations":"Operators trying to disable the cache by setting it to 0; misconfigured deploy templates that compute a size which underflows to zero; defaulting to 0 in test/staging configs.","solutions":["Set the property to a positive integer (default 256). To reduce memory pressure pick a small positive value rather than 0.","Remove the override to use the default.","If a small cache is genuinely desired, set it to 1 or another small positive number; the cache is backed by a ConcurrentMap with soft references, so it is bounded by capacity."],"exampleFix":"# before (jvm.options)\n-Des.ingest.date_processor.cache_capacity=0\n# after\n-Des.ingest.date_processor.cache_capacity=256","handlingStrategy":"validation","validationCode":"# Pre-flight check the value is strictly positive:\n# v=${ES_INGEST_DATE_CACHE:-256}; [ \"$v\" -gt 0 ] || { echo 'capacity must be > 0'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set cache_capacity to a positive integer (default 256); never 0.","If cache pressure is the concern, use a small positive value rather than disabling.","Validate operator-supplied JVM flags in deployment automation."],"tags":["ingest","date-processor","jvm-config","startup","settings"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}