avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip Rizk (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AVRO-2033) GenericUnions constructor defaults to a broken state
Date Wed, 10 May 2017 15:50:04 GMT

     [ https://issues.apache.org/jira/browse/AVRO-2033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Philip Rizk updated AVRO-2033:
------------------------------
    Status: Patch Available  (was: Open)

Index: GenericDatum.hh
===================================================================
--- api/GenericDatum.hh	
+++ api/GenericDatum.hh	
@@ -200,7 +200,7 @@
      * and the value should correspond to one of the branches of the union.
      */
     GenericUnion(const NodePtr& schema) :
-        GenericContainer(AVRO_UNION, schema), curBranch_(schema->leaves()) {
+        GenericContainer(AVRO_UNION, schema), curBranch_(0) {
     }
 
     /**


> GenericUnions constructor defaults to a broken state
> ----------------------------------------------------
>
>                 Key: AVRO-2033
>                 URL: https://issues.apache.org/jira/browse/AVRO-2033
>             Project: Avro
>          Issue Type: Bug
>          Components: c++
>    Affects Versions: 1.7.7
>            Reporter: Philip Rizk
>            Priority: Minor
>
> Creating a GenericUnion with a NodePtr results in an object that causes errors when written.
Specifically the index for the union type will be invalid. This will only be caught when reading
the serialized record. 
> The issue is the consturctor:
> {code}
>    GenericUnion(const NodePtr& schema) :
>         GenericContainer(AVRO_UNION, schema), curBranch_(schema->leaves()) {
> {code}
> Setting curBranch_ to schema->leaves() will result in setting the value to an invalid
index (one more than available. I believe the constructor in question should be changed to:

> {code}
>   GenericContainer(AVRO_UNION, schema), curBranch_(0) {
> {code}
> This should ensure the union is set to the default branch. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message