summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-09-05 15:53:11 +0000
committerSamuel Giddins <segiddins@segiddins.me>2017-09-06 21:35:31 -0500
commit8a46399f830d8142986580d5a152d010c4d04612 (patch)
treefc5bd6c97c4ba78b8184641edda6bfc3fdb401a6
parent5ffc8b010cc704d0ca8d385d1f6aec38a413d3ab (diff)
downloadbundler-8a46399f830d8142986580d5a152d010c4d04612.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... (cherry picked from commit f81b8ddaefa0528105c9e2dcb33e045b20588f42)
-rw-r--r--lib/bundler/vendored_persistent.rb1
-rw-r--r--spec/bundler/vendored_persistent_spec.rb6
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"