You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2022/06/20 16:45:42 UTC
[GitHub] [avro] github-code-scanning[bot] commented on a diff in pull request #1624: AVRO-3473: ServiceLoader for Conversion
github-code-scanning[bot] commented on code in PR #1624:
URL: https://github.com/apache/avro/pull/1624#discussion_r901853287
##########
lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java:
##########
@@ -131,18 +144,15 @@
/**
* 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:
## Possible confusion of local and field
Confusing name: method [addLogicalTypeConversion](1) also refers to field [conversions](2) (without qualifying it with 'this').
[Show more details](https://github.com/apache/avro/security/code-scanning/2660)
--
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: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org