quarkusio/quarkus · error · IllegalStateException

Computing function not defined

Error message

Computing function not defined

What it means

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.

Source

Thrown at independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ComputingCache.java:59

    }

    public V getValueIfPresent(K key) {
        LazyValue<V> value = map.get(key);
        return value != null ? value.getIfPresent() : null;
    }

    public V computeIfAbsent(K key, Function<? super K, ? extends V> computingFunction) {
        return computeIfAbsent(key, new Supplier<V>() {
            @Override
            public V get() {
                return computingFunction.apply(key);
            }
        });
    }

    public V computeIfAbsent(K key, Supplier<V> supplier) {
        if (supplier == null) {
            throw new IllegalStateException("Computing function not defined");
        }
        LazyValue<V> value = map.get(key);
        if (value == null) {
            value = new LazyValue<V>(supplier);
            LazyValue<V> previous = map.putIfAbsent(key, value);
            if (previous != null) {
                value = previous;
            }
        }
        return value.get();
    }

    public V remove(K key) {
        LazyValue<V> previous = map.remove(key);
        return previous != null ? previous.get() : null;
    }

    public void clear() {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass a non-null Supplier/lambda to computeIfAbsent; never forward a nullable factory result.
  2. If the supplier is conditional, substitute a supplier that throws a domain-meaningful exception or returns a sentinel instead of null itself.
  3. If this comes from a patched ArC, revert to stock ArC and report the bug with a reproducer.

Example fix

// before
Supplier<Foo> s = factory.get(); // may be null
cache.computeIfAbsent(key, s);

// after
Supplier<Foo> s = Objects.requireNonNullElseGet(factory.get(), () -> () -> defaultFoo);
cache.computeIfAbsent(key, s);
Defensive patterns

Strategy: type-guard

Validate before calling

if (supplier == null) {
    supplier = () -> defaultOrThrow(key);
}

Type guard

static <K, V> Supplier<V> nonNullSupplier(Supplier<V> s, Supplier<V> fallback) {
    return s != null ? s : fallback;
}

Try / catch

try {
    cache.computeIfAbsent(key, supplier);
} catch (IllegalStateException e) {
    if (!"Computing function not defined".equals(e.getMessage())) throw e;
    // substitute a valid computing function and retry once
}

Prevention

When it happens

Trigger: 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.

Common situations: See trigger scenarios.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/cb5dcf3bf340e038. Report an issue: GitHub.