jackson-databind icon indicating copy to clipboard operation
jackson-databind copied to clipboard

Make `BeanDeserializer` consider `DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES` to avoid buffering

Open cowtowncoder opened this issue 3 years ago • 1 comments

Currently BeanDeserializer has _ignoreAllUnknown flag but it is only set if per-class annotation @JsonIgnoreProperties(ignoreUnknown = true) (or its ConfigOverride equivalent) is specified. This flag is used to optimize handling to skip buffering for unknown properties; it would make sense to make it also consider that if DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES is disabled, property value need not be buffered.

It'd be good to test detection as well to ensure we know how settings work; perhaps by checking how BeanDeserializerBuilder works.

Note that we might want to do dynamic check for the flag, instead of modifying _ignoreAllUnknown: this because DeserializationFeatures may be changed on per-call basis (and since it can, inevitably someone will :) ). And since the case of buffering seemingly unknown property value is presumably rare, minor overhead for feature-flag check is probably fine.

cowtowncoder avatar Oct 24 '22 17:10 cowtowncoder