mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 5a79d8e0,160511d8: [Backport #16925]
Fix error raised by Net::HTTPResponse#inflater if the block raises * See https://bugs.ruby-lang.org/issues/13882#note-6 --- lib/net/http/response.rb | 5 ++- spec/ruby/library/net/http/http/get_spec.rb | 67 +++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) Quarantine specs which fail frequently with CHECK_LEAKS=true --- spec/ruby/library/net/http/http/get_spec.rb | 2 ++ 1 file changed, 2 insertions(+) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
efd499b211
commit
a175a30ab9
3 changed files with 73 additions and 3 deletions
|
@ -262,12 +262,13 @@ class Net::HTTPResponse
|
|||
|
||||
begin
|
||||
yield inflate_body_io
|
||||
success = true
|
||||
ensure
|
||||
orig_err = $!
|
||||
begin
|
||||
inflate_body_io.finish
|
||||
rescue => err
|
||||
raise orig_err || err
|
||||
# Ignore #finish's error if there is an exception from yield
|
||||
raise err if success
|
||||
end
|
||||
end
|
||||
when 'none', 'identity' then
|
||||
|
|
|
@ -24,3 +24,72 @@ describe "Net::HTTP.get when passed URI" do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
quarantine! do # These specs fail frequently with CHECK_LEAKS=true
|
||||
describe "Net::HTTP.get" do
|
||||
describe "when reading gzipped contents" do
|
||||
def start_threads
|
||||
require 'zlib'
|
||||
|
||||
server = nil
|
||||
server_thread = Thread.new do
|
||||
server = TCPServer.new("127.0.0.1", 0)
|
||||
begin
|
||||
c = server.accept
|
||||
ensure
|
||||
server.close
|
||||
end
|
||||
c.print "HTTP/1.1 200\r\n"
|
||||
c.print "Content-Type: text/plain\r\n"
|
||||
c.print "Content-Encoding: gzip\r\n"
|
||||
s = StringIO.new
|
||||
z = Zlib::GzipWriter.new(s)
|
||||
begin
|
||||
z.write 'Hello World!'
|
||||
ensure
|
||||
z.close
|
||||
end
|
||||
c.print "Content-Length: #{s.length}\r\n\r\n"
|
||||
# Write partial gzip content
|
||||
c.write s.string.byteslice(0..-2)
|
||||
c.flush
|
||||
c
|
||||
end
|
||||
Thread.pass until server && server_thread.stop?
|
||||
|
||||
client_thread = Thread.new do
|
||||
Thread.current.report_on_exception = false
|
||||
Net::HTTP.get("127.0.0.1", '/', server.connect_address.ip_port)
|
||||
end
|
||||
Thread.pass until client_thread.stop?
|
||||
|
||||
[server_thread, client_thread]
|
||||
end
|
||||
|
||||
it "propagates exceptions interrupting the thread and does not replace it with Zlib::BufError" do
|
||||
my_exception = Class.new(RuntimeError)
|
||||
server_thread, client_thread = start_threads
|
||||
socket = server_thread.value
|
||||
begin
|
||||
client_thread.raise my_exception, "my exception"
|
||||
-> { client_thread.value }.should raise_error(my_exception)
|
||||
ensure
|
||||
socket.close
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.8" do # https://bugs.ruby-lang.org/issues/13882#note-6
|
||||
it "lets the kill Thread exception goes through and does not replace it with Zlib::BufError" do
|
||||
server_thread, client_thread = start_threads
|
||||
socket = server_thread.value
|
||||
begin
|
||||
client_thread.kill
|
||||
client_thread.value.should == nil
|
||||
ensure
|
||||
socket.close
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.6.7"
|
||||
#define RUBY_RELEASE_DATE "2021-03-02"
|
||||
#define RUBY_PATCHLEVEL 168
|
||||
#define RUBY_PATCHLEVEL 169
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2021
|
||||
#define RUBY_RELEASE_MONTH 3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue