[ruby-core:32829] [Ruby 1.8-Bug#3955][Open] Undefined method in net/http.rb Error on Exception

From: Egbert Eich <redmine@...>
Date: 2010-10-17 13:11:55 UTC
List: ruby-core #32829
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 in start()) I get an error:
/usr/lib64/ruby/1.8/net/http.rb:1067:in `request': undefined method `closed?' 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 which raises the exception again then in the ensure block of start() @socked is nil-ed. However since the exception has been raised again the exception block of the outer request() call gets called after that. Since @socket 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). The code in question has been moved to transport_request() now but the execution sequence remains largely unchanged.


----------------------------------------
http://redmine.ruby-lang.org

Attachments (1)

diff.http.rb (351 Bytes, application/x-ruby)

In This Thread

Prev Next