You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/07/12 11:24:14 UTC

[GitHub] [incubator-druid] leventov commented on a change in pull request #7985: fail complex type 'serde' registration when registered type does not match expected type

leventov 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_r302940602
 
 

 ##########
 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:
   Such non-obvious considerations should have been reflected in code comments along with the code, not just remain in PR discussions. Otherwise, future developers might use `getCanonicalName()` without noticing a problem.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org