{"record":{"id":"cb5dcf3bf340e038","repo":"quarkusio/quarkus","slug":"computing-function-not-defined","errorCode":null,"errorMessage":"Computing function not defined","messagePattern":"Computing function not defined","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ComputingCache.java","lineNumber":59,"sourceCode":"    }\n\n    public V getValueIfPresent(K key) {\n        LazyValue<V> value = map.get(key);\n        return value != null ? value.getIfPresent() : null;\n    }\n\n    public V computeIfAbsent(K key, Function<? super K, ? extends V> computingFunction) {\n        return computeIfAbsent(key, new Supplier<V>() {\n            @Override\n            public V get() {\n                return computingFunction.apply(key);\n            }\n        });\n    }\n\n    public V computeIfAbsent(K key, Supplier<V> supplier) {\n        if (supplier == null) {\n            throw new IllegalStateException(\"Computing function not defined\");\n        }\n        LazyValue<V> value = map.get(key);\n        if (value == null) {\n            value = new LazyValue<V>(supplier);\n            LazyValue<V> previous = map.putIfAbsent(key, value);\n            if (previous != null) {\n                value = previous;\n            }\n        }\n        return value.get();\n    }\n\n    public V remove(K key) {\n        LazyValue<V> previous = map.remove(key);\n        return previous != null ? previous.get() : null;\n    }\n\n    public void clear() {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ComputingCache.java#L41-L77","documentation":"ComputingCache.computeIfAbsent(key, supplier) requires a computing function to create the cached value lazily. It throws IllegalStateException when the supplied supplier is null, because the cache would otherwise be unable to ever produce a value for the key. This is a programming-error guard inside ArC internals.","triggerScenarios":"Internal ArC code paths (bean, qualifier, or client-proxy caches) calling computeIfAbsent with a null Supplier — typically only reachable via custom/patched code or reflection into ArC internals.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-null Supplier/lambda to computeIfAbsent; never forward a nullable factory result.","If the supplier is conditional, substitute a supplier that throws a domain-meaningful exception or returns a sentinel instead of null itself.","If this comes from a patched ArC, revert to stock ArC and report the bug with a reproducer."],"exampleFix":"// before\nSupplier<Foo> s = factory.get(); // may be null\ncache.computeIfAbsent(key, s);\n\n// after\nSupplier<Foo> s = Objects.requireNonNullElseGet(factory.get(), () -> () -> defaultFoo);\ncache.computeIfAbsent(key, s);","handlingStrategy":"type-guard","validationCode":"if (supplier == null) {\n    supplier = () -> defaultOrThrow(key);\n}","typeGuard":"static <K, V> Supplier<V> nonNullSupplier(Supplier<V> s, Supplier<V> fallback) {\n    return s != null ? s : fallback;\n}","tryCatchPattern":"try {\n    cache.computeIfAbsent(key, supplier);\n} catch (IllegalStateException e) {\n    if (!\"Computing function not defined\".equals(e.getMessage())) throw e;\n    // substitute a valid computing function and retry once\n}","preventionTips":["Never pass a nullable factory result directly into computeIfAbsent.","Wrap external factory calls with Objects.requireNonNullElse/requireNonNullElseGet.","Prefer passing a lambda literal at the call site instead of a stored Supplier."],"tags":["cache","null-argument","quarkus-arc","internal"],"backgroundTag":"null-required-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}