diff options
author | The Bundler Bot <bot@bundler.io> | 2017-09-05 15:53:11 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-09-05 15:53:11 +0000 |
commit | f81b8ddaefa0528105c9e2dcb33e045b20588f42 (patch) | |
tree | fc5bd6c97c4ba78b8184641edda6bfc3fdb401a6 | |
parent | d5592453ba6c60809fe827d329f430b9eab4634a (diff) | |
parent | dda270ec5b0aa6d55e02efe5e305110df95eca06 (diff) | |
download | bundler-f81b8ddaefa0528105c9e2dcb33e045b20588f42.tar.gz |
Auto merge of #6003 - greysteil:handle-missing-socket, r=segiddins
Handle missing socket when warning about OpenSSL version
### What was the end-user problem that led to this PR?
Stubbing Rubygems requests with WebMock was causing `undefined method 'io' for nil:NilClass` errors when using Bundler 1.16.0.pre.1
### What was your diagnosis of the problem?
My diagnosis was that the new warning text about old OpenSSL versions didn't consider the case that a connection might not have an `@socket` variable set.
### What is your fix for the problem, implemented in this PR?
Guard against this by returning early in that case.
### Why did you choose this fix out of the possible options?
I chose this fix because it works, and because `Net::HTTP` itself has some guards in it around `nil` values for `@socket` ([example](https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L858-L860)). This isn't my area, though, so it could be that a fix is needed in WebMock, not here...
-rw-r--r-- | lib/bundler/vendored_persistent.rb | 1 | ||||
-rw-r--r-- | spec/bundler/vendored_persistent_spec.rb | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/bundler/vendored_persistent.rb b/lib/bundler/vendored_persistent.rb index 190fed58e5..de9c42fcc1 100644 --- a/lib/bundler/vendored_persistent.rb +++ b/lib/bundler/vendored_persistent.rb @@ -30,6 +30,7 @@ module Bundler return unless (uri.host || "").end_with?("rubygems.org") socket = connection.instance_variable_get(:@socket) + return unless socket socket_io = socket.io return unless socket_io.respond_to?(:ssl_version) ssl_version = socket_io.ssl_version diff --git a/spec/bundler/vendored_persistent_spec.rb b/spec/bundler/vendored_persistent_spec.rb index b1b091f2c5..338431c4a6 100644 --- a/spec/bundler/vendored_persistent_spec.rb +++ b/spec/bundler/vendored_persistent_spec.rb @@ -45,6 +45,12 @@ RSpec.describe Bundler::PersistentHTTP do include_examples "does not warn" end + context "without a socket" do + let(:socket) { nil } + + include_examples "does not warn" + end + context "with a different TLD" do let(:uri) { "https://foo.bar" } include_examples "does not warn" |