Dmytro Shteflyuk created THRIFT-6140:
----------------------------------------

             Summary: Ruby SimpleServer stops after a short JSON UUID value
                 Key: THRIFT-6140
                 URL: https://issues.apache.org/jira/browse/THRIFT-6140
             Project: Thrift
          Issue Type: Bug
          Components: Ruby - Library
            Reporter: Dmytro Shteflyuk
            Assignee: Dmytro Shteflyuk


h3. Problem

Ruby JSONProtocol raises EOFError when it reads a complete JSON UUID string 
shorter than 36 characters. SimpleServer only treats Thrift transport and 
protocol exceptions as per-connection failures, so this error escapes the 
connection boundary and stops the serving loop.

h3. Client impact

A malformed JSON request containing a short UUID value stops the server loop 
instead of rejecting only that client connection. Valid UUID values are 
unaffected.

h3. Reproduction

Testing on master commit {{a9663bc6661a5dd1d99d629e1f269c1907592a1a}} produces:

{code:ruby}
require "thrift"

class ReproProcessor
  def process(input, _output)
    input.read_message_begin
    input.skip(Thrift::Types::STRUCT)
  end
end

class ReproServerTransport
  def initialize
    @accepts = 0
  end

  def listen; end
  def close; end

  def accept
    @accepts += 1
    throw :continued if @accepts > 1

    Thrift::MemoryBufferTransport.new(
      %q([1,"unknown",1,1,{"1":{"uid":"x"}}])
    )
  end
end

begin
  catch(:continued) do
    Thrift::SimpleServer.new(
      ReproProcessor.new,
      ReproServerTransport.new,
      nil,
      Thrift::JsonProtocolFactory.new
    ).serve
  end
rescue => error
  puts "#{error.class}: #{error.message}"
end
{code}

{noformat}
EOFError: EOFError
{noformat}

h3. Expected behavior

A complete but malformed UUID value should be rejected as 
Thrift::ProtocolException::INVALID_DATA. SimpleServer should close the 
malformed connection and continue accepting clients, while valid UUID values 
continue to round-trip.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to