[ 
https://issues.apache.org/jira/browse/AVRO-3186?focusedWorklogId=642387&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-642387
 ]

ASF GitHub Bot logged work on AVRO-3186:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Aug/21 14:52
            Start Date: 26/Aug/21 14:52
    Worklog Time Spent: 10m 
      Work Description: RyanSkraba commented on pull request #1304:
URL: https://github.com/apache/avro/pull/1304#issuecomment-906483121


   Thanks for the info -- having Avro running correctly in Quarkus is a 
compelling reason to get this fix in!  I've updated the JIRA to be included in 
the next major release (which is hopefully soon).  I've got some things on my 
plate at the moment, so if anyone wants to jump in with a review, feel free!
   
   Is there a way to unit test for Quarkus compatibility, or at least 
demonstrate the symptom on master?


-- 
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: 642387)
    Remaining Estimate: 0h
            Time Spent: 10m

> Avro can't decode union<null, logicalType> field of a record 
> -------------------------------------------------------------
>
>                 Key: AVRO-3186
>                 URL: https://issues.apache.org/jira/browse/AVRO-3186
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.10.2
>         Environment: JDK 11, macOS.
>            Reporter: Yubao Liu
>            Priority: Critical
>             Fix For: 1.11.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> [https://github.com/apache/avro/blob/release-1.10.2/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java#L163]
> {code:java}
>   protected Object read(Object old, Schema expected, ResolvingDecoder in) 
> throws IOException {
>     Object datum = readWithoutConversion(old, expected, in);
>     LogicalType logicalType = expected.getLogicalType();
>     if (logicalType != null) {
>       Conversion<?> conversion = getData().getConversionFor(logicalType);  // 
> <---- bad
>       if (conversion != null) {
>         return convert(datum, expected, logicalType, conversion);
>       }
>     }
>     return datum;
>   }
>  {code}
>  
> For a logic type field in a union,  getData().getConversionFor(logicalType) 
> returns null, the cause is SpecificData.getForSchema() isn't compatible with 
> JDK >= 9,  it can't depend on Class.forName() to load user class.
> [https://github.com/apache/avro/blob/release-1.10.2/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java#L147]
> {code:java}
> diff --git 
> a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java 
> b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
> index 58bc660b..33fc3418 100644
> --- a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
> +++ b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
> @@ -140,15 +140,9 @@ public class SpecificData extends GenericData {
>     */
>    public static SpecificData getForSchema(Schema reader) {
>      if (reader != null && reader.getType() == Type.RECORD) {
> -      final String className = getClassName(reader);
> -      if (className != null) {
> -        final Class<?> clazz;
> -        try {
> -          clazz = Class.forName(className);
> -          return getForClass(clazz);
> -        } catch (ClassNotFoundException e) {
> -          return SpecificData.get();
> -        }
> +      final Class<?> clazz = SpecificData.get().getClass(reader);
> +      if (clazz != null) {
> +        return getForClass(clazz);
>        }
>      }
>      return SpecificData.get();
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to