thrift 0.22.0 → 0.24.0
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/README.md +235 -17
- data/benchmark/benchmark.rb +23 -8
- data/benchmark/client.rb +50 -6
- data/benchmark/server.rb +46 -7
- data/benchmark/thin_server.rb +2 -0
- data/ext/binary_protocol_accelerated.c +154 -42
- data/ext/bytes.c +14 -0
- data/ext/compact_protocol.c +138 -45
- data/ext/constants.h +12 -0
- data/ext/extconf.rb +17 -8
- data/ext/memory_buffer.c +44 -7
- data/ext/protocol.c +29 -0
- data/ext/protocol.h +35 -0
- data/ext/struct.c +48 -17
- data/ext/thrift_native.c +28 -3
- data/lib/thrift/bytes.rb +70 -100
- data/lib/thrift/client.rb +54 -13
- data/lib/thrift/exceptions.rb +6 -5
- data/lib/thrift/multiplexed_processor.rb +20 -10
- data/lib/thrift/processor.rb +7 -6
- data/lib/thrift/protocol/base_protocol.rb +52 -21
- data/lib/thrift/protocol/binary_protocol.rb +65 -20
- data/lib/thrift/protocol/binary_protocol_accelerated.rb +6 -5
- data/lib/thrift/protocol/compact_protocol.rb +76 -41
- data/lib/thrift/protocol/header_protocol.rb +321 -0
- data/lib/thrift/protocol/json_protocol.rb +44 -27
- data/lib/thrift/protocol/multiplexed_protocol.rb +6 -5
- data/lib/thrift/protocol/protocol_decorator.rb +13 -4
- data/lib/thrift/serializer/deserializer.rb +6 -5
- data/lib/thrift/serializer/serializer.rb +5 -5
- data/lib/thrift/server/base_server.rb +5 -4
- data/lib/thrift/server/mongrel_http_server.rb +7 -6
- data/lib/thrift/server/nonblocking_server.rb +35 -9
- data/lib/thrift/server/simple_server.rb +13 -5
- data/lib/thrift/server/thin_http_server.rb +4 -3
- data/lib/thrift/server/thread_pool_server.rb +7 -6
- data/lib/thrift/server/threaded_server.rb +13 -5
- data/lib/thrift/struct.rb +12 -11
- data/lib/thrift/struct_union.rb +14 -9
- data/lib/thrift/thrift_native.rb +3 -2
- data/lib/thrift/transport/base_server_transport.rb +8 -5
- data/lib/thrift/transport/base_transport.rb +18 -14
- data/lib/thrift/transport/buffered_transport.rb +7 -6
- data/lib/thrift/transport/framed_transport.rb +8 -7
- data/lib/thrift/transport/header_transport.rb +562 -0
- data/lib/thrift/transport/http_client_transport.rb +2 -1
- data/lib/thrift/transport/io_stream_transport.rb +4 -3
- data/lib/thrift/transport/memory_buffer_transport.rb +13 -6
- data/lib/thrift/transport/server_socket.rb +14 -8
- data/lib/thrift/transport/socket.rb +126 -60
- data/lib/thrift/transport/ssl_server_socket.rb +4 -3
- data/lib/thrift/transport/ssl_socket.rb +45 -13
- data/lib/thrift/transport/unix_server_socket.rb +9 -5
- data/lib/thrift/transport/unix_socket.rb +7 -6
- data/lib/thrift/types.rb +10 -6
- data/lib/thrift/union.rb +15 -8
- data/lib/thrift/uuid.rb +50 -0
- data/lib/thrift.rb +4 -1
- data/spec/ThriftSpec.thrift +21 -1
- data/spec/base_protocol_spec.rb +21 -2
- data/spec/base_transport_spec.rb +48 -8
- data/spec/binary_protocol_accelerated_spec.rb +1 -0
- data/spec/binary_protocol_spec.rb +1 -2
- data/spec/binary_protocol_spec_shared.rb +206 -155
- data/spec/bytes_spec.rb +71 -114
- data/spec/client_spec.rb +86 -19
- data/spec/compact_protocol_spec.rb +153 -16
- data/spec/constants_demo_spec.rb +102 -0
- data/spec/exception_spec.rb +1 -1
- data/spec/flat_spec.rb +1 -0
- data/spec/header_protocol_spec.rb +476 -0
- data/spec/header_transport_spec.rb +431 -0
- data/spec/http_client_spec.rb +5 -6
- data/spec/json_protocol_spec.rb +69 -47
- data/spec/multiplexed_processor_spec.rb +75 -0
- data/spec/namespaced_spec.rb +1 -1
- data/spec/nonblocking_server_spec.rb +174 -8
- data/spec/processor_spec.rb +1 -1
- data/spec/recursion_depth_spec.rb +223 -0
- data/spec/serializer_spec.rb +1 -1
- data/spec/server_socket_spec.rb +38 -1
- data/spec/server_spec.rb +60 -9
- data/spec/socket_spec.rb +119 -13
- data/spec/socket_spec_shared.rb +73 -9
- data/spec/spec_helper.rb +2 -1
- data/spec/ssl_server_socket_spec.rb +52 -1
- data/spec/ssl_socket_spec.rb +181 -11
- data/spec/struct_nested_containers_spec.rb +2 -2
- data/spec/struct_spec.rb +114 -9
- data/spec/support/header_protocol_helper.rb +55 -0
- data/spec/thin_http_server_spec.rb +4 -18
- data/spec/types_spec.rb +26 -26
- data/spec/union_spec.rb +70 -11
- data/spec/unix_socket_spec.rb +17 -2
- data/spec/uuid_validation_spec.rb +239 -0
- data/test/fuzz/Makefile +779 -0
- data/test/fuzz/Makefile.am +173 -0
- data/test/fuzz/Makefile.in +775 -0
- data/test/fuzz/README.md +149 -0
- data/test/fuzz/fuzz_common.rb +96 -0
- data/{lib/thrift/core_ext.rb → test/fuzz/fuzz_parse_binary_protocol.rb} +4 -4
- data/{lib/thrift/core_ext/fixnum.rb → test/fuzz/fuzz_parse_binary_protocol_accelerated.rb} +7 -13
- data/test/fuzz/fuzz_parse_binary_protocol_accelerated_harness.rb +23 -0
- data/test/fuzz/fuzz_parse_binary_protocol_harness.rb +23 -0
- data/test/fuzz/fuzz_parse_compact_protocol.rb +23 -0
- data/test/fuzz/fuzz_parse_compact_protocol_harness.rb +23 -0
- data/test/fuzz/fuzz_parse_json_protocol.rb +23 -0
- data/test/fuzz/fuzz_parse_json_protocol_harness.rb +23 -0
- data/test/fuzz/fuzz_roundtrip_binary_protocol.rb +23 -0
- data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated.rb +23 -0
- data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated_harness.rb +23 -0
- data/test/fuzz/fuzz_roundtrip_binary_protocol_harness.rb +23 -0
- data/test/fuzz/fuzz_roundtrip_compact_protocol.rb +23 -0
- data/test/fuzz/fuzz_roundtrip_compact_protocol_harness.rb +23 -0
- data/test/fuzz/fuzz_roundtrip_json_protocol.rb +23 -0
- data/test/fuzz/fuzz_roundtrip_json_protocol_harness.rb +23 -0
- data/test/fuzz/fuzz_tracer.rb +29 -0
- metadata +105 -70
data/lib/thrift/uuid.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'thrift/protocol/base_protocol'
|
|
22
|
+
|
|
23
|
+
module Thrift
|
|
24
|
+
module UUID
|
|
25
|
+
UUID_REGEX = /\A[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\z/.freeze
|
|
26
|
+
|
|
27
|
+
def self.validate_uuid!(uuid)
|
|
28
|
+
unless uuid.is_a?(String)
|
|
29
|
+
raise ProtocolException.new(ProtocolException::INVALID_DATA, 'UUID must be a string')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
unless uuid =~ UUID_REGEX
|
|
33
|
+
raise ProtocolException.new(ProtocolException::INVALID_DATA, 'Invalid UUID format')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.uuid_bytes(uuid)
|
|
38
|
+
[uuid.delete('-')].pack('H*')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.uuid_from_bytes(bytes)
|
|
42
|
+
unless bytes.bytesize == 16
|
|
43
|
+
raise ProtocolException.new(ProtocolException::INVALID_DATA, 'Invalid UUID data length')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
hex = bytes.unpack('H*').first
|
|
47
|
+
"#{hex[0, 8]}-#{hex[8, 4]}-#{hex[12, 4]}-#{hex[16, 4]}-#{hex[20, 12]}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/thrift.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
#
|
|
2
3
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
4
|
# or more contributor license agreements. See the NOTICE file
|
|
@@ -23,7 +24,6 @@
|
|
|
23
24
|
$:.unshift File.dirname(__FILE__)
|
|
24
25
|
|
|
25
26
|
require 'thrift/bytes'
|
|
26
|
-
require 'thrift/core_ext'
|
|
27
27
|
require 'thrift/exceptions'
|
|
28
28
|
require 'thrift/types'
|
|
29
29
|
require 'thrift/processor'
|
|
@@ -32,6 +32,7 @@ require 'thrift/client'
|
|
|
32
32
|
require 'thrift/struct'
|
|
33
33
|
require 'thrift/union'
|
|
34
34
|
require 'thrift/struct_union'
|
|
35
|
+
require 'thrift/uuid'
|
|
35
36
|
|
|
36
37
|
# serializer
|
|
37
38
|
require 'thrift/serializer/serializer'
|
|
@@ -44,6 +45,7 @@ require 'thrift/protocol/binary_protocol_accelerated'
|
|
|
44
45
|
require 'thrift/protocol/compact_protocol'
|
|
45
46
|
require 'thrift/protocol/json_protocol'
|
|
46
47
|
require 'thrift/protocol/multiplexed_protocol'
|
|
48
|
+
require 'thrift/protocol/header_protocol'
|
|
47
49
|
|
|
48
50
|
# transport
|
|
49
51
|
require 'thrift/transport/base_transport'
|
|
@@ -56,6 +58,7 @@ require 'thrift/transport/unix_socket'
|
|
|
56
58
|
require 'thrift/transport/unix_server_socket'
|
|
57
59
|
require 'thrift/transport/buffered_transport'
|
|
58
60
|
require 'thrift/transport/framed_transport'
|
|
61
|
+
require 'thrift/transport/header_transport'
|
|
59
62
|
require 'thrift/transport/http_client_transport'
|
|
60
63
|
require 'thrift/transport/io_stream_transport'
|
|
61
64
|
require 'thrift/transport/memory_buffer_transport'
|
data/spec/ThriftSpec.thrift
CHANGED
|
@@ -60,6 +60,7 @@ union TestUnion {
|
|
|
60
60
|
3: i32 other_i32_field;
|
|
61
61
|
4: SomeEnum enum_field;
|
|
62
62
|
5: binary binary_field;
|
|
63
|
+
6: uuid uuid_field;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
struct Foo {
|
|
@@ -71,6 +72,7 @@ struct Foo {
|
|
|
71
72
|
6: set<i16> shorts = [5, 17, 239],
|
|
72
73
|
7: optional string opt_string
|
|
73
74
|
8: bool my_bool
|
|
75
|
+
9: optional uuid opt_uuid
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
struct Foo2 {
|
|
@@ -92,7 +94,8 @@ struct SimpleList {
|
|
|
92
94
|
8: list<map<i16, i16>> maps,
|
|
93
95
|
9: list<list<i16>> lists,
|
|
94
96
|
10: list<set<i16>> sets,
|
|
95
|
-
11: list<Hello> hellos
|
|
97
|
+
11: list<Hello> hellos,
|
|
98
|
+
12: list<uuid> uuids
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
exception Xception {
|
|
@@ -119,6 +122,7 @@ union My_union {
|
|
|
119
122
|
8: i32 other_i32
|
|
120
123
|
9: SomeEnum some_enum;
|
|
121
124
|
10: map<SomeEnum, list<SomeEnum>> my_map;
|
|
125
|
+
11: uuid unique_id;
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
struct Struct_with_union {
|
|
@@ -181,3 +185,19 @@ struct NestedMapInMapKey {
|
|
|
181
185
|
struct NestedMapInMapValue {
|
|
182
186
|
2: map<byte, map<byte, byte>> value
|
|
183
187
|
}
|
|
188
|
+
|
|
189
|
+
# Recursive types for the struct/union/exception recursion-depth limit specs (THRIFT-6045).
|
|
190
|
+
struct RecTree {
|
|
191
|
+
1: list<RecTree> children
|
|
192
|
+
2: i16 item
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
union RecUnion {
|
|
196
|
+
1: list<RecUnion> children
|
|
197
|
+
2: i32 leaf
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
exception RecError {
|
|
201
|
+
1: list<RecError> children
|
|
202
|
+
2: i32 leaf
|
|
203
|
+
}
|
data/spec/base_protocol_spec.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
#
|
|
2
3
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
4
|
# or more contributor license agreements. See the NOTICE file
|
|
@@ -20,7 +21,6 @@
|
|
|
20
21
|
require 'spec_helper'
|
|
21
22
|
|
|
22
23
|
describe 'BaseProtocol' do
|
|
23
|
-
|
|
24
24
|
before(:each) do
|
|
25
25
|
@trans = double("MockTransport")
|
|
26
26
|
@prot = Thrift::BaseProtocol.new(@trans)
|
|
@@ -210,12 +210,31 @@ describe 'BaseProtocol' do
|
|
|
210
210
|
expect(@prot).to receive(:read_list_end)
|
|
211
211
|
real_skip.call(Thrift::Types::LIST)
|
|
212
212
|
end
|
|
213
|
+
|
|
214
|
+
it "should raise DEPTH_LIMIT when max_depth is exhausted" do
|
|
215
|
+
expect { @prot.skip(Thrift::Types::STRUCT, 0) }.to raise_error(Thrift::ProtocolException) do |e|
|
|
216
|
+
expect(e.type).to eq(Thrift::ProtocolException::DEPTH_LIMIT)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
it "should skip at max_depth=1 without raising" do
|
|
221
|
+
expect(@prot).to receive(:read_bool).once
|
|
222
|
+
expect { @prot.skip(Thrift::Types::BOOL, 1) }.not_to raise_error
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it "should reject negative container sizes while skipping" do
|
|
226
|
+
expect(@prot).to receive(:read_list_begin).and_return([Thrift::Types::I32, -1])
|
|
227
|
+
|
|
228
|
+
expect { @prot.skip(Thrift::Types::LIST) }.to raise_error(Thrift::ProtocolException, "Negative size") do |e|
|
|
229
|
+
expect(e.type).to eq(Thrift::ProtocolException::NEGATIVE_SIZE)
|
|
230
|
+
end
|
|
231
|
+
end
|
|
213
232
|
end
|
|
214
233
|
|
|
215
234
|
describe Thrift::BaseProtocolFactory do
|
|
216
235
|
it "should raise NotImplementedError" do
|
|
217
236
|
# returning nil since Protocol is just an abstract class
|
|
218
|
-
expect {Thrift::BaseProtocolFactory.new.get_protocol(double("MockTransport"))}.to raise_error(NotImplementedError)
|
|
237
|
+
expect { Thrift::BaseProtocolFactory.new.get_protocol(double("MockTransport")) }.to raise_error(NotImplementedError)
|
|
219
238
|
end
|
|
220
239
|
|
|
221
240
|
it "should provide a reasonable to_s" do
|
data/spec/base_transport_spec.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
#
|
|
2
3
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
4
|
# or more contributor license agreements. See the NOTICE file
|
|
@@ -20,7 +21,6 @@
|
|
|
20
21
|
require 'spec_helper'
|
|
21
22
|
|
|
22
23
|
describe 'BaseTransport' do
|
|
23
|
-
|
|
24
24
|
describe Thrift::TransportException do
|
|
25
25
|
it "should make type accessible" do
|
|
26
26
|
exc = Thrift::TransportException.new(Thrift::TransportException::ALREADY_OPEN, "msg")
|
|
@@ -38,6 +38,25 @@ describe 'BaseTransport' do
|
|
|
38
38
|
expect(transport.read_all(40)).to eq("10 lettersfifteen lettersmore characters")
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
it "should coerce reads to binary encoding" do
|
|
42
|
+
transport = Thrift::BaseTransport.new
|
|
43
|
+
expect(transport).to receive(:read).with(3).and_return(+'abc')
|
|
44
|
+
|
|
45
|
+
buf = transport.read_all(3)
|
|
46
|
+
|
|
47
|
+
expect(buf).to eq('abc')
|
|
48
|
+
expect(buf.encoding).to eq(Encoding::BINARY)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should reject negative read sizes" do
|
|
52
|
+
transport = Thrift::BaseTransport.new
|
|
53
|
+
expect(transport).not_to receive(:read)
|
|
54
|
+
|
|
55
|
+
expect { transport.read_all(-1) }.to raise_error(Thrift::TransportException, "Negative size") do |e|
|
|
56
|
+
expect(e.type).to eq(Thrift::TransportException::NEGATIVE_SIZE)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
41
60
|
it "should stub out the rest of the methods" do
|
|
42
61
|
# can't test for stubbiness, so just make sure they're defined
|
|
43
62
|
[:open?, :open, :close, :read, :write, :flush].each do |sym|
|
|
@@ -48,7 +67,7 @@ describe 'BaseTransport' do
|
|
|
48
67
|
it "should alias << to write" do
|
|
49
68
|
expect(Thrift::BaseTransport.instance_method(:<<)).to eq(Thrift::BaseTransport.instance_method(:write))
|
|
50
69
|
end
|
|
51
|
-
|
|
70
|
+
|
|
52
71
|
it "should provide a reasonable to_s" do
|
|
53
72
|
expect(Thrift::BaseTransport.new.to_s).to eq("base")
|
|
54
73
|
end
|
|
@@ -67,7 +86,7 @@ describe 'BaseTransport' do
|
|
|
67
86
|
transport = double("Transport")
|
|
68
87
|
expect(Thrift::BaseTransportFactory.new.get_transport(transport)).to eql(transport)
|
|
69
88
|
end
|
|
70
|
-
|
|
89
|
+
|
|
71
90
|
it "should provide a reasonable to_s" do
|
|
72
91
|
expect(Thrift::BaseTransportFactory.new.to_s).to eq("base")
|
|
73
92
|
end
|
|
@@ -149,7 +168,7 @@ describe 'BaseTransport' do
|
|
|
149
168
|
expect(Thrift::BufferedTransport).to receive(:new).with(trans).and_return(btrans)
|
|
150
169
|
expect(Thrift::BufferedTransportFactory.new.get_transport(trans)).to eq(btrans)
|
|
151
170
|
end
|
|
152
|
-
|
|
171
|
+
|
|
153
172
|
it "should provide a reasonable to_s" do
|
|
154
173
|
expect(Thrift::BufferedTransportFactory.new.to_s).to eq("buffered")
|
|
155
174
|
end
|
|
@@ -271,7 +290,7 @@ describe 'BaseTransport' do
|
|
|
271
290
|
expect(Thrift::FramedTransport).to receive(:new).with(trans)
|
|
272
291
|
Thrift::FramedTransportFactory.new.get_transport(trans)
|
|
273
292
|
end
|
|
274
|
-
|
|
293
|
+
|
|
275
294
|
it "should provide a reasonable to_s" do
|
|
276
295
|
expect(Thrift::FramedTransportFactory.new.to_s).to eq("framed")
|
|
277
296
|
end
|
|
@@ -287,7 +306,7 @@ describe 'BaseTransport' do
|
|
|
287
306
|
end
|
|
288
307
|
|
|
289
308
|
it "should accept a buffer on input and use it directly" do
|
|
290
|
-
s = "this is a test"
|
|
309
|
+
s = +"this is a test"
|
|
291
310
|
@buffer = Thrift::MemoryBufferTransport.new(s)
|
|
292
311
|
expect(@buffer.read(4)).to eq("this")
|
|
293
312
|
s.slice!(-4..-1)
|
|
@@ -339,12 +358,33 @@ describe 'BaseTransport' do
|
|
|
339
358
|
expect(@buffer.read(@buffer.available)).to eq("foo bar")
|
|
340
359
|
end
|
|
341
360
|
|
|
361
|
+
it "should force mutable write buffers into binary in place" do
|
|
362
|
+
s = "abc \u20AC".encode("UTF-8")
|
|
363
|
+
@buffer.write(s)
|
|
364
|
+
expect(s.encoding).to eq(Encoding::BINARY)
|
|
365
|
+
expect(@buffer.read(@buffer.available)).to eq("abc \u20AC".encode("UTF-8").b)
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
it "should not mutate frozen write buffers while forcing binary encoding" do
|
|
369
|
+
s = "abc \u20AC".encode("UTF-8").freeze
|
|
370
|
+
@buffer.write(s)
|
|
371
|
+
expect(s.encoding).to eq(Encoding::UTF_8)
|
|
372
|
+
expect(s).to be_frozen
|
|
373
|
+
expect(@buffer.read(@buffer.available)).to eq("abc \u20AC".encode("UTF-8").b)
|
|
374
|
+
end
|
|
375
|
+
|
|
342
376
|
it "should throw an EOFError when there isn't enough data in the buffer" do
|
|
343
377
|
@buffer.reset_buffer("")
|
|
344
|
-
expect{@buffer.read(1)}.to raise_error(EOFError)
|
|
378
|
+
expect{ @buffer.read(1) }.to raise_error(EOFError)
|
|
345
379
|
|
|
346
380
|
@buffer.reset_buffer("1234")
|
|
347
|
-
expect{@buffer.read(5)}.to raise_error(EOFError)
|
|
381
|
+
expect{ @buffer.read(5) }.to raise_error(EOFError)
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
it "should reject negative read_all sizes" do
|
|
385
|
+
expect { @buffer.read_all(-1) }.to raise_error(Thrift::TransportException, "Negative size") do |e|
|
|
386
|
+
expect(e.type).to eq(Thrift::TransportException::NEGATIVE_SIZE)
|
|
387
|
+
end
|
|
348
388
|
end
|
|
349
389
|
end
|
|
350
390
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
#
|
|
2
3
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
4
|
# or more contributor license agreements. See the NOTICE file
|
|
@@ -21,7 +22,6 @@ require 'spec_helper'
|
|
|
21
22
|
require File.expand_path("#{File.dirname(__FILE__)}/binary_protocol_spec_shared")
|
|
22
23
|
|
|
23
24
|
describe 'BinaryProtocol' do
|
|
24
|
-
|
|
25
25
|
it_should_behave_like 'a binary protocol'
|
|
26
26
|
|
|
27
27
|
def protocol_class
|
|
@@ -29,7 +29,6 @@ describe 'BinaryProtocol' do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
describe Thrift::BinaryProtocol do
|
|
32
|
-
|
|
33
32
|
before(:each) do
|
|
34
33
|
@trans = Thrift::MemoryBufferTransport.new
|
|
35
34
|
@prot = protocol_class.new(@trans)
|