{"record":{"id":"88cff0b149f4cafc","repo":"quarkusio/quarkus","slug":"value-cannot-be-null","errorCode":null,"errorMessage":"Value cannot be null","messagePattern":"Value cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/runtime/src/main/java/io/quarkus/runtime/ValueRegistryImpl.java","lineNumber":38,"sourceCode":" * injected into the recorders' constructors as a {@link RuntimeValue}.\n *\n * @see Application#Application(boolean)\n * @see \"io.quarkus.deployment.steps.MainClassBuildStep#build for storage\"\n * @see \"io.quarkus.deployment.ExtensionLoader#loadStepsFrom for retrieval\"\n * @see \"io.quarkus.deployment.recording.ObjectLoader\"\n */\npublic class ValueRegistryImpl implements ValueRegistry {\n    private final Map<String, RuntimeInfo<?>> values = new ConcurrentHashMap<>();\n\n    private ValueRegistryImpl() {\n    }\n\n    public <T> void register(final RuntimeKey<T> key, final T value) {\n        if (key == null || key.key() == null) {\n            throw new IllegalArgumentException(\"Key cannot be null\");\n        }\n        if (value == null) {\n            throw new IllegalArgumentException(\"Value cannot be null\");\n        }\n        registerInfo(key, SimpleRuntimeInfo.of(value));\n    }\n\n    public <T> void registerInfo(final RuntimeKey<T> key, final RuntimeInfo<T> runtimeInfo) {\n        if (key == null || key.key() == null) {\n            throw new IllegalArgumentException(\"Key cannot be null\");\n        }\n        if (runtimeInfo == null) {\n            throw new IllegalArgumentException(\"Value cannot be null\");\n        }\n        RuntimeInfo<?> mapValue = values.putIfAbsent(key.key(), runtimeInfo);\n        if (mapValue != null) {\n            throw new IllegalArgumentException(\"Key already registered \" + key.key());\n        }\n    }\n\n    public <T> boolean containsKey(final RuntimeKey<T> key) {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/runtime/src/main/java/io/quarkus/runtime/ValueRegistryImpl.java#L20-L56","documentation":"ValueRegistryImpl.register() validates its arguments before inserting into the backing ConcurrentHashMap. It throws IllegalArgumentException('Value cannot be null') when the value being registered is null. The registry refuses null values because a null entry would be indistinguishable from a missing key during lookup.","triggerScenarios":"Calling RuntimeValueRegistry.register(key, null), or registerInfo with a RuntimeInfo that wraps/exposes a null value path via SimpleRuntimeInfo.of(null).","commonSituations":"A config value or programmatically produced bean resolves to null at startup (e.g. an optional property not set) and the code registers it unconditionally; a factory method returns null instead of throwing.","solutions":["Check the value for null before calling register(); skip registration or throw a descriptive error naming the source of the null.","Fix the producing code so it never returns null (substitute a default or Optional-handling).","Use getOrDefault-style access patterns instead of registering sentinel nulls."],"exampleFix":"// before\nregistry.register(MyKeys.TIMEOUT, config.timeout()); // config.timeout() may be null\n// after\nObjects.requireNonNull(config.timeout(), \"timeout config missing\");\nregistry.register(MyKeys.TIMEOUT, config.timeout());","handlingStrategy":"validation","validationCode":"if (value == null) { throw new IllegalStateException(\"Refusing to register null value for \" + key.key()); }\nregistry.register(key, value);","typeGuard":"boolean isRegistrable(Object key, Object value) {\n    return key != null && key.key() != null && value != null;\n}","tryCatchPattern":"try {\n    registry.register(key, value);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Value cannot be null\")) {\n        log.warnf(\"Skipping null value for key %s\", key.key());\n    } else { throw e; }\n}","preventionTips":["Apply Objects.requireNonNull on values at their production site","Never register optional config values without a default","Wrap registration in a helper that logs and skips nulls"],"tags":["null-argument","registry","illegal-argument"],"backgroundTag":"null-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}