Fix #6201: honor @JacksonInject(useInput=FALSE) on Field/Setter - #6202
aysha-afrah26 wants to merge 3 commits into
Conversation
|
Sounds like 3.x is the right target wrt behavior change. |
Code Review ✅ Approved🔴 High risk · Field/setter injection-only properties now ignore JSON values, affecting stored-data integrity. Fixes OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
Sounds good, leaving it on 3.x. Rebuilt after your latest merge of 3.x into the branch and the inject tests are still green, so nothing else pending from my side. |
@JacksonInjectdocumentsuseInput = OptBoolean.FALSEas meaning the value from input is ignored and the injected value always wins, andCreatorProperty.isInjectionOnly()together with the[databind#1381]checks in the property-based-Creator loops makes that true for Creator properties. A property backed by a Field or a Setter gets no such treatment:getInjectionDefinition()returnsnullfor it, so it stays in the settable set and binds like any other property, whileinjectValues()runs right after the bean is constructed and before the first property is read. The injected value is written first and then overwritten by whatever the document carries under the same name, which turns a pinned server-side value such as a tenant id or a principal into something the request body can set. I noticed it comparing the Creator and Field forms of the same class while readingJacksonInject1381Test, whose fixtures all reach the value through a Creator, so the Field and Setter path has no coverage there. Dropping such a property from the settable set at deserializer-construction time keeps every binding path out of it at once, includingshape=ARRAY,@JsonPOJOBuilder,@JsonUnwrappedandreaderForUpdating(), whileValueInjectorstill supplies the value. Only the explicitOptBoolean.FALSEsetting changes;DEFAULTandTRUEbind from input exactly as before, and Creator properties are left to the existinghasConstructorParameter()guard. Registering the name as ignorable rather than just removing it keepsFAIL_ON_UNKNOWN_PROPERTIESquiet and keeps the value out of an@JsonAnySetter, so the property ends up behaving like aREAD_ONLYone, which also means it is skipped positionally undershape=ARRAY.Reported separately as #6201. Targeted at
3.xsince it changes which properties are bindable, but happy to retarget to3.1if you would rather have it on the LTS line.