Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.10.0
-
None
-
Thrift v0.10.0
ruby 2.4.0p0
CentOS Linux (3.10.0-514.26.2.el7.x86_64) 7
-
Patch Available
-
Patch
Description
Steps to reproduce:
1) Install ruby 2.4.x
2) Build Thrift with `./bootstrap.sh`, `./configure`, `make`, and `sudo make install`
The RSpec suite will fail 3 errors:
Failures: 1) Struct Thrift::Struct should support optional type-checking in Thrift::Struct.new Failure/Error: lambda { SpecNamespace::Hello.new(:greeting => 3) }.should raise_error(Thrift::TypeError, "Expected Types::STRING, received Fixnum for field greeting") expected Thrift::TypeError with "Expected Types::STRING, received Fixnum for field greeting", got #<Thrift::TypeError: Expected Types::STRING, received Integer for field greeting> with backtrace: # ./lib/thrift/types.rb:69:in `check_type' # ./lib/thrift/struct.rb:42:in `block in initialize' # ./lib/thrift/struct.rb:38:in `each' # ./lib/thrift/struct.rb:38:in `initialize' # ./spec/struct_spec.rb:230:in `new' # ./spec/struct_spec.rb:230:in `block (4 levels) in <top (required)>' # ./spec/struct_spec.rb:230:in `block (3 levels) in <top (required)>' # ./spec/struct_spec.rb:230:in `block (3 levels) in <top (required)>' 2) Struct Thrift::Struct should support optional type-checking in field accessors Failure/Error: lambda { hello.greeting = 3 }.should raise_error(Thrift::TypeError, "Expected Types::STRING, received Fixnum for field greeting") expected Thrift::TypeError with "Expected Types::STRING, received Fixnum for field greeting", got #<Thrift::TypeError: Expected Types::STRING, received Integer for field greeting> with backtrace: # ./lib/thrift/types.rb:69:in `check_type' # ./lib/thrift/struct.rb:157:in `block in field_accessor' # ./spec/struct_spec.rb:241:in `block (4 levels) in <top (required)>' # ./spec/struct_spec.rb:241:in `block (3 levels) in <top (required)>' # ./spec/struct_spec.rb:241:in `block (3 levels) in <top (required)>' 3) Thrift::Types type checking should give the Thrift::TypeError a readable message Failure/Error: lambda { Thrift.check_type(3, {:type => Thrift::Types::STRING}, :foo) }.should raise_error(Thrift::TypeError, msg) expected Thrift::TypeError with "Expected Types::STRING, received Fixnum for field foo", got #<Thrift::TypeError: Expected Types::STRING, received Integer for field foo> with backtrace: # ./lib/thrift/types.rb:69:in `check_type' # ./spec/types_spec.rb:101:in `block (4 levels) in <top (required)>' # ./spec/types_spec.rb:101:in `block (3 levels) in <top (required)>' # ./spec/types_spec.rb:101:in `block (3 levels) in <top (required)>'
Cause
Starting in Ruby 2.4, ::Fixnum is deprecated. See https://bugs.ruby-lang.org/issues/12005
Solution
In lib/rb/spec/struct_spec.rb, change
lambda { SpecNamespace::Hello.new(:greeting => 3) }.should raise_error(Thrift::TypeError, "Expected Types::STRING, received Fixnum for field greeting")
to
lambda { SpecNamespace::Hello.new(:greeting => 3) }.should raise_error(Thrift::TypeError, "Expected Types::STRING, received Integer for field greeting")
and
lambda { hello.greeting = 3 }.should raise_error(Thrift::TypeError, "Expected Types::STRING, received Fixnum for field greeting")
to
lambda { hello.greeting = 3 }.should raise_error(Thrift::TypeError, "Expected Types::STRING, received Integer for field greeting")
In lib/rb/spec/types_spec.rb, change:
msg = "Expected Types::STRING, received Fixnum for field foo"
to
msg = "Expected Types::STRING, received Integer for field foo"
and
msg = "Expected Types::STRING, received Fixnum for field foo.element"
to
msg = "Expected Types::STRING, received Integer for field foo.element"
RSpec suite will then pass, and `sudo make install` will exit successfully.