Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
Description
When searching for a valid schema to encode a field that is a union of records, the Perl encoder warns if the payload doesn't contain a long field required in one of the records' schemas.
Example. The following snippet:
my $schema = Avro::Schema->parse(<<EOJ); [ { "type": "record", "name": "rectangle", "fields": [{ "name": "width", "type": "long" }, { "name": "height", "type": "long"}] }, { "type": "record", "name": "square", "fields": [{ "name": "dim", "type": "long" }] } ] EOJ my $enc = ''; Avro::BinaryEncoder->encode( schema => $schema, data => { dim => 10 }, emit_cb => sub { $enc .= ${ $_[0] } }, );
Throws the following warnings:
Use of uninitialized value $data in pack at ...avro/lang/perl/lib/Avro/Schema.pm line 287. Use of uninitialized value $data in string eq at ...avro/lang/perl/lib/Avro/Schema.pm line 289.
The same doesn't happen if width and height are int's.
This behavior unnecessarily pollutes the logs and can even cause failures in the cases where the encoder is called from a context that doesn't allow warnings.