You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Jacob Tolar (JIRA)" <ji...@apache.org> on 2019/05/17 23:26:00 UTC

[jira] [Commented] (AVRO-2400) Avro 1.9.0 can't resolve schemas that can be resolved in 1.8.2

    [ https://issues.apache.org/jira/browse/AVRO-2400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16842803#comment-16842803 ] 

Jacob Tolar commented on AVRO-2400:
-----------------------------------

This fixes my issue and all existing unit tests pass:

[https://github.com/apache/avro/compare/master...jacobtolar:AVRO-2400?expand=1]

When we reach this point in the code the writer schema is type is ARRAY but we should prefer the ReaderUnion case.  

Alternatively, could fix by removing these lines (also verified with my test case, and the existing tests pass): [https://github.com/apache/avro/blob/branch-1.9/lang/java/avro/src/main/java/org/apache/avro/Resolver.java#L694-L696]

 

Let me know what is preferred and I can send the PR with the fix and a new test case for this issue. 

 

cc [~raymie] since he made the original changes in AVRO-2275 and can comment on the correctness of either fix I'm proposing here.

> Avro 1.9.0 can't resolve schemas that can be resolved in 1.8.2
> --------------------------------------------------------------
>
>                 Key: AVRO-2400
>                 URL: https://issues.apache.org/jira/browse/AVRO-2400
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>            Reporter: Jacob Tolar
>            Priority: Major
>
> The failure occurs in ResolvingGrammarGenerator when reader and writer schema have an array of records with different full names (e.g. different namespace). 
> {code:java}
> Exception in thread "main" java.lang.ClassCastException: org.apache.avro.Resolver$ReaderUnion cannot be cast to org.apache.avro.Resolver$Container{code}
> Avro 1.8.2 allowed this behavior but it now fails in 1.9.0. Looking at the jiras and code, I don't believe this was intentional ( AVRO-2275,  [https://github.com/apache/avro/commit/39d959e1c6a1f339f03dab18289e47f27c10be7f]  ).
>  
> It looks like there were some attempts to keep compatibility ( [https://github.com/apache/avro/blob/branch-1.9/lang/java/avro/src/main/java/org/apache/avro/Resolver.java] , e.g. see the commented out check for w.getFullName() in resolve()) but this case was missed.
>  
> See this simple example to reproduce. 
> [https://gist.github.com/jacobtolar/c88d43ab4e8767227891e5cdc188ffad]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)