From bdbd67e393d8575b933d1a8396c9bbd034c7204f Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 13 Apr 2018 16:58:44 -0700 Subject: [PATCH] ... --- .../jackson/databind/SerializerProvider.java | 38 +++++++------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java b/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java index 70b29bc092..7f612ab0ba 100644 --- a/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java +++ b/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java @@ -510,7 +510,6 @@ public abstract WritableObjectId findObjectId(Object forPojo, * accessing suitable serializer; including that of not * finding any serializer */ - @SuppressWarnings("unchecked") public JsonSerializer findValueSerializer(Class valueType, BeanProperty property) throws JsonMappingException { @@ -534,7 +533,7 @@ public JsonSerializer findValueSerializer(Class valueType, BeanProper } } // at this point, resolution has occured, but not contextualization - return (JsonSerializer) handleSecondaryContextualization(ser, property); + return handleSecondaryContextualization(ser, property); } /** @@ -549,7 +548,6 @@ public JsonSerializer findValueSerializer(Class valueType, BeanProper * serializer is needed: annotations of the property (or bean that contains it) * may be checked to create contextual serializers. */ - @SuppressWarnings("unchecked") public JsonSerializer findValueSerializer(JavaType valueType, BeanProperty property) throws JsonMappingException { @@ -568,7 +566,7 @@ public JsonSerializer findValueSerializer(JavaType valueType, BeanProper return ser; } } - return (JsonSerializer) handleSecondaryContextualization(ser, property); + return handleSecondaryContextualization(ser, property); } /** @@ -627,7 +625,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. */ - @SuppressWarnings("unchecked") public JsonSerializer findPrimaryPropertySerializer(JavaType valueType, BeanProperty property) throws JsonMappingException { @@ -643,7 +640,7 @@ public JsonSerializer findPrimaryPropertySerializer(JavaType valueType, return ser; } } - return (JsonSerializer) handlePrimaryContextualization(ser, property); + return handlePrimaryContextualization(ser, property); } /** @@ -748,7 +745,9 @@ public JsonSerializer findKeySerializer(JavaType keyType, BeanProperty p // 16-Mar-2018, tatu: Used to have "default key serializer" in 2.x; dropped to let/make // custom code use Module interface or similar to provide key serializers JsonSerializer ser = _serializerFactory.createKeySerializer(_config, keyType, null); - return _handleContextualResolvable(ser, property); + // _handleContextualResolvable(ser, property): + ser.resolve(this); + return handleSecondaryContextualization(ser, property); } public JsonSerializer findKeySerializer(Class rawKeyType, BeanProperty property) @@ -798,19 +797,6 @@ protected JsonSerializer _createAndCacheUntypedSerializer(JavaType type) return ser; } - /** - * Helper method called to resolve and contextualize given - * serializer, if and as necessary. - */ - @SuppressWarnings("unchecked") - protected JsonSerializer _handleContextualResolvable(JsonSerializer ser, - BeanProperty property) - throws JsonMappingException - { - ser.resolve(this); - return (JsonSerializer) handleSecondaryContextualization(ser, property); - } - @SuppressWarnings("unchecked") protected JsonSerializer _handleResolvable(JsonSerializer ser) throws JsonMappingException @@ -818,7 +804,7 @@ protected JsonSerializer _handleResolvable(JsonSerializer ser) ser.resolve(this); return (JsonSerializer) ser; } - + /* /********************************************************************** /* Accessors for specialized serializers @@ -951,14 +937,15 @@ public abstract boolean includeFilterSuppressNulls(Object filter) * * @param property Property for which the given primary serializer is used; never null. */ - public JsonSerializer handlePrimaryContextualization(JsonSerializer ser, + @SuppressWarnings("unchecked") + public JsonSerializer handlePrimaryContextualization(JsonSerializer ser, BeanProperty property) throws JsonMappingException { if (ser != null) { ser = ser.createContextual(this, property); } - return ser; + return (JsonSerializer) ser; } /** @@ -975,14 +962,15 @@ public JsonSerializer handlePrimaryContextualization(JsonSerializer ser, * @param property Property for which serializer is used, if any; null * when deserializing root values */ - public JsonSerializer handleSecondaryContextualization(JsonSerializer ser, + @SuppressWarnings("unchecked") + public JsonSerializer handleSecondaryContextualization(JsonSerializer ser, BeanProperty property) throws JsonMappingException { if (ser != null) { ser = ser.createContextual(this, property); } - return ser; + return (JsonSerializer) ser; } /*