Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.2
-
None
-
Linux on x86_64
Description
A thrift server built with ruby does will only return nonzero values from the handler functions.
In the following test case, when registerClient returns 0, the client throws an exception. If register client returns a nonzero value, no exception is generated.
Test case:
file myservice.thrift:
service MyService{
bool registerClient(1:string email);
}
Create a server handler in ruby:
file svr.rb:
$:.push('./gen-rb')
require 'thrift/transport/socket'
require 'thrift/protocol/binaryprotocol'
require 'thrift/server'
require 'MyService'
def class MyServiceHandler
def registerClient ( email )
return false # works for 'return true'
end
end
handler = MyServiceHandler.new()
processor = MyService::Processor.new(handler)
transport = Thrift::ServerSocket.new( 9030 ) # client code
server = Thrift::SimpleServer.new(processor, transport )
puts "Starting the MyService server..."
server.serve()
puts "Done"
Here's the client:
file cl.rb:
require 'gen-rb/MyService.rb'
- include Thrift
def run( )
transport = Thrift::Socket.new( "localhost", 9030, 10 )
transport.open
protocol = Thrift::BinaryProtocol.new( transport )
client = MyService::Client.new( protocol )
puts "MyService client created"
begin
retval = client.registerClient( "email@host.com" )
rescue Exception => e
puts "Exception caught during registerClient:
puts e.message
else
puts "registerClient returned = #
"
end
end
run()
The following error is put out by the client:
Exception caught during registerClient
registerClient failed: unknown result
The problem appears in both thrift-instant-r760184.tar.gz (from facebook.com) and thrift-0.2.0-incubating.tar.gz from Apache.
=========
The offending code is in struct.rb, Struct.write:
if (value = instance_variable_get("@#
{name}"))It appears to have been fixed in r915499 with the following code:
value = instance_variable_get("@#{name}
")
unless value.nil?