Description
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:
GenericUnion(const NodePtr& schema) :
GenericContainer(AVRO_UNION, schema), curBranch_(schema->leaves()) {
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:
GenericContainer(AVRO_UNION, schema), curBranch_(0) {
This should ensure the union is set to the default branch.