Skip to content
Browse files

Require net/https up front to resolve issue in jruby 1.6.8 when threa…

…ds concurrently require it
  • Loading branch information...
1 parent 322392c commit 08cc249a2ef3e270eac1b0583d72d90119c8ae8f @bpardee committed
Showing with 9 additions and 2 deletions.
  1. +5 −0 History.md
  2. +3 −1 lib/persistent_http.rb
  3. +1 −1 persistent_http.gemspec
View
5 History.md
@@ -1,6 +1,11 @@
PersistentHttp Changelog
========================
+1.0.5
+
+ - Don't require 'net/https' in code. JRuby 1.6.8 can have issues when 2 threads attempt to require it
+ at the same time.
+
1.0.4
- Added option :pool_timeout which will raise a Timeout::Error if unable to checkout a connection
View
4 lib/persistent_http.rb
@@ -1,4 +1,5 @@
require 'net/http'
+require 'net/https'
require 'persistent_http/faster'
require 'uri'
require 'gene_pool'
@@ -241,6 +242,7 @@ def initialize(options={})
:close_proc => nil,
:logger => @logger) do
begin
+ @logger.debug { "#{name}: Creating connection" } if @logger
connection = Net::HTTP.new(*net_http_args)
connection.set_debug_output @debug_output if @debug_output
connection.open_timeout = @open_timeout if @open_timeout
@@ -249,6 +251,7 @@ def initialize(options={})
ssl connection if @use_ssl
connection.start
+ @logger.debug { "#{name} #{connection}: Connection created" } if @logger
connection
rescue Errno::ECONNREFUSED
raise Error, "connection refused: #{connection.address}:#{connection.port}"
@@ -442,7 +445,6 @@ def renew connection
# Enables SSL on +connection+
def ssl connection
- require 'net/https'
connection.use_ssl = true
# suppress warning but allow override
View
2 persistent_http.gemspec
@@ -6,6 +6,6 @@ Gem::Specification.new do |s|
s.email = ['bradpardee@gmail.com']
s.homepage = 'http://github.com/bpardee/persistent_http'
s.files = Dir["{examples,lib}/**/*"] + %w(LICENSE Rakefile History.md README.rdoc)
- s.version = '1.0.4'
+ s.version = '1.0.5'
s.add_dependency 'gene_pool', '>= 1.3'
end

0 comments on commit 08cc249

Please sign in to comment.
Something went wrong with that request. Please try again.