Exception change with net/http in Ruby 187 PL 248/9

Discussion in 'Ruby' started by Mitch Williams, Feb 18, 2010.

  1. Ran into the following problem with net http in Ruby 187 pl248

    require net/http.rb
    n =3D Net::HTTP.new('server-that-is-not-listening-on-port-eighty')
    n.request_head('/')

    Prior to this change:
    http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=3Drev&revision=3D25851 the
    above code results in an:

    Errno::ECONNREFUSED: Connection refused - connect(2)


    After the change I receive:

    NoMethodError: undefined method `closed?' for nil:NilClass


    From line 1060 of net/http.rb. It looks like the code was intended to clos=
    e
    sockets in the event of an error, but it assumes the socket actually exists=
    Mitch Williams, Feb 18, 2010
    #1
    1. Advertising

  2. Mitch Williams

    hemant Guest

    Hi,

    On Thu, Feb 18, 2010 at 6:19 AM, Mitch Williams <> wrot=
    e:
    > Ran into the following problem with net http in Ruby 187 pl248
    >
    > require net/http.rb
    > n =3D Net::HTTP.new('server-that-is-not-listening-on-port-eighty')
    > n.request_head('/')
    >
    > Prior to this change:
    > http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=3Drev&revision=3D25851 t=

    he
    > above code results in an:
    >
    > Errno::ECONNREFUSED: Connection refused - connect(2)
    >
    >
    > After the change I receive:
    >
    > NoMethodError: undefined method `closed?' for nil:NilClass
    >
    >
    > From line 1060 of net/http.rb. =A0It looks like the code was intended to =

    close
    > sockets in the event of an error, but it assumes the socket actually exis=

    ts.
    >
    > Can anyone else reproduce this issue?
    >


    Yes, I can reproduce.

    Indeed, this looks like unintentional change to me and somewhat
    unintuitive. I think, you should file a report on Redmine for this or
    raise it on ruby-core mailing list.
    hemant, Feb 18, 2010
    #2
    1. Advertising

  3. Thanks for taking the time to respond Hemant.

    I've added a redmine ticket for it here
    http://redmine.ruby-lang.org/issues/show/2758

    On Thu, Feb 18, 2010 at 6:20 AM, hemant <> wrote:

    > Hi,
    >
    > On Thu, Feb 18, 2010 at 6:19 AM, Mitch Williams <>
    > wrote:
    > > Ran into the following problem with net http in Ruby 187 pl248
    > >
    > > require net/http.rb
    > > n =3D Net::HTTP.new('server-that-is-not-listening-on-port-eighty')
    > > n.request_head('/')
    > >
    > > Prior to this change:
    > > http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=3Drev&revision=3D25851=

    the
    > > above code results in an:
    > >
    > > Errno::ECONNREFUSED: Connection refused - connect(2)
    > >
    > >
    > > After the change I receive:
    > >
    > > NoMethodError: undefined method `closed?' for nil:NilClass
    > >
    > >
    > > From line 1060 of net/http.rb. It looks like the code was intended to

    > close
    > > sockets in the event of an error, but it assumes the socket actually

    > exists.
    > >
    > > Can anyone else reproduce this issue?
    > >

    >
    > Yes, I can reproduce.
    >
    > Indeed, this looks like unintentional change to me and somewhat
    > unintuitive. I think, you should file a report on Redmine for this or
    > raise it on ruby-core mailing list.
    >
    >



    --=20
    + Mitch Williams
    + Software Engineer
    + Socialcast=AE

    + 19 South Park
    + San Francisco, CA 94107

    + e:

    + p: 651.964.8521
    + f: 801.348.4750

    This e-mail may be privileged and/or confidential, and the sender does not
    waive any related rights and obligations. Any distribution, use or copying
    of this e-mail or the information it contains by other than an intended
    recipient is unauthorized. If you are unsure why this e-mail was sent to
    you, please advise me (by return e-mail or otherwise) immediately.
    Mitch Williams, Feb 18, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew Moss
    Replies:
    9
    Views:
    136
    Robert Dober
    Dec 25, 2008
  2. Hr Ro
    Replies:
    0
    Views:
    99
    Hr Ro
    Aug 23, 2009
  3. Wayne Conrad
    Replies:
    1
    Views:
    92
    Wayne Conrad
    Jan 26, 2010
  4. Radhika
    Replies:
    0
    Views:
    238
    Radhika
    Sep 13, 2004
  5. Guest
    Replies:
    0
    Views:
    161
    Guest
    Nov 28, 2012
Loading...

Share This Page