diff --git a/processing/src/main/java/org/apache/druid/java/util/common/jackson/JacksonUtils.java b/processing/src/main/java/org/apache/druid/java/util/common/jackson/JacksonUtils.java index 705c6962c75f..9c71fc705684 100644 --- a/processing/src/main/java/org/apache/druid/java/util/common/jackson/JacksonUtils.java +++ b/processing/src/main/java/org/apache/druid/java/util/common/jackson/JacksonUtils.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JavaType; @@ -124,21 +125,29 @@ public static void writeObjectUsingSerializerProvider( } } + @Nullable public static T readObjectUsingDeserializationContext( final JsonParser jp, final DeserializationContext deserializationContext, final Class clazz ) throws IOException { + if (jp.currentToken() == JsonToken.VALUE_NULL) { + return null; + } return deserializationContext.readValue(jp, clazz); } + @Nullable public static Object readObjectUsingDeserializationContext( final JsonParser jp, final DeserializationContext deserializationContext, final JavaType javaType ) throws IOException { + if (jp.currentToken() == JsonToken.VALUE_NULL) { + return null; + } return deserializationContext.readValue(jp, javaType); }