maccamlc commented on a change in pull request #885:
URL: https://github.com/apache/avro/pull/885#discussion_r711493550



##########
File path: lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
##########
@@ -51,9 +65,27 @@ default String getTypeName() {
   public static void register(String logicalTypeName, LogicalTypeFactory 
factory) {
     Objects.requireNonNull(logicalTypeName, "Logical type name cannot be 
null");
     Objects.requireNonNull(factory, "Logical type factory cannot be null");
+
+    try {
+      String factoryTypeName = factory.getTypeName();
+      if (!logicalTypeName.equals(factoryTypeName)) {
+        throw new IllegalArgumentException(String.format(
+            "Provided logicalTypeName '%s' does not match factory typeName 
'%s'", logicalTypeName, factoryTypeName));
+      }
+    } catch (UnsupportedOperationException ignore) {
+      // ignore exception, as by default this value has not been provided

Review comment:
       Reworked. No exception, but might be worth to still log this. Eventually 
might want to settle on providing the value in the LogTypeFactory only? But now 
it should always use the value passed through in this method if they differ.




-- 
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]


Reply via email to