Skip to content

Commit

Permalink
GH-44337: [CI][GLib] Fix a flaky StreamDecoder and Buffer test
Browse files Browse the repository at this point in the history
It's related to GC.

StreamDecoder accepts incomplete data. They are kept until enough data
are provided. A caller must not release the incomplete data before
they are processed. If they are released, StreamDecoder may touch
unexpected data.
  • Loading branch information
kou committed Oct 8, 2024
1 parent c50c4fa commit 29edcd1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion c_glib/test/test-stream-decoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@ def test_consume_bytes
end

def test_consume_buffer
# We need to keep data that aren't processed yet.
data = []
@buffer.data.to_s.each_byte do |byte|
@decoder.consume_buffer(Arrow::Buffer.new(byte.chr))
data << byte.chr
can_clear = (@decoder.next_required_size == 1)
@decoder.consume_buffer(Arrow::Buffer.new(data.last))
# We can release a reference for kept data after they are
# processed.
data.clear if can_clear
end
assert_equal([
[:schema_decoded, @schema, @schema],
Expand Down

0 comments on commit 29edcd1

Please sign in to comment.