[
https://issues.apache.org/jira/browse/AVRO-3473?focusedWorklogId=749230&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-749230
]
ASF GitHub Bot logged work on AVRO-3473:
----------------------------------------
Author: ASF GitHub Bot
Created on: 29/Mar/22 09:29
Start Date: 29/Mar/22 09:29
Worklog Time Spent: 10m
Work Description: 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]
Issue Time Tracking
-------------------
Worklog Id: (was: 749230)
Time Spent: 40m (was: 0.5h)
> Automatically register Conversion<T> classes
> --------------------------------------------
>
> Key: AVRO-3473
> URL: https://issues.apache.org/jira/browse/AVRO-3473
> Project: Apache Avro
> Issue Type: Improvement
> Components: java, logical types
> Reporter: Oscar Westra van Holthe - Kind
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.11.1
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Manually registering a {{Conversion<T>}} is cumbersome, but necessary if
> creating the factory requires constructor parameters.
> For most cases though, a {{Conversion<T>}} gets all the information it needs
> from the schema. This makes it a good candidate for a SPI (using the Java 6
> {{ServiceLoader}} class).
> This is the addendum to AVRO-3441, which does the same thing for
> {{{}LogicalTypeFactory{}}}.
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)