drbrain / net-http-persistent

Thread-safe persistent connections with Net::HTTP
http://seattlerb.rubyforge.org/net-http-persistent
339 stars 117 forks source link

Issue with autoloading not working on some Rubies #70

Closed dreilly1982 closed 4 years ago

dreilly1982 commented 9 years ago

The autoload in https://github.com/drbrain/net-http-persistent/blob/master/lib/net/http/persistent.rb#L17 seems to fail on some Rubies. While I have not been able to find an root cause of WHY, I do have some examples. This can be seen in rubygems/rubygems-mirror#36 and bundler/bundler#3107. I have personally seen it on Ruby 2.2.2p95 with the following test:

irb(main):001:0> autoload :OpenSSL, 'openssl'
=> nil
irb(main):002:0> defined? OpenSSL::SSL
=> nil
irb(main):003:0> require 'openssl'
=> true
irb(main):004:0> defined? OpenSSL::SSL
=> "constant"

Where as on other machines (both different versions and 2.2.2p95) it works as intended:

:001 > autoload :OpenSSL, 'openssl'
 => nil 
 :002 > defined? OpenSSL::SSL
 => "constant" 

This is causing programs that rely on this Net::HTTP::Persistent to have to account for this behavior and forcibly load OpenSSL upfront, in much the same way as net/http/pipeline is loaded in https://github.com/drbrain/net-http-persistent/blob/master/lib/net/http/persistent.rb#L12-15

drbrain commented 4 years ago

I believe this has been addressed within ruby, if not a new bug should be filed there as the bug will occur with other users of net-http.