44import com .fasterxml .jackson .annotation .JsonProperty ;
55import com .fasterxml .jackson .annotation .JsonSetter ;
66import com .fasterxml .jackson .annotation .Nulls ;
7- import com . fasterxml . jackson . core . JsonProcessingException ;
7+
88import com .fasterxml .jackson .databind .*;
99import com .fasterxml .jackson .databind .exc .InvalidNullException ;
10- import com .fasterxml .jackson .databind .json .JsonMapper ;
1110
1211import java .util .Collection ;
1312
@@ -62,6 +61,21 @@ static class NullsForString {
6261 public String getName () { return n ; }
6362 }
6463
64+ // [databind#3645]
65+ static class Issue3645BeanA {
66+ private String name ;
67+ private Collection <Integer > prices ;
68+
69+ public Issue3645BeanA (
70+ @ JsonProperty ("name" ) String name ,
71+ @ JsonProperty ("prices" )
72+ @ JsonSetter (nulls = Nulls .AS_EMPTY ) Collection <Integer > prices
73+ ) {
74+ this .name = name ;
75+ this .prices = prices ;
76+ }
77+ }
78+
6579 /*
6680 /**********************************************************
6781 /* Test methods
@@ -164,21 +178,8 @@ public void testNullsToEmptyViaCtor() throws Exception
164178 assertEquals ("" , result ._nullAsEmpty );
165179 }
166180
167- static class Issue3645BeanA {
168- private String name ;
169- private Collection <Integer > prices ;
170-
171- public Issue3645BeanA (
172- @ JsonProperty ("name" ) String name ,
173- @ JsonProperty ("prices" )
174- @ JsonSetter (nulls = Nulls .AS_EMPTY ) Collection <Integer > prices
175- ) {
176- this .name = name ;
177- this .prices = prices ;
178- }
179- }
180-
181- public void testDeserializeMissingCollectionFieldAsEmpty () throws JsonProcessingException {
181+ // [databind#3645]
182+ public void testDeserializeMissingCollectionFieldAsEmpty () throws Exception {
182183 String json = "{\" name\" : \" Computer\" }" ;
183184
184185 Issue3645BeanA actual = MAPPER .readValue (json , Issue3645BeanA .class );
@@ -187,13 +188,13 @@ public void testDeserializeMissingCollectionFieldAsEmpty() throws JsonProcessing
187188 assertTrue (actual .prices .isEmpty ());
188189 }
189190
190- public void testDeserializeNullAsEmpty () throws JsonProcessingException {
191+ // [databind#3645]
192+ public void testDeserializeNullAsEmpty () throws Exception {
191193 String json = "{\" name\" : \" Computer\" , \" prices\" : null}" ;
192194
193195 Issue3645BeanA actual = MAPPER .readValue (json , Issue3645BeanA .class );
194196
195197 assertEquals (actual .name , "Computer" );
196198 assertTrue (actual .prices .isEmpty ());
197199 }
198-
199200}
0 commit comments