File tree 1 file changed +11
-5
lines changed
src/test/java/com/fasterxml/jackson/databind/creators
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -163,12 +163,18 @@ public Issue700Bean(@JsonProperty("item") String item) { }
163
163
}
164
164
165
165
static class Issue905Bean {
166
- public int v1 , v2 ;
166
+ // 08-Nov-2015, tatu: Note that in real code we would most likely use same
167
+ // names for properties; but here we use different name on purpose to
168
+ // ensure that Jackson has no way of binding JSON properties "x" and "y"
169
+ // using any other mechanism than via `@ConstructorProperties` annotation
170
+ public int _x , _y ;
167
171
168
172
@ ConstructorProperties ({"x" , "y" })
173
+ // Same as above; use differing local parameter names so that parameter name
174
+ // introspection can not be used as the source of property names.
169
175
public Issue905Bean (int a , int b ) {
170
- v1 = a ;
171
- v2 = b ;
176
+ _x = a ;
177
+ _y = b ;
172
178
}
173
179
}
174
180
@@ -313,7 +319,7 @@ public void testCreatorPropertiesAnnotation() throws Exception
313
319
{
314
320
Issue905Bean b = MAPPER .readValue (aposToQuotes ("{'y':3,'x':2}" ),
315
321
Issue905Bean .class );
316
- assertEquals (2 , b .v1 );
317
- assertEquals (3 , b .v2 );
322
+ assertEquals (2 , b ._x );
323
+ assertEquals (3 , b ._y );
318
324
}
319
325
}
You can’t perform that action at this time.
0 commit comments