abhishekagarwal87 commented on code in PR #12612:
URL: https://github.com/apache/druid/pull/12612#discussion_r890869855
##########
processing/src/main/java/org/apache/druid/jackson/DefaultObjectMapper.java:
##########
@@ -61,11 +77,54 @@ public DefaultObjectMapper(JsonFactory factory)
configure(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS, false);
configure(SerializationFeature.INDENT_OUTPUT, false);
configure(SerializationFeature.FLUSH_AFTER_WRITE_VALUE, false);
+
+ addHandler(new DefaultDeserializationProblemHandler(serviceName));
}
@Override
public ObjectMapper copy()
{
return new DefaultObjectMapper(this);
}
+
+ /**
+ * A custom implementation of {@link #DeserializationProblemHandler} to add
custom error message so
+ * that users know how to troubleshoot unknown type ids.
+ */
+ static class DefaultDeserializationProblemHandler extends
DeserializationProblemHandler
+ {
+ private final String serviceName;
+
+ public DefaultDeserializationProblemHandler(@Nullable String serviceName)
+ {
+ this.serviceName = serviceName == null ? "unknown" : serviceName;
+ }
+
+ @VisibleForTesting
+ String getServiceName()
+ {
+ return serviceName;
+ }
+
+ @Override
+ public JavaType handleUnknownTypeId(DeserializationContext ctxt,
+ JavaType baseType, String subTypeId,
TypeIdResolver idResolver,
+ String failureMsg)
+ throws IOException
+ {
+ String msg = String.format("Please make sure to load all the necessary
extensions and jars " +
+ "with type '%s' on '%s' service. " +
+ "Could not resolve type id '%s' as a subtype of %s",
Review Comment:
It was intentional since the non-technical user might not even look beyond
the technical jargon.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]