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

When writing an irregular string, TZlibTransport cannot read cerrectlly the same length of strings

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 0.13.0
    • Fix Version/s: None
    • Component/s: Python - Library
    • Labels:
      None
    • Environment:

      Environment : Ubuntu 18.04.4
      version : 0.13.0

      Description

      When writing an irregular string, TZlibTransport cannot read cerrectlly the same length of strings
      this may be a bug.

      example:
      import _import_local_thrift
      from thrift.transport import TTransport
      from thrift.transport import TZlibTransport

      if _name_ == '_main_':
      buff = TTransport.TMemoryBuffer()
      trans = TTransport.TBufferedTransportFactory().getTransport(buff)
      zlib_trans = TZlibTransport.TZlibTransport(trans)
      data = 'abcefg'
      zlib_trans.write(data.encode('utf-8'))
      zlib_trans.flush()
      value = buff.getvalue()
      buff = TTransport.TMemoryBuffer(value)
      trans = TTransport.TBufferedTransportFactory().getTransport(buff)
      zlib_trans = TZlibTransport.TZlibTransport(trans)
      data_r = zlib_trans.read(len(data))
      print("write data:{}".format(data))
      print("write data len :{}".format(len(data)))
      print("read data:{}".format(data_r))
      print("read data len:{}".format(len(data_r)))

      test result: FALSE
      Irregular string:

      write data:abcefg
      write data len :7
      read data:b'abcd'
      read data len:4

      regular string: TRUE

      write data:abcefgabcefg
      write data len :14
      read data:b'abcefgabcefg'
      read data len:14

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              zeshuai007 Zezeng Wang
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: