@@ -135,10 +135,24 @@ public PropertyValueBuffer(JsonParser p, DeserializationContext ctxt, int paramC
135
135
*/
136
136
public final boolean hasParameter (SettableBeanProperty prop )
137
137
{
138
+ final int ix = prop .getCreatorIndex ();
139
+
138
140
if (_paramsSeenBig == null ) {
139
- return ((_paramsSeen >> prop .getCreatorIndex ()) & 1 ) == 1 ;
141
+ if (((_paramsSeen >> ix ) & 1 ) == 1 ) {
142
+ return true ;
143
+ }
144
+ } else {
145
+ if (_paramsSeenBig .get (ix )) {
146
+ return true ;
147
+ }
140
148
}
141
- return _paramsSeenBig .get (prop .getCreatorIndex ());
149
+ // 28-Sep-2024 : [databind#4508] Support any-setter flowing through creator
150
+ if (_anyParamSetter != null ) {
151
+ if (ix == _anyParamSetter .getParameterIndex ()) {
152
+ return true ;
153
+ }
154
+ }
155
+ return false ;
142
156
}
143
157
144
158
/**
@@ -160,6 +174,11 @@ public Object getParameter(SettableBeanProperty prop)
160
174
} else {
161
175
value = _creatorParameters [prop .getCreatorIndex ()] = _findMissing (prop );
162
176
}
177
+ // 28-Sep-2024 : [databind#4508] Support any-setter flowing through creator
178
+ if ((value == null ) && (_anyParamSetter != null )
179
+ && (prop .getCreatorIndex () == _anyParamSetter .getParameterIndex ())) {
180
+ value = _createAndSetAnySetterValue ();
181
+ }
163
182
if (value == null && _context .isEnabled (DeserializationFeature .FAIL_ON_NULL_CREATOR_PROPERTIES )) {
164
183
return _context .reportInputMismatch (prop ,
165
184
"Null value for creator property '%s' (index %d); `DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES` enabled" ,
@@ -198,11 +217,7 @@ public Object[] getParameters(SettableBeanProperty[] props)
198
217
}
199
218
// [databind#562] since 2.18 : Respect @JsonAnySetter in @JsonCreator
200
219
if (_anyParamSetter != null ) {
201
- Object anySetterParameterObject = _anyParamSetter .createParameterObject ();
202
- for (PropertyValue pv = _anyParamBuffered ; pv != null ; pv = pv .next ) {
203
- pv .setValue (anySetterParameterObject );
204
- }
205
- _creatorParameters [_anyParamSetter .getParameterIndex ()] = anySetterParameterObject ;
220
+ _creatorParameters [_anyParamSetter .getParameterIndex ()] = _createAndSetAnySetterValue ();
206
221
}
207
222
if (_context .isEnabled (DeserializationFeature .FAIL_ON_NULL_CREATOR_PROPERTIES )) {
208
223
for (int ix = 0 ; ix < props .length ; ++ix ) {
@@ -217,6 +232,27 @@ public Object[] getParameters(SettableBeanProperty[] props)
217
232
return _creatorParameters ;
218
233
}
219
234
235
+ /**
236
+ * Helper method called to create and set any values buffered for "any setter"
237
+ */
238
+ private Object _createAndSetAnySetterValue () throws JsonMappingException
239
+ {
240
+ Object anySetterParameterObject = _anyParamSetter .createParameterObject ();
241
+ for (PropertyValue pv = _anyParamBuffered ; pv != null ; pv = pv .next ) {
242
+ try {
243
+ pv .setValue (anySetterParameterObject );
244
+
245
+ // Since one of callers only exposes JsonMappingException, but pv.setValue()
246
+ // nominally leaks IOException, need to do this unfortunate conversion
247
+ } catch (JsonMappingException e ) {
248
+ throw e ;
249
+ } catch (IOException e ) {
250
+ throw JsonMappingException .fromUnexpectedIOE (e );
251
+ }
252
+ }
253
+ return anySetterParameterObject ;
254
+ }
255
+
220
256
protected Object _findMissing (SettableBeanProperty prop ) throws JsonMappingException
221
257
{
222
258
// 08-Jun-2024: [databind#562] AnySetters are bit special
0 commit comments