clintropolis commented on a change in pull request #7985: fail complex type
'serde' registration when registered type does not match expected type
URL: https://github.com/apache/incubator-druid/pull/7985#discussion_r303125699
##########
File path:
processing/src/main/java/org/apache/druid/segment/serde/ComplexMetrics.java
##########
@@ -38,12 +38,18 @@ public static ComplexMetricSerde getSerdeForType(String
type)
return complexSerializers.get(type);
}
- public static void registerSerde(String type, Supplier<ComplexMetricSerde>
serdeSupplier)
+ public static <T extends ComplexMetricSerde> void registerSerde(String type,
Class<T> clazz, Supplier<T> serdeSupplier)
{
- if (ComplexMetrics.getSerdeForType(type) == null) {
- if (complexSerializers.containsKey(type)) {
- throw new ISE("Serializer for type[%s] already exists.", type);
+ if (complexSerializers.containsKey(type)) {
+ if
(!complexSerializers.get(type).getClass().getCanonicalName().equals(clazz.getCanonicalName()))
{
Review comment:
`getName` (or `getTypeName` i guess) seem more useful/informative to me as
well for the same reason about nulls. It is a bit less friendly, but an error
is probably never really friendly, so it least this way we can be sure it is
informative in helping isolate the issue that caused the error.
I found a few more usages of `getCanonicalName` searching with intellij, but
they are all similar usages to the ones you listed and could probably also
safely be adapted. I don't feel strongly either way about a rule to force it,
but am willing to add it if that is best.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]