You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Ilya Maykov (JIRA)" <ji...@apache.org> on 2011/05/29 09:46:47 UTC

[jira] [Created] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

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


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

[jira] [Commented] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13042319#comment-13042319 ] 

Hudson commented on THRIFT-1183:
--------------------------------

Integrated in Thrift #151 (See [https://builds.apache.org/hudson/job/Thrift/151/])
    THRIFT-1183. rb: Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Use #ord to ensure we get back an int

Patch: Ilya Maykov

bryanduxbury : http://svn.apache.org/viewvc/?view=rev&rev=1130236
Files : 
* /thrift/trunk/lib/rb/lib/thrift/protocol/compact_protocol.rb


> 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
>            Assignee: Ilya Maykov
>             Fix For: 0.7
>
>         Attachments: patch-THRIFT-1183.txt
>
>
> 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

[jira] [Updated] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Ilya Maykov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ilya Maykov updated THRIFT-1183:
--------------------------------

    Remaining Estimate:     (was: 1h)
     Original Estimate:     (was: 1h)

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

[jira] [Commented] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Ilya Maykov (JIRA)" <ji...@apache.org>.
    [ 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

[jira] [Commented] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Ilya Maykov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041494#comment-13041494 ] 

Ilya Maykov commented on THRIFT-1183:
-------------------------------------

This breaks CompactProtocol completely in JRuby when run with the --1.9 flag.

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

[jira] [Closed] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury closed THRIFT-1183.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 0.7
         Assignee: Ilya Maykov

Ah, you're totally right. I just tested #ord in a ruby 1.8.6 irb without thinking about our extensions. I just committed this patch.

> 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
>            Assignee: Ilya Maykov
>             Fix For: 0.7
>
>         Attachments: patch-THRIFT-1183.txt
>
>
> 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

[jira] [Commented] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041794#comment-13041794 ] 

Bryan Duxbury commented on THRIFT-1183:
---------------------------------------

There's a problem with your one-liner: it doesn't work in ruby 1.8.6!

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

[jira] [Updated] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Ilya Maykov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ilya Maykov updated THRIFT-1183:
--------------------------------

    Attachment: patch-THRIFT-1183.txt

Patch attached.

> 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

[jira] [Commented] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Ilya Maykov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041854#comment-13041854 ] 

Ilya Maykov commented on THRIFT-1183:
-------------------------------------

P.S. The pure-ruby BinaryProtocol already has this #ord behavior in 0.6.1 (probably much earlier), but the CompactProtocol does not.

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

[jira] [Commented] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Ilya Maykov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041853#comment-13041853 ] 

Ilya Maykov commented on THRIFT-1183:
-------------------------------------

I haven't tested it in 1.8.6 but it should work with the thrift/core_ext/fixnum.rb patch. I can test it with 1.8.6 if you like.

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

[jira] [Commented] (THRIFT-1183) Pure-ruby CompactProtocol raises ArgumentError when deserializing under Ruby 1.9

Posted by "Michael Stockton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041800#comment-13041800 ] 

Michael Stockton commented on THRIFT-1183:
------------------------------------------

It should work. We added the #ord method in thrift/core_ext/fixnum.rb for pre 1.8.7 clients.

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