From: Egbert Eich Date: 2010-10-17T22:11:55+09:00 Subject: [ruby-core:32829] [Ruby 1.8-Bug#3955][Open] Undefined method in net/http.rb Error on Exception --mimepart_4cbaf60c3e34d_eedc2a1b86229fd Content-Type: text/plain Content-Transfer-Encoding: Quoted-printable Content-Disposition: inline Bug #3955: Undefined method in net/http.rb Error on Exception http://redmine.ruby-lang.org/issues/show/3955 Author: Egbert Eich Status: Open, Priority: Normal Category: lib ruby -v: ruby 1.8.7 (2010-01-10 patchlevel 249) If request() (net/http.rb) gets an exception (for instance an EOF error i= n start()) I get an error: /usr/lib64/ruby/1.8/net/http.rb:1067:in `request': undefined method `clos= ed?' for nil:NilClass (NoMethodError) Reason: request() calls itself recursively in the block to 'start'. On an= exception the rescue block of the inner call to request() is executed wh= ich raises the exception again then in the ensure block of start() @socke= d is nil-ed. However since the exception has been raised again the except= ion block of the outer request() call gets called after that. Since @sock= et has already been nil-ed the above error occurs. The fix is simple, see attached file. I suspect the bug still exists in 1.9 (as presently in HEAD in github). T= he code in question has been moved to transport_request() now but the exe= cution sequence remains largely unchanged. ---------------------------------------- http://redmine.ruby-lang.org --mimepart_4cbaf60c3e34d_eedc2a1b86229fd Content-Type: application/x-ruby; name=diff.http.rb Content-Transfer-Encoding: Base64 Content-Disposition: attachment; filename=diff.http.rb LS0tIGh0dHAucmIuYmFrCTIwMTAtMDctMDUgMTY6NTA6MjguMDAwMDAwMDAw ICswMjAwCisrKyBodHRwLnJiCTIwMTAtMTAtMTcgMTU6MDE6MjMuMDAwMDAw MDAwICswMjAwCkBAIC0xMDU3LDcgKzEwNTcsNyBAQAogICAgICAgcmVzCiAg ICAgcmVzY3VlID0+IGV4Y2VwdGlvbgogICAgICAgRCAiQ29ubiBjbG9zZSBi ZWNhdXNlIG9mIGVycm9yICN7ZXhjZXB0aW9ufSIKLSAgICAgIEBzb2NrZXQu Y2xvc2UgdW5sZXNzIEBzb2NrZXQuY2xvc2VkPworICAgICAgQHNvY2tldC5j bG9zZSB1bmxlc3MgKEBzb2NrZXQubmlsPyB8fCAgQHNvY2tldC5jbG9zZWQ/ KQogICAgICAgcmFpc2UgZXhjZXB0aW9uCiAgICAgZW5kCiAK --mimepart_4cbaf60c3e34d_eedc2a1b86229fd--