Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5050

Fix MemoryBuffer.pm to raise a proper exception if no data is available

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.14.0
    • Perl - Library
    • None

    Description

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

      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
      

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

      $ 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.
      

      Attachments

        Issue Links

          Activity

            People

              sekikn Kengo Seki
              sekikn Kengo Seki
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m