{"record":{"id":"ba540a7fc6999580","repo":"FasterXML/jackson-databind","slug":"no-entry-oldprop-getname-found-can-t-repla","errorCode":null,"errorMessage":"No entry '${oldProp.getName()}' found, can't replace","messagePattern":"No entry '(.+?)' found, can't replace","errorType":"exception","errorClass":"NoSuchElementException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/bean/BeanPropertyMap.java","lineNumber":266,"sourceCode":"        // 17-Nov-2017, tatu: do NOT try to change indexes since this could lead to discrepancies\n        //    (unless we actually copy property instances)\n        return new BeanPropertyMap(newProps, newAliases, _locale, _caseInsensitive, false);\n    }\n\n    /**\n     * Specialized method that can be used to replace an existing entry\n     * (note: entry MUST exist; otherwise exception is thrown) with\n     * specified replacement.\n     */\n    public void replace(SettableBeanProperty oldProp, SettableBeanProperty newProp)\n    {\n        for (int i = 0, end = _propsInOrder.length; i < end; ++i) {\n            if (_propsInOrder[i] == oldProp) {\n                _propsInOrder[i] = newProp;\n                return;\n            }\n        }\n        throw new NoSuchElementException(\"No entry '\"+oldProp.getName()+\"' found, can't replace\");\n    }\n\n    /**\n     * Specialized method for removing specified existing entry.\n     * NOTE: entry MUST exist, otherwise an exception is thrown.\n     */\n    public void remove(SettableBeanProperty propToRm)\n    {\n        final String key = propToRm.getName();\n        final int len = _propsInOrder.length;\n        ArrayList<SettableBeanProperty> props = new ArrayList<>(len);\n        // [databind#5884]: Must also update _aliasDefs to stay aligned with _propsInOrder\n        ArrayList<PropertyName[]> aliases = (_aliasDefs != null)\n                ? new ArrayList<PropertyName[]>(len) : null;\n        boolean found = false;\n        for (int i = 0; i < len; ++i) {\n            if (!found && _propsInOrder[i].getName().equals(key)) {\n                found = true;","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/deser/bean/BeanPropertyMap.java#L248-L284","documentation":"BeanPropertyMap.replace requires the old property to actually be present in the in-order array; if it is not found (no reference equality match), it throws NoSuchElementException. This indicates the caller is trying to swap a property that was never inserted (or was already replaced/removed).","triggerScenarios":"Custom BeanDeserializerFactory code calling replace() with a property instance that is not in the map; double-replace of the same property; replace after remove; a custom module manipulating BeanPropertyMap out of order.","commonSituations":"Third-party modules (afterburner, blacklist) that rewrite properties and call replace twice; mixin application that removes a property before a later replace; race-free ordering bugs where replace runs before the map is populated.","solutions":["Verify the property exists in the map (findDefinition(name) != null) before calling replace.","Ensure replace is called at most once per property instance during construction.","If you are subclassing BeanDeserializerFactory, perform replaces in the correct phase (post-resolve, post-remove).","Upgrade third-party modules that manipulate BeanPropertyMap; the contract requires the old entry be present."],"exampleFix":"// before\nmap.replace(oldProp, newProp); // throws if oldProp not present\n\n// after\nif (map.findDefinition(oldProp.getName()) != null) {\n    map.replace(oldProp, newProp);\n}","handlingStrategy":"validation","validationCode":"if (map.findDefinition(oldProp.getName()) == null) {\n    // not present; skip replace\n    return;\n}","typeGuard":"// no type guard; runtime membership check via findDefinition","tryCatchPattern":"try { map.replace(oldProp, newProp); }\ncatch (NoSuchElementException e) {\n    // oldProp was not in the map; rebuild the map from scratch instead\n}","preventionTips":["Replace each property exactly once during construction.","In custom factories, perform replaces after the map is fully populated and before any removes."],"tags":["deserialization","bean-property-map","internal","module"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}