Skip to content

Commit

Permalink
AVRO-3999 - Avoid warnings in Perl test suite (#2953)
Browse files Browse the repository at this point in the history
* Add error message when schema do not match in Perl

When the schema did not match in a call to Avro::BinaryDecoder::decode,
a Avro::Schema::Error::Mismatch error was thrown without a body. This
was generating a warning when trying to stringify an undefined value,
and resulted in the empty string being used as the error message, which
was not veryb informative.

This change adds a message which should solve both issues.

* Do not exit sub via next in Perl tests

This silences a loud warning in xt/schema.t
  • Loading branch information
jjatria committed Jun 12, 2024
1 parent c1dc836 commit 072b51f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lang/perl/lib/Avro/BinaryDecoder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sub decode {
my $type = Avro::Schema->match(
writer => $writer_schema,
reader => $reader_schema,
) or throw Avro::Schema::Error::Mismatch;
) or throw Avro::Schema::Error::Mismatch 'schema do not match';

my $meth = "decode_$type";
return $class->$meth($writer_schema, $reader_schema, $reader);
Expand Down
2 changes: 1 addition & 1 deletion lang/perl/xt/schema.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use File::Find;
use_ok 'Avro::Schema';

sub parse {
next unless /\.avsc$/;
return unless /\.avsc$/;
open(my $fh, '<', $_);
local $/ = undef;
my $schema = <$fh>;
Expand Down

0 comments on commit 072b51f

Please sign in to comment.