Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-715

Thrift server built with ruby fails to return values of 0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.2
    • 0.3
    • Ruby - Library
    • 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'

      1. 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 = #

      {retval}

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

      Attachments

        1. myservice.thrift
          0.1 kB
          Larry Kang
        2. cl.rb
          0.5 kB
          Larry Kang
        3. svr.rb
          0.8 kB
          Larry Kang
        4. THRIFT-715.patch
          0.6 kB
          Larry Kang

        Activity

          People

            bryanduxbury Bryan Duxbury
            lkang Larry Kang
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: