[
https://issues.apache.org/jira/browse/AVRO-2108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Faisal Feroz updated AVRO-2108:
-------------------------------
Component/s: java
> @Stringable annotation should be processed before creating the schema
> ---------------------------------------------------------------------
>
> Key: AVRO-2108
> URL: https://issues.apache.org/jira/browse/AVRO-2108
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.8.2
> Reporter: Faisal Feroz
>
> In {{org.apache.avro.reflect.ReflectData::createFieldSchema}} the following
> code is processing Stringable after explicitly creating a schema
> {code:java}
> Schema schema = createSchema(field.getGenericType(), names);
> if (field.isAnnotationPresent(Stringable.class)) { // Stringable
> schema = Schema.create(Schema.Type.STRING);
> }
> {code}
> https://github.com/apache/avro/blob/3af404efb31a1dc2fd720384ef9a3f7326c2d303/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java#L748
> The above code has a side effect when @Stringable annotation is placed over a
> Generic Type like {{ID}} which results in Unknown Type {{ID}} since the
> schema is created first which causes the error.
> Changing the code to following would fix this. Also it would also act as a
> micro optimization of the code as the generated schema is overwritten if
> stringable annotation is preset
> {code:java}
> Schema schema = null;
> if (field.isAnnotationPresent(Stringable.class)) { // Stringable
> schema = Schema.create(Schema.Type.STRING);
> } else {
> schema = createSchema(field.getGenericType(), names);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)