diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-12 02:19:17 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-12 02:19:17 +0000 |
commit | 70777b3fa87d6c0aefb0f072b68e7b792a9e63f3 (patch) | |
tree | 6ed3b721abc358f6c14274dc288c25aeba31ac35 /test/net/smtp/test_smtp.rb | |
parent | 58c654a06eb9f77c91486adc208c5e738bc4a934 (diff) | |
download | ruby-70777b3fa87d6c0aefb0f072b68e7b792a9e63f3.tar.gz |
lib/net/protocol.rb: preserve backtrace information
BufferedIO#rbuf_fill should preserve backtrace information when raising
EOFError. Otherwise, users get confused when EOFError is leaked out from
Net::SMTP etc. [ruby-core:78550] [Bug #13018]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/smtp/test_smtp.rb')
-rw-r--r-- | test/net/smtp/test_smtp.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/net/smtp/test_smtp.rb b/test/net/smtp/test_smtp.rb index 01b8ae504c..89a08cb17b 100644 --- a/test/net/smtp/test_smtp.rb +++ b/test/net/smtp/test_smtp.rb @@ -157,6 +157,28 @@ module Net end end + def test_eof_error_backtrace + bug13018 = '[ruby-core:78550] [Bug #13018]' + servers = Socket.tcp_server_sockets("localhost", 0) + begin + sock = nil + Thread.start do + sock = accept(servers) + sock.close + end + smtp = Net::SMTP.new("localhost", servers[0].local_address.ip_port) + e = assert_raise(EOFError, bug13018) do + smtp.start do + end + end + assert_equal(EOFError, e.class, bug13018) + assert(e.backtrace.grep(%r"\bnet/smtp\.rb:").size > 0, bug13018) + ensure + sock.close if sock + servers.each(&:close) + end + end + private def accept(servers) |