thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zezeng Wang (Jira)" <j...@apache.org>
Subject [jira] [Updated] (THRIFT-5191) TZlibTransport cannot read strings of the same length when writing a string of length less than 3
Date Thu, 30 Apr 2020 03:32:00 GMT

     [ https://issues.apache.org/jira/browse/THRIFT-5191?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Zezeng Wang updated THRIFT-5191:
--------------------------------
    Description: 
TZlibTransport cannot read strings of the same length when writing a string of length less
than 3.
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 = 'aa'
    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:
len <3:

write data:aa
write data len :2
read data:b'a'
read data len:1


len>3:

write data:aaa
write data len :3
read data:b'aaa'
read data len:3





  was:
TZlibTransport cannot read strings of the same length when writing a string of length less
than 3.
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 = 'aaa'
    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:
len <3:

write data:aa
write data len :2
read data:b'a'
read data len:1


len>3:

write data:aaa
write data len :3
read data:b'aaa'
read data len:3






> TZlibTransport cannot read strings of the same length when writing a string of length
less than 3
> -------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-5191
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5191
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library
>    Affects Versions: 0.13.0
>         Environment: Environment : Ubuntu 18.04.4 
> version : 0.13.0
>            Reporter: Zezeng Wang
>            Priority: Minor
>
> TZlibTransport cannot read strings of the same length when writing a string of length
less than 3.
> 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 = 'aa'
>     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:
> len <3:
> write data:aa
> write data len :2
> read data:b'a'
> read data len:1
> len>3:
> write data:aaa
> write data len :3
> read data:b'aaa'
> read data len:3



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

Mime
View raw message