From 98ea5bbbaf5fa30415876c5b2855a8dd7041475d Mon Sep 17 00:00:00 2001 From: Laksh Singla Date: Wed, 24 Jul 2024 11:44:45 +0530 Subject: [PATCH] null fix --- .../druid/java/util/common/jackson/JacksonUtils.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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); }