@@ -82,6 +82,23 @@ public BeanForGH311(@JsonProperty("b") int b, @JsonProperty("a") int a) { //b an
8282 public int getB () { return b ; }
8383 }
8484
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+
85102 // We'll expect ordering of "FUBAR"
86103 @ JsonPropertyOrder ({ "f" })
87104 static class OrderingByIndexBean {
@@ -145,6 +162,16 @@ public void testOrderWithFeature() throws Exception
145162 ALPHA_MAPPER .writeValueAsString (new BeanFor459 ()));
146163 }
147164
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+
148175 // [databind#311]
149176 public void testAlphaAndCreatorOrdering () throws Exception
150177 {
0 commit comments