FasterXML/jackson-databind · error · IllegalArgumentException
Cannot pass null Deserializers
Error message
Cannot pass null Deserializers
What it means
Thrown by DeserializerFactoryConfig.withAdditionalDeserializers(Deserializers) when the argument is null. Deserializers providers are the mechanism by which modules and custom code register custom deserializers; a null provider would be silently ignored or cause NPEs later, so it is rejected at registration time.
Solutions
- Pass a non-null Deserializers instance. If you have nothing to add, do not call the method.
- Use SimpleDeserializers (from SimpleModule) as a concrete non-null implementation even if empty.
- Fix the upstream code that produced the null (e.g., a factory method that should return an empty set).
Example fix
// before
Deserializers desers = maybeBuildDeserializers(); // returns null
config.withAdditionalDeserializers(desers); // throws
// after
Deserializers desers = maybeBuildDeserializers();
if (desers != null) {
config.withAdditionalDeserializers(desers);
} Defensive patterns
Strategy: validation
Validate before calling
// Validate before calling
if (deserializers == null) {
// skip registration or throw a clear error
throw new IllegalArgumentException("Deserializers provider must not be null");
}
config.withAdditionalDeserializers(deserializers); Type guard
boolean isNonNullProvider(Deserializers d) {
return d != null;
} Prevention
- Use Objects.requireNonNull(d, "deserializers") before calling.
- Guard conditional Deserializers construction with null checks.
- Prefer SimpleDeserializers as an empty concrete type over null.
When it happens
Trigger: Calling deserializerFactoryConfig.withAdditionalDeserializers(null) directly, or more commonly via SimpleModule.addDeserializer() / SimpleModule.setDeserializerModifier() with internal wiring that resolves to a null Deserializers instance. Also possible via Module.setup() that has a bug returning null.
Common situations: Custom Jackson modules where a factory method or conditional returns null instead of a no-op implementation. Incomplete refactoring where a Deserializers field is left null. Third-party modules with bugs.
Related errors
- Cannot pass null KeyDeserializers
- AnnotationIntrospector returned `Class<
- AnnotationIntrospector.
- AnnotationIntrospector returned Class
- AnnotationIntrospector returned key deserializer definition…
AI-assisted analysis of FasterXML/jackson-databind@87876ca5c0 (2026-08-11).
Data as JSON: /api/errors/4ebb38136b10b906.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/tools/jackson/databind/cfg/DeserializerFactoryConfig.java:93
{
_additionalDeserializers = (allAdditionalDeserializers == null) ?
NO_DESERIALIZERS : allAdditionalDeserializers;
_additionalKeyDeserializers = (allAdditionalKeyDeserializers == null) ?
DEFAULT_KEY_DESERIALIZERS : allAdditionalKeyDeserializers;
_modifiers = (modifiers == null) ? NO_MODIFIERS : modifiers;
_valueInstantiators = (vi == null) ? NO_VALUE_INSTANTIATORS : vi;
}
/**
* Fluent/factory method used to construct a configuration object that
* has same deserializer providers as this instance, plus one specified
* as argument. Additional provider will be added before existing ones,
* meaning it has priority over existing definitions.
*/
public DeserializerFactoryConfig withAdditionalDeserializers(Deserializers additional)
{
if (additional == null) {
throw new IllegalArgumentException("Cannot pass null Deserializers");
}
Deserializers[] all = ArrayBuilders.insertInListNoDup(_additionalDeserializers, additional);
return new DeserializerFactoryConfig(all, _additionalKeyDeserializers, _modifiers,
_valueInstantiators);
}
/**
* Fluent/factory method used to construct a configuration object that
* has same key deserializer providers as this instance, plus one specified
* as argument. Additional provider will be added before existing ones,
* meaning it has priority over existing definitions.
*/
public DeserializerFactoryConfig withAdditionalKeyDeserializers(KeyDeserializers additional)
{
if (additional == null) {
throw new IllegalArgumentException("Cannot pass null KeyDeserializers");
}
KeyDeserializers[] all = ArrayBuilders.insertInListNoDup(_additionalKeyDeserializers, additional);View on GitHub (pinned to 87876ca5c0)