7
7
import com .fasterxml .jackson .annotation .*;
8
8
9
9
import com .fasterxml .jackson .databind .BaseMapTest ;
10
+ import com .fasterxml .jackson .databind .JsonMappingException ;
10
11
import com .fasterxml .jackson .databind .ObjectMapper ;
11
- import com .fasterxml .jackson .databind .exc .InvalidDefinitionException ;
12
12
13
13
// Tests for [databind#888]
14
14
public class JsonIncludeCustomTest extends BaseMapTest
@@ -110,16 +110,12 @@ public void testRepeatedCalls() throws Exception
110
110
111
111
assertEquals (a2q ("{'value':'x'}" ),
112
112
MAPPER .writeValueAsString (new CountingFooBean ("x" )));
113
+ assertEquals (1 , CountingFooFilter .counter .get ());
113
114
114
- // 06-May-2022, tatu: Maybe surprisingly, we get TWO calls; first one to
115
- // see if `null`s are to be filtered, second time for "real" call
116
- assertEquals (2 , CountingFooFilter .counter .get ());
117
115
assertEquals ("{}" , MAPPER .writeValueAsString (new CountingFooBean ("foo" )));
116
+ assertEquals (2 , CountingFooFilter .counter .get ());
118
117
119
- // but beyond initial extra call, as expected
120
- assertEquals (3 , CountingFooFilter .counter .get ());
121
-
122
- // except filter will NOT be called again for `null`s, as per [databind#3481]
118
+ // except filter will be called again for `null`s, as per [databind#3481]
123
119
assertEquals (a2q ("{'value':null}" ), MAPPER .writeValueAsString (new CountingFooBean (null )));
124
120
assertEquals (3 , CountingFooFilter .counter .get ());
125
121
}
@@ -133,11 +129,10 @@ public void testRepeatedCalls() throws Exception
133
129
public void testBrokenFilter () throws Exception
134
130
{
135
131
try {
136
- String json = MAPPER .writeValueAsString (new BrokenBean ("foo" ));
132
+ String json = MAPPER .writeValueAsString (new BrokenBean (null ));
137
133
fail ("Should not pass, produced: " +json );
138
- } catch (InvalidDefinitionException e ) {
139
- verifyException (e , "Problem determining whether filter of type" );
140
- verifyException (e , "filter out `null`" );
134
+ } catch (JsonMappingException e ) {
135
+ verifyException (e , "while trying to invoke the method java.lang.Object.toString() of a null object loaded from local variable 'other'" );
141
136
}
142
137
}
143
138
}
0 commit comments