You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Kengo Seki (Jira)" <ji...@apache.org> on 2019/12/26 05:34:00 UTC

[jira] [Created] (THRIFT-5050) Fix MemoryBuffer.pm to raise a proper exception if no data is available

Kengo Seki created THRIFT-5050:
----------------------------------

             Summary: Fix MemoryBuffer.pm to raise a proper exception if no data is available
                 Key: THRIFT-5050
                 URL: https://issues.apache.org/jira/browse/THRIFT-5050
             Project: Thrift
          Issue Type: Bug
          Components: Perl - Library
            Reporter: Kengo Seki
            Assignee: Kengo Seki


MemoryBuffer.pm is implemented as follows, but it doesn't raise a {{TTransportException}} when no data is available.

{code:title=lib/perl/lib/Thrift/MemoryBuffer.pm}
113 sub readAll
114 {
115     my $self = shift;
116     my $len  = shift;
117
118     my $avail = ($self->{wPos} - $self->{rPos});
119     if ($avail < $len) {
120         die TTransportException->new("Attempt to readAll($len) found only $avail available",
121                                     Thrift::TTransportException::END_OF_FILE);
122     }
123
{code}

Instead, it dies due to a wrong package name as follows. The right name is {{Thrift::TTransportException}}.

{code}
$ perl -Ilib -de 1

(snip)

  DB<1> use Thrift::BinaryProtocol

  DB<2> use Thrift::MemoryBuffer

  DB<3> $trans = Thrift::MemoryBuffer->new

  DB<4> $proto = Thrift::BinaryProtocol->new($trans)

  DB<5> $s

  DB<6> $proto->readString(\$s)
Can't locate object method "new" via package "TTransportException" (perhaps you forgot to load "TTransportException"?) at lib/Thrift/MemoryBuffer.pm line 120.
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)