Skip to content

Commit 2b047e1

Browse files
hsbtclaude
andcommitted
Consume remaining gzip data in open_tar_gz to suppress zlib warning
When a GzipReader is closed before all compressed data is consumed, zlib emits "attempt to close unfinished zstream; reset forced" warning. This happens in open_tar_gz because the TarReader stops reading at the end-of-archive marker, leaving unconsumed compressed data in the stream. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e1c0959 commit 2b047e1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/rubygems/package.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,15 @@ def open_tar_gz(io) # :nodoc:
556556
tar = Gem::Package::TarReader.new gzio
557557

558558
yield tar
559+
ensure
560+
# Consume remaining gzip data to prevent the
561+
# "attempt to close unfinished zstream; reset forced" warning
562+
# when the GzipReader is closed with unconsumed compressed data.
563+
begin
564+
gzio.read
565+
rescue Zlib::GzipFile::Error, IOError
566+
nil
567+
end
559568
end
560569
end
561570

0 commit comments

Comments
 (0)