avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Carey (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AVRO-656) writing unions with multiple records, fixed or enums can choose wrong branch
Date Mon, 21 Feb 2011 21:41:38 GMT

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

Scott Carey commented on AVRO-656:
----------------------------------

The patch needs a change.   
* The change I suggested above does not allow a null name to match a non-null name in ResolvingGrammarGenerator.
  It needs to be consistent with all the other checks one way or another.

It was: if (vname == null || vname.equals(b.getName()))
which allows nulls to match non-nulls if equals() does, and now it is:

if ((vname != null && vname.equals(bname)) || vname == bname)
which only allows nulls to equal nulls.


If we allow null names to match non-nulls for compatibility reasons in the short term, lets
make it clear in the CHANGES.txt/javadoc that the old constructors are deprecated and it is
recommended to avoid mix/matching the two.
Hashmaps may behave strangely if these are used as keys.

> writing unions with multiple records, fixed or enums can choose wrong branch 
> -----------------------------------------------------------------------------
>
>                 Key: AVRO-656
>                 URL: https://issues.apache.org/jira/browse/AVRO-656
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.4.0
>            Reporter: Doug Cutting
>            Assignee: Doug Cutting
>            Priority: Blocker
>             Fix For: 1.5.0
>
>         Attachments: AVRO-656.patch, AVRO-656.patch, AVRO-656.patch, AVRO-656.patch,
AVRO-656.patch, AVRO-656.patch
>
>
> According to the specification, a union may contain multiple instances of a named type,
provided they have different names.  There are several bugs in the Java implementation of
this when writing data:
>  - for record, only the short-name of the record is checked, so the branch for a record
of the same name in a different namespace may be used by mistake
>  - for enum and fixed, the name of the record is not checked, so the first enum or fixed
in the union will always be assumed when writing.  in many cases this may cause the wrong
data to be written, potentially corrupting output.
> This is not a regression.  This has never been implemented correctly by Java.  Python
and Ruby never check names, but rather perform a full, recursive validation of content.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message