[SCM] libmessage-passing-perl Debian packaging branch, master, updated. debian/0.111-3-14-g44f6e88
Tomas Doran
bobtfish at bobtfish.net
Mon May 6 11:57:42 UTC 2013
The following commit has been merged in the master branch:
commit 48d000670d41f932b199d0679452a2d9cb4abdd8
Author: Tomas Doran <bobtfish at bobtfish.net>
Date: Mon Aug 27 10:51:54 2012 +0100
Fix JSON decoder error handling
diff --git a/Changes b/Changes
index 86dacec..deaac04 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,5 @@
+ - Fix issue in JSON decoder when processing exceptions.
+
0.102
- Add error chain support to the JSON encoder and decoder so that an
error is logged if JSON encoding or decoding fails.
diff --git a/lib/Message/Passing/Exception/Decoding.pm b/lib/Message/Passing/Exception/Decoding.pm
index 134a247..ea4de57 100644
--- a/lib/Message/Passing/Exception/Decoding.pm
+++ b/lib/Message/Passing/Exception/Decoding.pm
@@ -9,7 +9,7 @@ with 'Message::Passing::Exception';
has exception => (
is => 'ro',
required => 1,
- isa => 'Str',
+ isa => Str,
);
has packed_data => (
diff --git a/t/errorchain.t b/t/errorchain.t
index 746225c..9299e87 100644
--- a/t/errorchain.t
+++ b/t/errorchain.t
@@ -4,24 +4,46 @@ use warnings;
use Test::More 0.88;
use_ok 'Message::Passing::Filter::Encoder::JSON';
+use_ok 'Message::Passing::Filter::Decoder::JSON';
use_ok 'Message::Passing::Output::Test';
-my $test = Message::Passing::Output::Test->new;
-my $test_e = Message::Passing::Output::Test->new;
-my $encoder = Message::Passing::Filter::Encoder::JSON->new(
- output_to => $test,
- error => $test_e,
-);
-$encoder->consume({ foo => bless {}, 'Bar' });
-is $test->message_count, 0;
-is $test_e->message_count, 1;
-my ($m) = $test_e->messages;
-#{"exception":"encountered object 'Bar=HASH(0x7fab21236f30)', but neither allow_blessed nor convert_blessed settings are enabled at /Users/t0m/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/JSON.pm line 154.\n","class":"Message::Passing::Exception::Encoding","stringified_data":"$VAR1 = {\n 'foo' => bless( {}, 'Bar' )\n };\n"}
-$m = $m->as_hash;
-is ref($m), 'HASH';
-is $m->{'class'}, 'Message::Passing::Exception::Encoding';
-ok exists $m->{'exception'};
-ok exists $m->{'stringified_data'};
+{
+ my $test = Message::Passing::Output::Test->new;
+ my $test_e = Message::Passing::Output::Test->new;
+ my $encoder = Message::Passing::Filter::Encoder::JSON->new(
+ output_to => $test,
+ error => $test_e,
+ );
+ $encoder->consume({ foo => bless {}, 'Bar' });
+ is $test->message_count, 0;
+ is $test_e->message_count, 1;
+ my ($m) = $test_e->messages;
+ #{"exception":"encountered object 'Bar=HASH(0x7fab21236f30)', but neither allow_blessed nor convert_blessed settings are enabled at /Users/t0m/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/JSON.pm line 154.\n","class":"Message::Passing::Exception::Encoding","stringified_data":"$VAR1 = {\n 'foo' => bless( {}, 'Bar' )\n };\n"}
+ $m = $m->as_hash;
+ is ref($m), 'HASH';
+ is $m->{'class'}, 'Message::Passing::Exception::Encoding';
+ ok exists $m->{'exception'};
+ ok exists $m->{'stringified_data'};
+}
+{
+ my $test = Message::Passing::Output::Test->new;
+ my $test_e = Message::Passing::Output::Test->new;
+ my $decoder = Message::Passing::Filter::Decoder::JSON->new(
+ output_to => $test,
+ error => $test_e,
+ );
+ $decoder->consume("{}");
+ is $test->message_count, 1;
+ is $test_e->message_count, 0;
+ $decoder->consume("{}sjdjd");
+ is $test->message_count, 1;
+ is $test_e->message_count, 1;
+ my ($m) = $test_e->messages;
+ $m = $m->as_hash;
+ like $m->{exception}, qr/garbage after/;
+ is $m->{packed_data}, '{}sjdjd';
+ is $m->{class}, 'Message::Passing::Exception::Decoding';
+}
done_testing;
--
libmessage-passing-perl Debian packaging
More information about the Pkg-perl-cvs-commits
mailing list