summaryrefslogtreecommitdiff
path: root/lib/rb
diff options
context:
space:
mode:
authorJens Geyer <jensg@apache.org>2015-09-21 22:36:45 +0200
committerJens Geyer <jensg@apache.org>2015-09-21 22:36:45 +0200
commitb9257395509bc6fbcc2f77e0f9237e39f7ec1a7d (patch)
treed3e2947e03e5bc1c0994ea6804a8845f08dfb40a /lib/rb
parentff4a8edd50621fb6aab7dbbf6968d4322700ed7d (diff)
downloadthrift-b9257395509bc6fbcc2f77e0f9237e39f7ec1a7d.tar.gz
THRIFT-3335 Ruby server does not handle processor exception
Client: Ruby Patch: Nobuaki Sukegawa <nsukeg@gmail.com> This closes #612
Diffstat (limited to 'lib/rb')
-rw-r--r--lib/rb/lib/thrift/processor.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/rb/lib/thrift/processor.rb b/lib/rb/lib/thrift/processor.rb
index 5d9e0a11c..b96fb43b9 100644
--- a/lib/rb/lib/thrift/processor.rb
+++ b/lib/rb/lib/thrift/processor.rb
@@ -26,16 +26,18 @@ module Thrift
def process(iprot, oprot)
name, type, seqid = iprot.read_message_begin
if respond_to?("process_#{name}")
- send("process_#{name}", seqid, iprot, oprot)
+ begin
+ send("process_#{name}", seqid, iprot, oprot)
+ rescue => e
+ x = ApplicationException.new(ApplicationException::INTERNAL_ERROR, 'Internal error')
+ write_error(x, oprot, name, seqid)
+ end
true
else
iprot.skip(Types::STRUCT)
iprot.read_message_end
x = ApplicationException.new(ApplicationException::UNKNOWN_METHOD, 'Unknown function '+name)
- oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid)
- x.write(oprot)
- oprot.write_message_end
- oprot.trans.flush
+ write_error(x, oprot, name, seqid)
false
end
end
@@ -53,5 +55,14 @@ module Thrift
oprot.write_message_end
oprot.trans.flush
end
+
+ def write_error(err, oprot, name, seqid)
+ p 'write_error'
+ oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid)
+ err.write(oprot)
+ oprot.write_message_end
+ oprot.trans.flush
+ p 'write_error end'
+ end
end
end