File tree Expand file tree Collapse file tree
main/java/com/fasterxml/jackson/databind/ser/std
test/java/com/fasterxml/jackson/databind/ser/filter Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ Project: jackson-databind
4444#6339 : Enum aliases from an appended `AnnotationIntrospector` are discarded:
4545 `JacksonAnnotationIntrospector.findEnumAliases()` overwrites every slot
4646 (reported, fixed by @Marti2203)
47+ #6399 : `NullSerializer` should not be annotated with `@JacksonStdImpl`
4748
48492.22.5 (not yet released)
4950
Original file line number Diff line number Diff line change 55
66import com .fasterxml .jackson .core .*;
77import com .fasterxml .jackson .databind .*;
8- import com .fasterxml .jackson .databind .annotation .JacksonStdImpl ;
98import com .fasterxml .jackson .databind .jsonFormatVisitors .JsonFormatVisitorWrapper ;
109import com .fasterxml .jackson .databind .jsontype .TypeSerializer ;
1110
1514 * Used as the default "null serializer" (which is used for serializing
1615 * null object references unless overridden), as well as for some
1716 * more exotic types (java.lang.Void).
17+ *<p>
18+ * NOTE: not annotated with {@code @JacksonStdImpl} (since 2.23): it is a
19+ * fallback rather than the default serializer for any type, and optimization
20+ * modules (Afterburner, Blackbird) would otherwise consider it replaceable.
1821 */
19- @ JacksonStdImpl
2022@ SuppressWarnings ("serial" )
2123public class NullSerializer
2224 extends StdSerializer <Object >
Original file line number Diff line number Diff line change 1212import com .fasterxml .jackson .databind .ser .DefaultSerializerProvider ;
1313import com .fasterxml .jackson .databind .ser .SerializerFactory ;
1414import com .fasterxml .jackson .databind .testutil .DatabindTestUtil ;
15+ import com .fasterxml .jackson .databind .util .ClassUtil ;
1516
1617import static org .junit .jupiter .api .Assertions .*;
1718
@@ -138,4 +139,15 @@ public void testNullSerializerForProperty() throws Exception
138139 {
139140 assertEquals ("{\" a\" :\" foobar\" }" , MAPPER .writeValueAsString (new BeanWithNullProps ()));
140141 }
142+
143+ // [databind#6399]: `NullSerializer` is a fallback, not the default serializer
144+ // for any type, so must NOT be marked as standard implementation (optimization
145+ // modules like Afterburner and Blackbird consider std impls replaceable)
146+ @ Test
147+ public void testNullSerializerNotMarkedAsStdImpl () throws Exception
148+ {
149+ assertFalse (ClassUtil .isJacksonStdImpl (
150+ com .fasterxml .jackson .databind .ser .std .NullSerializer .class ),
151+ "NullSerializer must not be @JacksonStdImpl (see databind#6399)" );
152+ }
141153}
You can’t perform that action at this time.
0 commit comments