Skip to content

Commit

Permalink
GH-44337: [CI][GLib] Fix a flaky StreamDecoder and Buffer test (#44341)
Browse files Browse the repository at this point in the history
### Rationale for this change

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.

### What changes are included in this PR?

Refer unprocessed data until they are processed.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* GitHub Issue: #44337

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored Oct 9, 2024
1 parent c50c4fa commit 38c1286
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 38c1286

Please sign in to comment.