upfluence-thrift 2.7.4 → 2.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/thrift/exceptions.rb +4 -1
- data/lib/thrift/processor.rb +41 -45
- data/lib/thrift/types/program_definition/program_definition_types.rb +10 -1
- data/spec/processor_spec.rb +183 -56
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e31952e8e892fc4b82c5a19ac4145bf6c8d439474b83b8162119a11cedc5b0d
|
|
4
|
+
data.tar.gz: '049b17f3c6bba2b2ce85aff58417785465614992435667036fcda62bf4f43fa9'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b5a53855250a59549aaab99463b1fd8512c9d2379f6dfbee1407357f3270b8717ed009319923a64d023402ff50c01d7d62fb413c064d9e31cf94656529555f83
|
|
7
|
+
data.tar.gz: 98d79404c6044387670b06ceef345acdfa70d618d645da24d02b1ff191eef1cdf8a22723ce06b13de8a4b59653a9a6daec6b4639fb5b538ad283229458743887
|
data/lib/thrift/exceptions.rb
CHANGED
|
@@ -37,9 +37,12 @@ module Thrift
|
|
|
37
37
|
MISSING_RESULT = 5
|
|
38
38
|
INTERNAL_ERROR = 6
|
|
39
39
|
PROTOCOL_ERROR = 7
|
|
40
|
-
|
|
40
|
+
INTERNAL_TIME_OUT_ERROR = 8
|
|
41
|
+
INVALID_TRANSFORM = 11
|
|
41
42
|
INVALID_PROTOCOL = 9
|
|
42
43
|
UNSUPPORTED_CLIENT_TYPE = 10
|
|
44
|
+
METHOD_NOT_IMPLEMENTED = 12
|
|
45
|
+
|
|
43
46
|
|
|
44
47
|
attr_reader :type
|
|
45
48
|
|
data/lib/thrift/processor.rb
CHANGED
|
@@ -59,22 +59,7 @@ module Thrift
|
|
|
59
59
|
|
|
60
60
|
write_result(result, oprot, seqid)
|
|
61
61
|
rescue => e
|
|
62
|
-
write_exception(e, oprot, seqid)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def write_exception(exception, oprot, seqid)
|
|
66
|
-
oprot.write_message_begin(@fname, MessageTypes::EXCEPTION, seqid)
|
|
67
|
-
|
|
68
|
-
unless exception.is_a? ApplicationException
|
|
69
|
-
exception = ApplicationException.new(
|
|
70
|
-
ApplicationException::INTERNAL_ERROR,
|
|
71
|
-
"Internal error processing #{@fname}: #{exception.class}: #{exception}"
|
|
72
|
-
)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
exception.write(oprot)
|
|
76
|
-
oprot.write_message_end
|
|
77
|
-
oprot.trans.flush
|
|
62
|
+
Processor.write_exception(e, oprot, @fname, seqid)
|
|
78
63
|
end
|
|
79
64
|
|
|
80
65
|
def write_result(result, oprot, seqid)
|
|
@@ -131,11 +116,18 @@ module Thrift
|
|
|
131
116
|
end
|
|
132
117
|
|
|
133
118
|
def process(iprot, oprot)
|
|
134
|
-
name,
|
|
119
|
+
name, type, seqid = iprot.read_message_begin
|
|
135
120
|
|
|
136
121
|
mth = "process_#{name}"
|
|
137
122
|
if respond_to?(mth)
|
|
138
|
-
|
|
123
|
+
begin
|
|
124
|
+
send(mth, seqid, iprot, oprot)
|
|
125
|
+
rescue StandardError => e
|
|
126
|
+
raise e if type == MessageTypes::ONEWAY
|
|
127
|
+
|
|
128
|
+
Processor.write_internal_error(e, oprot, name, seqid)
|
|
129
|
+
end
|
|
130
|
+
|
|
139
131
|
return true
|
|
140
132
|
end
|
|
141
133
|
|
|
@@ -144,8 +136,35 @@ module Thrift
|
|
|
144
136
|
).process(seqid, iprot, oprot)
|
|
145
137
|
end
|
|
146
138
|
|
|
139
|
+
def self.write_exception(exception, oprot, name, seqid)
|
|
140
|
+
oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid)
|
|
141
|
+
|
|
142
|
+
unless exception.is_a? ApplicationException
|
|
143
|
+
exception = ApplicationException.new(
|
|
144
|
+
ApplicationException::INTERNAL_ERROR,
|
|
145
|
+
"Internal error processing #{name}: #{exception.class}: #{exception}"
|
|
146
|
+
)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
exception.write(oprot)
|
|
150
|
+
oprot.write_message_end
|
|
151
|
+
oprot.trans.flush
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def self.write_internal_error(exception, oprot, name, seqid)
|
|
155
|
+
write_exception(
|
|
156
|
+
ApplicationException.new(
|
|
157
|
+
ApplicationException::INTERNAL_ERROR,
|
|
158
|
+
"Internal error processing #{name}: #{exception.class}: #{exception}"
|
|
159
|
+
),
|
|
160
|
+
oprot,
|
|
161
|
+
name,
|
|
162
|
+
seqid
|
|
163
|
+
)
|
|
164
|
+
end
|
|
165
|
+
|
|
147
166
|
def build_processor(name, info)
|
|
148
|
-
if info[:result_klass].nil?
|
|
167
|
+
if info[:result_klass].nil? && info[:oneway]
|
|
149
168
|
UnaryProcessor
|
|
150
169
|
elsif info[:stream_klass].nil? && info[:sink_klass].nil?
|
|
151
170
|
BinaryProcessor
|
|
@@ -173,21 +192,6 @@ module Thrift
|
|
|
173
192
|
args
|
|
174
193
|
end
|
|
175
194
|
|
|
176
|
-
def write_exception(exception, oprot, name, seqid)
|
|
177
|
-
oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid)
|
|
178
|
-
|
|
179
|
-
unless exception.is_a? ApplicationException
|
|
180
|
-
exception = ApplicationException.new(
|
|
181
|
-
ApplicationException::INTERNAL_ERROR,
|
|
182
|
-
"Internal error processing #{name}: #{exception.class}: #{exception}"
|
|
183
|
-
)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
exception.write(oprot)
|
|
187
|
-
oprot.write_message_end
|
|
188
|
-
oprot.trans.flush
|
|
189
|
-
end
|
|
190
|
-
|
|
191
195
|
def write_result(result, oprot, seqid)
|
|
192
196
|
oprot.write_message_begin(@name, MessageTypes::REPLY, seqid)
|
|
193
197
|
result.write(oprot)
|
|
@@ -236,18 +240,10 @@ module Thrift
|
|
|
236
240
|
|
|
237
241
|
true
|
|
238
242
|
rescue ApplicationException => e
|
|
239
|
-
write_exception(e, oprot, @name, seqid)
|
|
243
|
+
Processor.write_exception(e, oprot, @name, seqid)
|
|
240
244
|
true
|
|
241
245
|
rescue StandardError => e
|
|
242
|
-
|
|
243
|
-
ApplicationException.new(
|
|
244
|
-
ApplicationException::INTERNAL_ERROR,
|
|
245
|
-
"Internal error processing #{@name}: #{e.class}: #{e}"
|
|
246
|
-
),
|
|
247
|
-
oprot,
|
|
248
|
-
@name,
|
|
249
|
-
seqid
|
|
250
|
-
)
|
|
246
|
+
Processor.write_internal_error(e, oprot, @name, seqid)
|
|
251
247
|
true
|
|
252
248
|
end
|
|
253
249
|
|
|
@@ -400,7 +396,7 @@ module Thrift
|
|
|
400
396
|
def process(seqid, iprot, oprot)
|
|
401
397
|
iprot.skip(Types::STRUCT)
|
|
402
398
|
iprot.read_message_end
|
|
403
|
-
write_exception(
|
|
399
|
+
Processor.write_exception(
|
|
404
400
|
ApplicationException.new(
|
|
405
401
|
ApplicationException::UNKNOWN_METHOD,
|
|
406
402
|
'Unknown function ' + @name,
|
|
@@ -40,6 +40,7 @@ module Thrift
|
|
|
40
40
|
THRIFT_FIELD_INDEX_CONSTANTS = 8
|
|
41
41
|
THRIFT_FIELD_INDEX_TYPEDEFS = 9
|
|
42
42
|
THRIFT_FIELD_INDEX_ENUMS = 10
|
|
43
|
+
THRIFT_FIELD_INDEX_STDLIB = 11
|
|
43
44
|
|
|
44
45
|
THRIFT_FIELD_NAME_LEGACY_ANNOTATIONS = {
|
|
45
46
|
}.freeze
|
|
@@ -101,6 +102,12 @@ module Thrift
|
|
|
101
102
|
THRIFT_FIELD_ENUMS_STRUCTURED_ANNOTATIONS = [
|
|
102
103
|
].freeze
|
|
103
104
|
|
|
105
|
+
THRIFT_FIELD_STDLIB_LEGACY_ANNOTATIONS = {
|
|
106
|
+
}.freeze
|
|
107
|
+
|
|
108
|
+
THRIFT_FIELD_STDLIB_STRUCTURED_ANNOTATIONS = [
|
|
109
|
+
].freeze
|
|
110
|
+
|
|
104
111
|
FIELDS = {
|
|
105
112
|
THRIFT_FIELD_INDEX_NAME => {type: ::Thrift::Types::STRING, name: 'name', legacy_annotations: THRIFT_FIELD_NAME_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_NAME_STRUCTURED_ANNOTATIONS},
|
|
106
113
|
THRIFT_FIELD_INDEX_PATH => {type: ::Thrift::Types::STRING, name: 'path', legacy_annotations: THRIFT_FIELD_PATH_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_PATH_STRUCTURED_ANNOTATIONS},
|
|
@@ -111,7 +118,8 @@ module Thrift
|
|
|
111
118
|
THRIFT_FIELD_INDEX_SERVICES => {type: ::Thrift::Types::MAP, name: 'services', key: {type: ::Thrift::Types::STRING}, value: {type: ::Thrift::Types::STRUCT, class: ::Thrift::Types::Service_definition::ServiceDefinition}, legacy_annotations: THRIFT_FIELD_SERVICES_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_SERVICES_STRUCTURED_ANNOTATIONS},
|
|
112
119
|
THRIFT_FIELD_INDEX_CONSTANTS => {type: ::Thrift::Types::MAP, name: 'constants', key: {type: ::Thrift::Types::STRING}, value: {type: ::Thrift::Types::STRUCT, class: ::Thrift::Types::Constant_definition::ConstantDefinition}, legacy_annotations: THRIFT_FIELD_CONSTANTS_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_CONSTANTS_STRUCTURED_ANNOTATIONS},
|
|
113
120
|
THRIFT_FIELD_INDEX_TYPEDEFS => {type: ::Thrift::Types::MAP, name: 'typedefs', key: {type: ::Thrift::Types::STRING}, value: {type: ::Thrift::Types::STRUCT, class: ::Thrift::Types::Type_definition::TypeDefinition}, legacy_annotations: THRIFT_FIELD_TYPEDEFS_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_TYPEDEFS_STRUCTURED_ANNOTATIONS},
|
|
114
|
-
THRIFT_FIELD_INDEX_ENUMS => {type: ::Thrift::Types::MAP, name: 'enums', key: {type: ::Thrift::Types::STRING}, value: {type: ::Thrift::Types::STRUCT, class: ::Thrift::Types::Enum_definition::EnumDefinition}, legacy_annotations: THRIFT_FIELD_ENUMS_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_ENUMS_STRUCTURED_ANNOTATIONS}
|
|
121
|
+
THRIFT_FIELD_INDEX_ENUMS => {type: ::Thrift::Types::MAP, name: 'enums', key: {type: ::Thrift::Types::STRING}, value: {type: ::Thrift::Types::STRUCT, class: ::Thrift::Types::Enum_definition::EnumDefinition}, legacy_annotations: THRIFT_FIELD_ENUMS_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_ENUMS_STRUCTURED_ANNOTATIONS},
|
|
122
|
+
THRIFT_FIELD_INDEX_STDLIB => {type: ::Thrift::Types::BOOL, name: 'stdlib', legacy_annotations: THRIFT_FIELD_STDLIB_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_STDLIB_STRUCTURED_ANNOTATIONS}
|
|
115
123
|
}.freeze
|
|
116
124
|
|
|
117
125
|
def struct_fields; FIELDS; end
|
|
@@ -126,6 +134,7 @@ module Thrift
|
|
|
126
134
|
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field constants is unset!') unless @constants
|
|
127
135
|
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field typedefs is unset!') unless @typedefs
|
|
128
136
|
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field enums is unset!') unless @enums
|
|
137
|
+
raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field stdlib is unset!') if @stdlib.nil?
|
|
129
138
|
end
|
|
130
139
|
|
|
131
140
|
::Thrift::Struct.generate_accessors self
|
data/spec/processor_spec.rb
CHANGED
|
@@ -19,73 +19,200 @@
|
|
|
19
19
|
|
|
20
20
|
require 'spec_helper'
|
|
21
21
|
|
|
22
|
-
describe
|
|
23
|
-
class
|
|
24
|
-
include Thrift::
|
|
22
|
+
describe Thrift::Processor do
|
|
23
|
+
class EmptyArgs
|
|
24
|
+
include Thrift::Struct_Union
|
|
25
|
+
include Thrift::Struct
|
|
26
|
+
|
|
27
|
+
FIELDS = {}.freeze
|
|
28
|
+
|
|
29
|
+
def struct_fields
|
|
30
|
+
FIELDS
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def validate; end
|
|
25
34
|
end
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
class EmptyResult
|
|
37
|
+
include Thrift::Struct_Union
|
|
38
|
+
include Thrift::Struct
|
|
39
|
+
|
|
40
|
+
FIELDS = {}.freeze
|
|
41
|
+
|
|
42
|
+
def struct_fields
|
|
43
|
+
FIELDS
|
|
31
44
|
end
|
|
32
45
|
|
|
33
|
-
def
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
def validate; end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class LegacyProcessor
|
|
50
|
+
include Thrift::Processor
|
|
51
|
+
|
|
52
|
+
def process_ping(seqid, iprot, oprot)
|
|
53
|
+
args = read_args(iprot, EmptyArgs)
|
|
54
|
+
result = @middleware.handle_binary('ping', args) do
|
|
55
|
+
@handler.ping
|
|
56
|
+
EmptyResult.new
|
|
38
57
|
end
|
|
39
|
-
end
|
|
40
58
|
|
|
41
|
-
|
|
42
|
-
expect(@prot).to receive(:read_message_begin).ordered.and_return ['testMessage', Thrift::MessageTypes::CALL, 17]
|
|
43
|
-
expect(@processor).to receive(:process_testMessage).with(17, @prot, @prot).ordered
|
|
44
|
-
expect(@processor.process(@prot, @prot)).to eq(true)
|
|
59
|
+
write_result(result, oprot, 'ping', seqid)
|
|
45
60
|
end
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
expect(@prot).to receive(:skip).with(Thrift::Types::STRUCT).ordered
|
|
50
|
-
expect(@prot).to receive(:read_message_end).ordered
|
|
51
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::EXCEPTION, 4).ordered
|
|
52
|
-
e = Thrift::ApplicationException.new(
|
|
53
|
-
Thrift::ApplicationException::UNKNOWN_METHOD,
|
|
54
|
-
'Unknown function testMessage'
|
|
55
|
-
)
|
|
56
|
-
expect(Thrift::ApplicationException).to receive(:new).with(Thrift::ApplicationException::UNKNOWN_METHOD,
|
|
57
|
-
'Unknown function testMessage').and_return(e)
|
|
58
|
-
expect(@prot).to receive(:write_struct_begin).with('Thrift::ApplicationException').ordered
|
|
59
|
-
expect(@prot).to receive(:write_field_begin).with('message', Thrift::Types::STRING, 1).ordered
|
|
60
|
-
expect(@prot).to receive(:write_string).with('Unknown function testMessage').ordered
|
|
61
|
-
expect(@prot).to receive(:write_field_end).ordered
|
|
62
|
-
expect(@prot).to receive(:write_field_begin).with('type', Thrift::Types::I32, 2).ordered
|
|
63
|
-
expect(@prot).to receive(:write_i32).with(Thrift::ApplicationException::UNKNOWN_METHOD).ordered
|
|
64
|
-
expect(@prot).to receive(:write_field_end).ordered
|
|
65
|
-
expect(@prot).to receive(:write_field_stop).ordered
|
|
66
|
-
expect(@prot).to receive(:write_struct_end).ordered
|
|
67
|
-
expect(@prot).to receive(:write_message_end).ordered
|
|
68
|
-
mock_trans(@prot)
|
|
69
|
-
@processor.process(@prot, @prot)
|
|
70
|
-
end
|
|
62
|
+
def process_notify(_seqid, iprot, _oprot)
|
|
63
|
+
args = read_args(iprot, EmptyArgs)
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
args = double('#<MockArgsClass:mock>').tap do |args|
|
|
75
|
-
expect(args).to receive(:read).with(@prot).ordered
|
|
65
|
+
@middleware.handle_unary('notify', args) do
|
|
66
|
+
@handler.notify
|
|
76
67
|
end
|
|
77
|
-
expect(args_class).to receive(:new).and_return args
|
|
78
|
-
expect(@prot).to receive(:read_message_end).ordered
|
|
79
|
-
expect(@processor.read_args(@prot, args_class)).to eql(args)
|
|
80
68
|
end
|
|
69
|
+
end
|
|
81
70
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
71
|
+
class CurrentProcessor
|
|
72
|
+
include Thrift::Processor
|
|
73
|
+
|
|
74
|
+
METHODS = {
|
|
75
|
+
'ping' => {
|
|
76
|
+
args_klass: EmptyArgs,
|
|
77
|
+
result_klass: EmptyResult,
|
|
78
|
+
args: [],
|
|
79
|
+
exceptions: {},
|
|
80
|
+
oneway: false
|
|
81
|
+
}
|
|
82
|
+
}.freeze
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def request_protocol(name, type = Thrift::MessageTypes::CALL, seqid = 17)
|
|
86
|
+
trans = Thrift::MemoryBufferTransport.new
|
|
87
|
+
protocol = Thrift::BinaryProtocol.new(trans)
|
|
88
|
+
protocol.write_message_begin(name, type, seqid)
|
|
89
|
+
EmptyArgs.new.write(protocol)
|
|
90
|
+
protocol.write_message_end
|
|
91
|
+
|
|
92
|
+
Thrift::BinaryProtocol.new(trans)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def output_protocol
|
|
96
|
+
trans = Thrift::MemoryBufferTransport.new
|
|
97
|
+
|
|
98
|
+
[Thrift::BinaryProtocol.new(trans), trans]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def read_exception(protocol)
|
|
102
|
+
name, type, seqid = protocol.read_message_begin
|
|
103
|
+
exception = Thrift::ApplicationException.new
|
|
104
|
+
exception.read(protocol)
|
|
105
|
+
protocol.read_message_end
|
|
106
|
+
|
|
107
|
+
{
|
|
108
|
+
name: name,
|
|
109
|
+
type: type,
|
|
110
|
+
seqid: seqid,
|
|
111
|
+
exception_type: exception.type,
|
|
112
|
+
message: exception.message
|
|
113
|
+
}
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'processes requests with a legacy generated stub' do
|
|
117
|
+
handler = double('handler', ping: nil)
|
|
118
|
+
processor = LegacyProcessor.new(handler)
|
|
119
|
+
oprot, trans = output_protocol
|
|
120
|
+
|
|
121
|
+
expect(processor.process(request_protocol('ping'), oprot)).to eq(true)
|
|
122
|
+
expect(oprot.read_message_begin).to eq(
|
|
123
|
+
['ping', Thrift::MessageTypes::REPLY, 17]
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
EmptyResult.new.read(oprot)
|
|
127
|
+
oprot.read_message_end
|
|
128
|
+
|
|
129
|
+
expect(trans.available).to eq(0)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'writes internal errors raised by a legacy generated stub' do
|
|
133
|
+
handler = double('handler')
|
|
134
|
+
allow(handler).to receive(:ping).and_raise(StandardError, 'boom')
|
|
135
|
+
processor = LegacyProcessor.new(handler)
|
|
136
|
+
oprot, = output_protocol
|
|
137
|
+
|
|
138
|
+
expect(processor.process(request_protocol('ping'), oprot)).to eq(true)
|
|
139
|
+
expect(read_exception(oprot)).to eq(
|
|
140
|
+
name: 'ping',
|
|
141
|
+
type: Thrift::MessageTypes::EXCEPTION,
|
|
142
|
+
seqid: 17,
|
|
143
|
+
exception_type: Thrift::ApplicationException::INTERNAL_ERROR,
|
|
144
|
+
message: 'Internal error processing ping: StandardError: boom'
|
|
145
|
+
)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'raises errors from a legacy oneway method without writing a response' do
|
|
149
|
+
handler = double('handler')
|
|
150
|
+
allow(handler).to receive(:notify).and_raise(StandardError, 'boom')
|
|
151
|
+
processor = LegacyProcessor.new(handler)
|
|
152
|
+
oprot, trans = output_protocol
|
|
153
|
+
|
|
154
|
+
expect do
|
|
155
|
+
processor.process(
|
|
156
|
+
request_protocol('notify', Thrift::MessageTypes::ONEWAY),
|
|
157
|
+
oprot
|
|
158
|
+
)
|
|
159
|
+
end.to raise_error(StandardError, 'boom')
|
|
160
|
+
expect(trans.available).to eq(0)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it 'writes an unknown method exception' do
|
|
164
|
+
processor = CurrentProcessor.new(double('handler'))
|
|
165
|
+
oprot, = output_protocol
|
|
166
|
+
|
|
167
|
+
expect(
|
|
168
|
+
processor.process(
|
|
169
|
+
request_protocol('missing', Thrift::MessageTypes::CALL, 4),
|
|
170
|
+
oprot
|
|
171
|
+
)
|
|
172
|
+
).to eq(false)
|
|
173
|
+
expect(read_exception(oprot)).to eq(
|
|
174
|
+
name: 'missing',
|
|
175
|
+
type: Thrift::MessageTypes::EXCEPTION,
|
|
176
|
+
seqid: 4,
|
|
177
|
+
exception_type: Thrift::ApplicationException::UNKNOWN_METHOD,
|
|
178
|
+
message: 'Unknown function missing'
|
|
179
|
+
)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it 'writes internal errors raised by a current processor' do
|
|
183
|
+
handler = double('handler')
|
|
184
|
+
allow(handler).to receive(:ping).and_raise(StandardError, 'boom')
|
|
185
|
+
processor = CurrentProcessor.new(handler)
|
|
186
|
+
oprot, = output_protocol
|
|
187
|
+
|
|
188
|
+
expect(processor.process(request_protocol('ping'), oprot)).to eq(true)
|
|
189
|
+
expect(read_exception(oprot)).to eq(
|
|
190
|
+
name: 'ping',
|
|
191
|
+
type: Thrift::MessageTypes::EXCEPTION,
|
|
192
|
+
seqid: 17,
|
|
193
|
+
exception_type: Thrift::ApplicationException::INTERNAL_ERROR,
|
|
194
|
+
message: 'Internal error processing ping: StandardError: boom'
|
|
195
|
+
)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it 'preserves application exceptions raised by a current processor' do
|
|
199
|
+
handler = double('handler')
|
|
200
|
+
allow(handler).to receive(:ping).and_raise(
|
|
201
|
+
Thrift::ApplicationException.new(
|
|
202
|
+
Thrift::ApplicationException::PROTOCOL_ERROR,
|
|
203
|
+
'invalid request'
|
|
204
|
+
)
|
|
205
|
+
)
|
|
206
|
+
processor = CurrentProcessor.new(handler)
|
|
207
|
+
oprot, = output_protocol
|
|
208
|
+
|
|
209
|
+
expect(processor.process(request_protocol('ping'), oprot)).to eq(true)
|
|
210
|
+
expect(read_exception(oprot)).to eq(
|
|
211
|
+
name: 'ping',
|
|
212
|
+
type: Thrift::MessageTypes::EXCEPTION,
|
|
213
|
+
seqid: 17,
|
|
214
|
+
exception_type: Thrift::ApplicationException::PROTOCOL_ERROR,
|
|
215
|
+
message: 'invalid request'
|
|
216
|
+
)
|
|
90
217
|
end
|
|
91
218
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: upfluence-thrift
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.7.
|
|
4
|
+
version: 2.7.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thrift Developers
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-08-13 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rspec
|