From db69efde6cbb283e6e02039a24d6879e2468a358 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 16 Mar 2018 08:02:49 -0700 Subject: [PATCH] minor trimming, renaming --- .../jackson/databind/SerializerProvider.java | 155 ++++++++---------- .../jackson/databind/node/NullNode.java | 2 +- .../jackson/databind/node/POJONode.java | 2 +- .../ser/impl/IndexedListSerializer.java | 6 +- .../ser/impl/IndexedStringListSerializer.java | 2 +- .../databind/ser/impl/IteratorSerializer.java | 4 +- .../ser/impl/StringArraySerializer.java | 2 +- .../ser/impl/StringCollectionSerializer.java | 2 +- .../ser/std/CollectionSerializer.java | 4 +- .../databind/ser/std/IterableSerializer.java | 2 +- .../databind/ser/std/JsonValueSerializer.java | 4 +- .../databind/ser/std/MapSerializer.java | 4 +- .../ser/std/ObjectArraySerializer.java | 6 +- .../ser/std/ReferenceTypeSerializer.java | 4 +- .../ser/std/StdDelegatingSerializer.java | 2 +- .../jackson/databind/util/JSONPObject.java | 2 +- .../databind/util/JSONWrappedObject.java | 2 +- .../databind/ser/TestSerializerProvider.java | 2 +- 18 files changed, 90 insertions(+), 117 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java b/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java index 4db968239e..df727aa02a 100644 --- a/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java +++ b/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java @@ -112,9 +112,9 @@ public abstract class SerializerProvider final protected GeneratorSettings _generatorConfig; /* - /********************************************************** + /********************************************************************** /* Configuration, factories - /********************************************************** + /********************************************************************** */ /** @@ -124,9 +124,9 @@ public abstract class SerializerProvider final protected SerializerFactory _serializerFactory; /* - /********************************************************** + /********************************************************************** /* Helper objects for caching, reuse - /********************************************************** + /********************************************************************** */ /** @@ -141,9 +141,9 @@ public abstract class SerializerProvider protected transient ContextAttributes _attributes; /* - /********************************************************** + /********************************************************************** /* Configuration, specialized serializers - /********************************************************** + /********************************************************************** */ /** @@ -159,7 +159,7 @@ public abstract class SerializerProvider * output as JSON Objects), if not null; if null, us the standard * default key serializer. */ - protected JsonSerializer _keySerializer; + protected JsonSerializer _defaulKeySerializer; /** * Serializer used to output a null value. Default implementation @@ -177,9 +177,9 @@ public abstract class SerializerProvider protected JsonSerializer _nullKeySerializer = DEFAULT_NULL_KEY_SERIALIZER; /* - /********************************************************** + /********************************************************************** /* State, for non-blueprint instances - /********************************************************** + /********************************************************************** */ /** @@ -208,9 +208,9 @@ public abstract class SerializerProvider protected transient JsonGenerator _generator; /* - /********************************************************** + /********************************************************************** /* Life-cycle - /********************************************************** + /********************************************************************** */ /** @@ -252,7 +252,7 @@ protected SerializerProvider(SerializerProvider src, _serializerCache = src._serializerCache; _unknownTypeSerializer = src._unknownTypeSerializer; - _keySerializer = src._keySerializer; + _defaulKeySerializer = src._defaulKeySerializer; _nullValueSerializer = src._nullValueSerializer; _nullKeySerializer = src._nullKeySerializer; @@ -285,7 +285,7 @@ protected SerializerProvider(SerializerProvider src) _serializerCache = new SerializerCache(); _unknownTypeSerializer = src._unknownTypeSerializer; - _keySerializer = src._keySerializer; + _defaulKeySerializer = src._defaulKeySerializer; _nullValueSerializer = src._nullValueSerializer; _nullKeySerializer = src._nullKeySerializer; @@ -293,9 +293,9 @@ protected SerializerProvider(SerializerProvider src) } /* - /********************************************************** + /********************************************************************** /* ObjectWriteContext impl, config access - /********************************************************** + /********************************************************************** */ @Override @@ -336,9 +336,9 @@ public int getFormatWriteFeatures(int defaults) { } /* - /********************************************************** + /********************************************************************** /* ObjectWriteContext impl, databind integration - /********************************************************** + /********************************************************************** */ @Override @@ -381,9 +381,9 @@ public void writeTree(JsonGenerator gen, TreeNode tree) throws IOException } /* - /********************************************************** + /********************************************************************** /* Methods for configuring default settings - /********************************************************** + /********************************************************************** */ /** @@ -397,7 +397,7 @@ public void setDefaultKeySerializer(JsonSerializer ks) if (ks == null) { throw new IllegalArgumentException("Cannot pass null JsonSerializer"); } - _keySerializer = ks; + _defaulKeySerializer = ks; } /** @@ -433,12 +433,11 @@ public void setNullKeySerializer(JsonSerializer nks) } _nullKeySerializer = nks; } - + /* - /********************************************************** - /* DatabindContext implementation (and closely related - /* but ser-specific) - /********************************************************** + /********************************************************************** + /* DatabindContext implementation (and closely related but ser-specific) + /********************************************************************** */ /** @@ -502,9 +501,9 @@ public TimeZone getTimeZone() { } /* - /********************************************************** - /* Generic attributes (2.3+) - /********************************************************** + /********************************************************************** + /* Generic attributes + /********************************************************************** */ @Override @@ -520,9 +519,9 @@ public SerializerProvider setAttribute(Object key, Object value) } /* - /********************************************************** + /********************************************************************** /* Access to general configuration - /********************************************************** + /********************************************************************** */ /** @@ -561,9 +560,9 @@ public JsonGenerator getGenerator() { } /* - /********************************************************** + /********************************************************************** /* Access to Object Id aspects - /********************************************************** + /********************************************************************** */ /** @@ -576,9 +575,9 @@ public abstract WritableObjectId findObjectId(Object forPojo, ObjectIdGenerator generatorType); /* - /********************************************************** + /********************************************************************** /* General serializer locating functionality - /********************************************************** + /********************************************************************** */ /** @@ -729,8 +728,6 @@ public JsonSerializer findValueSerializer(JavaType valueType) * * @param property Property that is being handled; will never be null, and its * type has to match valueType parameter. - * - * @since 2.3 */ @SuppressWarnings("unchecked") public JsonSerializer findPrimaryPropertySerializer(JavaType valueType, BeanProperty property) @@ -754,9 +751,6 @@ public JsonSerializer findPrimaryPropertySerializer(JavaType valueType, return (JsonSerializer) handlePrimaryContextualization(ser, property); } - /** - * @since 2.3 - */ @SuppressWarnings("unchecked") public JsonSerializer findPrimaryPropertySerializer(Class valueType, BeanProperty property) @@ -892,14 +886,11 @@ public TypeSerializer findTypeSerializer(JavaType javaType) throws JsonMappingEx public JsonSerializer findKeySerializer(JavaType keyType, BeanProperty property) throws JsonMappingException { - JsonSerializer ser = _serializerFactory.createKeySerializer(_config, keyType, _keySerializer); + JsonSerializer ser = _serializerFactory.createKeySerializer(_config, keyType, _defaulKeySerializer); // 25-Feb-2011, tatu: As per [JACKSON-519], need to ensure contextuality works here, too return _handleContextualResolvable(ser, property); } - /** - * @since 2.7 - */ public JsonSerializer findKeySerializer(Class rawKeyType, BeanProperty property) throws JsonMappingException { @@ -907,41 +898,20 @@ public JsonSerializer findKeySerializer(Class rawKeyType, BeanPropert } /* - /******************************************************** + /********************************************************************** /* Accessors for specialized serializers - /******************************************************** + /********************************************************************** */ - /** - * @since 2.0 - */ - public JsonSerializer getDefaultNullKeySerializer() { - return _nullKeySerializer; - } - - /** - * @since 2.0 - */ public JsonSerializer getDefaultNullValueSerializer() { return _nullValueSerializer; } - - /** - * Method called to get the serializer to use for serializing - * Map keys that are nulls: this is needed since JSON does not allow - * any non-String value as key, including null. - *

- * Typically, returned serializer - * will either throw an exception, or use an empty String; but - * other behaviors are possible. - */ + /** * Method called to find a serializer to use for null values for given * declared type. Note that type is completely based on declared type, * since nulls in Java have no type and thus runtime type cannot be * determined. - * - * @since 2.0 */ public JsonSerializer findNullKeySerializer(JavaType serializationType, BeanProperty property) @@ -958,11 +928,10 @@ public JsonSerializer findNullKeySerializer(JavaType serializationType, * can be overridden to add custom null serialization for properties * of certain type or name. This gives method full granularity to basically * override null handling for any specific property or class of properties. - * - * @since 2.0 */ public JsonSerializer findNullValueSerializer(BeanProperty property) - throws JsonMappingException { + throws JsonMappingException + { return _nullValueSerializer; } @@ -991,8 +960,6 @@ public JsonSerializer getUnknownTypeSerializer(Class unknownType) { * Helper method called to see if given serializer is considered to be * something returned by {@link #getUnknownTypeSerializer}, that is, something * for which no regular serializer was found or constructed. - * - * @since 2.5 */ public boolean isUnknownTypeSerializer(JsonSerializer ser) { if ((ser == _unknownTypeSerializer) || (ser == null)) { @@ -1007,11 +974,11 @@ public boolean isUnknownTypeSerializer(JsonSerializer ser) { } return false; } - + /* - /********************************************************** + /********************************************************************** /* Methods for creating instances based on annotations - /********************************************************** + /********************************************************************** */ /** @@ -1048,9 +1015,9 @@ public abstract boolean includeFilterSuppressNulls(Object filter) throws JsonMappingException; /* - /********************************************************** + /********************************************************************** /* Support for contextualization - /********************************************************** + /********************************************************************** */ /** @@ -1096,9 +1063,9 @@ public JsonSerializer handleSecondaryContextualization(JsonSerializer ser, } /* - /******************************************************** + /********************************************************************** /* Convenience methods for serializing using default methods - /******************************************************** + /********************************************************************** */ /** @@ -1133,9 +1100,8 @@ public final void defaultSerializeField(String fieldName, Object value, JsonGene { gen.writeFieldName(fieldName); if (value == null) { - /* Note: can't easily check for suppression at this point - * any more; caller must check it. - */ + // Note: can't easily check for suppression at this point + // any more; caller must check it. if (_stdNullValueSerializer) { // minor perf optimization gen.writeNull(); } else { @@ -1208,7 +1174,14 @@ public void defaultSerializeDateKey(Date date, JsonGenerator gen) throws IOExcep } } - public final void defaultSerializeNull(JsonGenerator gen) throws IOException + /** + * Method to call when serializing a `null` value (POJO property, Map entry value, + * Collection/array element) using configured standard mechanism. Note that this + * does NOT consider filtering any more as value is expected. + * + * @since 3.0 (in 2.x was called defaultSerializeNull) + */ + public final void defaultSerializeNullValue(JsonGenerator gen) throws IOException { if (_stdNullValueSerializer) { // minor perf optimization gen.writeNull(); @@ -1218,9 +1191,9 @@ public final void defaultSerializeNull(JsonGenerator gen) throws IOException } /* - /******************************************************** + /********************************************************************** /* Error reporting - /******************************************************** + /********************************************************************** */ /** @@ -1316,9 +1289,9 @@ public JsonMappingException invalidTypeIdException(JavaType baseType, String typ } /* - /******************************************************** + /********************************************************************** /* Helper methods - /******************************************************** + /********************************************************************** */ protected void _reportIncompatibleRootType(Object value, JavaType rootType) throws IOException @@ -1337,10 +1310,10 @@ protected void _reportIncompatibleRootType(Object value, JavaType rootType) thro } /* - /********************************************************** + /********************************************************************** /* Low-level methods for actually constructing and initializing /* serializers - /********************************************************** + /********************************************************************** */ /** @@ -1424,9 +1397,9 @@ protected JsonSerializer _handleResolvable(JsonSerializer ser) } /* - /********************************************************** + /********************************************************************** /* Internal methods - /********************************************************** + /********************************************************************** */ protected final DateFormat _dateFormat() diff --git a/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java b/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java index 1a222433bc..ce47dc3a24 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/NullNode.java @@ -48,7 +48,7 @@ public JsonNodeType getNodeType() { public final void serialize(JsonGenerator g, SerializerProvider provider) throws IOException { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); } @Override diff --git a/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java b/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java index acf90e881a..178707472b 100644 --- a/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java +++ b/src/main/java/com/fasterxml/jackson/databind/node/POJONode.java @@ -108,7 +108,7 @@ public double asDouble(double defaultValue) public final void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException { if (_value == null) { - serializers.defaultSerializeNull(gen); + serializers.defaultSerializeNullValue(gen); } else if (_value instanceof JsonSerializable) { ((JsonSerializable) _value).serialize(gen, serializers); } else { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/IndexedListSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/IndexedListSerializer.java index f73aac3313..08fd9c7f19 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/IndexedListSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/IndexedListSerializer.java @@ -104,7 +104,7 @@ public void serializeContents(Object value0, JsonGenerator g, SerializerProvider for (; i < len; ++i) { Object elem = value.get(i); if (elem == null) { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); } else { Class cc = elem.getClass(); JsonSerializer serializer = serializers.serializerFor(cc); @@ -139,7 +139,7 @@ public void serializeContentsUsing(List value, JsonGenerator jgen, Serializer Object elem = value.get(i); try { if (elem == null) { - provider.defaultSerializeNull(jgen); + provider.defaultSerializeNullValue(jgen); } else if (typeSer == null) { ser.serialize(elem, jgen, provider); } else { @@ -166,7 +166,7 @@ public void serializeTypedContents(List value, JsonGenerator jgen, Serializer for (; i < len; ++i) { Object elem = value.get(i); if (elem == null) { - provider.defaultSerializeNull(jgen); + provider.defaultSerializeNullValue(jgen); } else { Class cc = elem.getClass(); JsonSerializer serializer = serializers.serializerFor(cc); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/IndexedStringListSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/IndexedStringListSerializer.java index ea817e7fa2..7e9f520b11 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/IndexedStringListSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/IndexedStringListSerializer.java @@ -98,7 +98,7 @@ private final void serializeContents(List value, JsonGenerator g, for (; i < len; ++i) { String str = value.get(i); if (str == null) { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); } else { g.writeString(str); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/IteratorSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/IteratorSerializer.java index 9fbb7e3f02..c422b3aeec 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/IteratorSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/IteratorSerializer.java @@ -84,7 +84,7 @@ public void serializeContents(Iterator value, JsonGenerator g, do { Object elem = value.next(); if (elem == null) { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); } else if (typeSer == null) { serializer.serialize(elem, g, provider); } else { @@ -102,7 +102,7 @@ protected void _serializeDynamicContents(Iterator value, JsonGenerator g, do { Object elem = value.next(); if (elem == null) { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); continue; } Class cc = elem.getClass(); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java index e4067bf788..bfc7ff2ece 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java @@ -196,7 +196,7 @@ private void serializeContentsSlow(String[] value, JsonGenerator gen, Serializer for (int i = 0, len = value.length; i < len; ++i) { String str = value[i]; if (str == null) { - provider.defaultSerializeNull(gen); + provider.defaultSerializeNullValue(gen); } else { ser.serialize(value[i], gen, provider); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringCollectionSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringCollectionSerializer.java index 339cdd6834..a2ecccbfc6 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringCollectionSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringCollectionSerializer.java @@ -103,7 +103,7 @@ private final void serializeContents(Collection value, JsonGenerator g, try { for (String str : value) { if (str == null) { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); } else { g.writeString(str); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/CollectionSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/CollectionSerializer.java index 30a1a1ca1e..acf0db6356 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/CollectionSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/CollectionSerializer.java @@ -114,7 +114,7 @@ public void serializeContents(Collection value, JsonGenerator g, SerializerPr do { Object elem = it.next(); if (elem == null) { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); } else { Class cc = elem.getClass(); JsonSerializer serializer = serializers.serializerFor(cc); @@ -151,7 +151,7 @@ public void serializeContentsUsing(Collection value, JsonGenerator g, Seriali Object elem = it.next(); try { if (elem == null) { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); } else { if (typeSer == null) { ser.serialize(elem, g, provider); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/IterableSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/IterableSerializer.java index 5cc5068452..1ca55547df 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/IterableSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/IterableSerializer.java @@ -88,7 +88,7 @@ public void serializeContents(Iterable value, JsonGenerator jgen, do { Object elem = it.next(); if (elem == null) { - provider.defaultSerializeNull(jgen); + provider.defaultSerializeNullValue(jgen); continue; } JsonSerializer currSerializer = _elementSerializer; diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/JsonValueSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/JsonValueSerializer.java index 40e21ef977..3ff6a03df7 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/JsonValueSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/JsonValueSerializer.java @@ -157,7 +157,7 @@ public void serialize(Object bean, JsonGenerator gen, SerializerProvider prov) t try { Object value = _accessor.getValue(bean); if (value == null) { - prov.defaultSerializeNull(gen); + prov.defaultSerializeNullValue(gen); return; } JsonSerializer ser = _valueSerializer; @@ -186,7 +186,7 @@ public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider value = _accessor.getValue(bean); // and if we got null, can also just write it directly if (value == null) { - provider.defaultSerializeNull(gen); + provider.defaultSerializeNullValue(gen); return; } JsonSerializer ser = _valueSerializer; diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java index 4368f73ad4..381e6a8067 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java @@ -655,7 +655,7 @@ public void serializeFields(Map value, JsonGenerator gen, SerializerProvide } // And then value if (valueElem == null) { - provider.defaultSerializeNull(gen); + provider.defaultSerializeNullValue(gen); continue; } JsonSerializer serializer = _valueSerializer; @@ -753,7 +753,7 @@ public void serializeFieldsUsing(Map value, JsonGenerator gen, SerializerPr } final Object valueElem = entry.getValue(); if (valueElem == null) { - provider.defaultSerializeNull(gen); + provider.defaultSerializeNullValue(gen); } else { try { if (typeSer == null) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/ObjectArraySerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/ObjectArraySerializer.java index 3d8854927b..1be27d48f4 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/ObjectArraySerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/ObjectArraySerializer.java @@ -231,7 +231,7 @@ public void serializeContents(Object[] value, JsonGenerator gen, SerializerProvi for (; i < len; ++i) { elem = value[i]; if (elem == null) { - provider.defaultSerializeNull(gen); + provider.defaultSerializeNullValue(gen); continue; } Class cc = elem.getClass(); @@ -263,7 +263,7 @@ public void serializeContentsUsing(Object[] value, JsonGenerator jgen, Serialize for (; i < len; ++i) { elem = value[i]; if (elem == null) { - provider.defaultSerializeNull(jgen); + provider.defaultSerializeNullValue(jgen); continue; } if (typeSer == null) { @@ -288,7 +288,7 @@ public void serializeTypedContents(Object[] value, JsonGenerator jgen, Serialize for (; i < len; ++i) { elem = value[i]; if (elem == null) { - provider.defaultSerializeNull(jgen); + provider.defaultSerializeNullValue(jgen); continue; } Class cc = elem.getClass(); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/ReferenceTypeSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/ReferenceTypeSerializer.java index 3d75828420..d10e17715e 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/ReferenceTypeSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/ReferenceTypeSerializer.java @@ -360,7 +360,7 @@ public void serialize(T ref, JsonGenerator g, SerializerProvider provider) Object value = _getReferencedIfPresent(ref); if (value == null) { if (_unwrapper == null) { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); } return; } @@ -383,7 +383,7 @@ public void serializeWithType(T ref, Object value = _getReferencedIfPresent(ref); if (value == null) { if (_unwrapper == null) { - provider.defaultSerializeNull(g); + provider.defaultSerializeNullValue(g); } return; } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java index cc5a2fef51..fcee746634 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java @@ -147,7 +147,7 @@ public void serialize(Object value, JsonGenerator gen, SerializerProvider provid Object delegateValue = convertValue(value); // should we accept nulls? if (delegateValue == null) { - provider.defaultSerializeNull(gen); + provider.defaultSerializeNullValue(gen); return; } // 02-Apr-2015, tatu: As per [databind#731] may need to do dynamic lookup diff --git a/src/main/java/com/fasterxml/jackson/databind/util/JSONPObject.java b/src/main/java/com/fasterxml/jackson/databind/util/JSONPObject.java index b6e91e0a68..f9adc25e81 100644 --- a/src/main/java/com/fasterxml/jackson/databind/util/JSONPObject.java +++ b/src/main/java/com/fasterxml/jackson/databind/util/JSONPObject.java @@ -69,7 +69,7 @@ public void serialize(JsonGenerator gen, SerializerProvider provider) gen.writeRaw('('); if (_value == null) { - provider.defaultSerializeNull(gen); + provider.defaultSerializeNullValue(gen); } else { // NOTE: Escape line-separator characters that break JSONP only if no custom character escapes are set. // If custom escapes are in place JSONP-breaking characters will not be escaped and it is recommended to diff --git a/src/main/java/com/fasterxml/jackson/databind/util/JSONWrappedObject.java b/src/main/java/com/fasterxml/jackson/databind/util/JSONWrappedObject.java index 121b1e3688..050ca8eee1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/util/JSONWrappedObject.java +++ b/src/main/java/com/fasterxml/jackson/databind/util/JSONWrappedObject.java @@ -80,7 +80,7 @@ public void serialize(JsonGenerator jgen, SerializerProvider provider) // First, wrapping: if (_prefix != null) jgen.writeRaw(_prefix); if (_value == null) { - provider.defaultSerializeNull(jgen); + provider.defaultSerializeNullValue(jgen); } else if (_serializationType != null) { provider.findTypedValueSerializer(_serializationType, true, null).serialize(_value, jgen, provider); } else { diff --git a/src/test/java/com/fasterxml/jackson/databind/ser/TestSerializerProvider.java b/src/test/java/com/fasterxml/jackson/databind/ser/TestSerializerProvider.java index 89310db5eb..b99e6c22c6 100644 --- a/src/test/java/com/fasterxml/jackson/databind/ser/TestSerializerProvider.java +++ b/src/test/java/com/fasterxml/jackson/databind/ser/TestSerializerProvider.java @@ -26,7 +26,7 @@ public void testFindExplicit() throws JsonMappingException // Should have working default key and null key serializers assertNotNull(prov.findKeySerializer(mapper.constructType(String.class), null)); - assertNotNull(prov.getDefaultNullKeySerializer()); +// assertNotNull(prov.getDefaultNullKeySerializer()); assertNotNull(prov.getDefaultNullValueSerializer()); // as well as 'unknown type' one (throws exception) assertNotNull(prov.getUnknownTypeSerializer(getClass()));