{"record":{"id":"2e085288a1d36974","repo":"FasterXML/jackson-databind","slug":"cannot-pass-null-resolver-2e0852","errorCode":null,"errorMessage":"Cannot pass null resolver","messagePattern":"Cannot pass null resolver","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/cfg/MapperBuilder.java","lineNumber":1496,"sourceCode":"        return _this();\n    }\n\n    /**\n     * Method that may be used to remove all {@link DeserializationProblemHandler}s added\n     * to this builder (if any).\n     */\n    public B clearProblemHandlers() {\n        _problemHandlers = null;\n        return _this();\n    }\n\n    /**\n     * Method for inserting specified {@link AbstractTypeResolver} as the first resolver\n     * in chain of possibly multiple resolvers.\n     */\n    public B addAbstractTypeResolver(AbstractTypeResolver resolver) {\n        if (resolver == null) {\n            throw new IllegalArgumentException(\"Cannot pass null resolver\");\n        }\n        _abstractTypeResolvers = ArrayBuilders.insertInListNoDup(_abstractTypeResolvers, resolver);\n        return _this();\n    }\n\n    /*\n    /**********************************************************************\n    /* Changing settings, date/time\n    /**********************************************************************\n     */\n\n    /**\n     * Method for configuring the default {@link DateFormat} to use when serializing time\n     * values as Strings, and deserializing from JSON Strings.\n     * If you need per-request configuration, factory methods in\n     * {@link ObjectReader} and {@link ObjectWriter} instead.\n     */\n    public B defaultDateFormat(DateFormat f) {","sourceCodeStart":1478,"sourceCodeEnd":1514,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/cfg/MapperBuilder.java#L1478-L1514","documentation":"Thrown by MapperBuilder.addAbstractTypeResolver(AbstractTypeResolver) when the argument is null. AbstractTypeResolver instances remap abstract types to concrete subtypes during deserialization; a null entry would produce gaps in the resolver chain, so Jackson rejects it at configuration time.","triggerScenarios":"Calling JsonMapper.builder().addAbstractTypeResolver(null) (directly or via a variable/expression that evaluates to null).","commonSituations":"Conditionally registering a resolver and omitting the null check; refactoring that replaces a resolver instance with a lookup that can return null; DI wiring missing the bean.","solutions":["Guard the call: only invoke addAbstractTypeResolver(resolver) when resolver != null.","If you want to disable resolution, omit the call or use clear/replace APIs rather than passing null.","Ensure the factory/DI lookup producing the resolver never returns null."],"exampleFix":"// before\nbuilder.addAbstractTypeResolver(maybeResolver());\n\n// after\nAbstractTypeResolver r = maybeResolver();\nif (r != null) {\n    builder.addAbstractTypeResolver(r);\n}","handlingStrategy":"validation","validationCode":"AbstractTypeResolver resolver = maybeResolver();\nif (resolver == null) {\n    // skip\n} else {\n    builder.addAbstractTypeResolver(resolver);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Null-check resolvers from DI/lookups before registering.","Omit the call instead of passing null when no resolver is needed.","Keep resolver wiring centralized so null sources are obvious."],"tags":["jackson","deserialization","config","null-check","builder","abstract-type"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}