[ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13040760#comment-13040760 ]
Ilya Maykov commented on THRIFT-1183: ------------------------------------- Sorry the patch is against a copy of the source that i've mirrored on our own git repo, so the file paths may look funky. > Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby > 1.9 > -------------------------------------------------------------------------------- > > Key: THRIFT-1183 > URL: https://issues.apache.org/jira/browse/THRIFT-1183 > Project: Thrift > Issue Type: Bug > Components: Ruby - Library > Affects Versions: 0.6.1 > Environment: OS X 10.6 i686 / Ruby 1.9.2 > Reporter: Ilya Maykov > Attachments: patch-THRIFT-1183.txt > > Original Estimate: 1h > Remaining Estimate: 1h > > While testing my fix for THRIFT-1182 with various combinations of > native/non-native ruby and binary/compact protocols, I stumbled upon a bug in > the pure-ruby implementation of CompactProtocol. > In lib/thrift/protocol/compact_protocol.rb line 306: > ... > val = dat[0] > if (val > 0x7f) > ... > Here, dat is a string, so dat[0] returns a Fixnum in Ruby 1.8.7 but a string > of size 1 in Ruby 1.9.2. The conditional compares dat[0] with 0x7f, which > raises the following error in 1.9.2: > /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/protocol/compact_protocol.rb:307:in > `>': comparison of String with 127 failed (ArgumentError) > from > /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/protocol/compact_protocol.rb:307:in > `read_byte' > from > /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/protocol/compact_protocol.rb:243:in > `read_field_begin' > from > /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/struct.rb:86:in > `block in read' > from > /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/struct.rb:85:in > `loop' > from > /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/struct.rb:85:in > `read' > from > /Users/ilyam/.rvm/gems/ruby-1.9.2-p180/gems/thrift-0.6.0/lib/thrift/serializer/deserializer.rb:29:in > `deserialize' > The solution is a one-line fix, patch will be attached shortly. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira