@@ -82,6 +82,23 @@ public BeanForGH311(@JsonProperty("b") int b, @JsonProperty("a") int a) { //b an
82
82
public int getB () { return b ; }
83
83
}
84
84
85
+ // For [databind#2879]
86
+ @ JsonPropertyOrder ({ "a" , "c" })
87
+ static class BeanFor2879 {
88
+ public int c ;
89
+ public int b ;
90
+ public int a ;
91
+
92
+ @ JsonCreator
93
+ public BeanFor2879 (@ JsonProperty ("a" ) int a ,
94
+ @ JsonProperty ("b" ) int b ,
95
+ @ JsonProperty ("c" ) int c ) {
96
+ this .a = a ;
97
+ this .b = b ;
98
+ this .c = c ;
99
+ }
100
+ }
101
+
85
102
// We'll expect ordering of "FUBAR"
86
103
@ JsonPropertyOrder ({ "f" })
87
104
static class OrderingByIndexBean {
@@ -145,6 +162,16 @@ public void testOrderWithFeature() throws Exception
145
162
ALPHA_MAPPER .writeValueAsString (new BeanFor459 ()));
146
163
}
147
164
165
+ // [databind#2879]: verify that Creator properties never override explicit
166
+ // order
167
+ public void testCreatorVsExplicitOrdering () throws Exception
168
+ {
169
+ assertEquals (aposToQuotes ("{'a':1,'c':3,'b':2}" ),
170
+ MAPPER .writeValueAsString (new BeanFor2879 (1 , 2 , 3 )));
171
+ assertEquals (aposToQuotes ("{'a':1,'c':3,'b':2}" ),
172
+ ALPHA_MAPPER .writeValueAsString (new BeanFor2879 (1 , 2 , 3 )));
173
+ }
174
+
148
175
// [databind#311]
149
176
public void testAlphaAndCreatorOrdering () throws Exception
150
177
{
0 commit comments