martin-g commented on a change in pull request #1624:
URL: https://github.com/apache/avro/pull/1624#discussion_r837260899



##########
File path: lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
##########
@@ -131,18 +144,15 @@ public ClassLoader getClassLoader() {
 
   /**
    * Registers the given conversion to be used when reading and writing with 
this
-   * data model.
+   * data model. Conversions can also be registered automatically, as 
documented
+   * on the class {@link Conversion Conversion<T>}.
    *
    * @param conversion a logical type Conversion.
    */
   public void addLogicalTypeConversion(Conversion<?> conversion) {
     conversions.put(conversion.getLogicalTypeName(), conversion);
     Class<?> type = conversion.getConvertedType();
-    Map<String, Conversion<?>> conversions = conversionsByClass.get(type);
-    if (conversions == null) {
-      conversions = new LinkedHashMap<>();
-      conversionsByClass.put(type, conversions);
-    }
+    Map<String, Conversion<?>> conversions = 
conversionsByClass.computeIfAbsent(type, k -> new LinkedHashMap<>());

Review comment:
       Agreed!




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