verify Rubygems versions before monkeypatching

Fixes #2684
This commit is contained in:
Colin Surprenant 2015-02-24 18:45:21 -05:00 committed by Jordan Sissel
parent 5e9644b7a5
commit d805cc76aa

View file

@ -11,27 +11,31 @@ require 'logstash/version'
# see https://github.com/elasticsearch/logstash/issues/2556 and https://github.com/rubygems/rubygems/issues/1070 # see https://github.com/elasticsearch/logstash/issues/2556 and https://github.com/rubygems/rubygems/issues/1070
# #
# this code is from Rubygems v2.1.9 in JRuby 1.7.17. Per tickets this issue should be solved at JRuby >= 1.7.20. # this code is from Rubygems v2.1.9 in JRuby 1.7.17. Per tickets this issue should be solved at JRuby >= 1.7.20.
class Gem::Specification
def self.reset # this method implementation works for Rubygems version 2.1.0 and up, verified up to 2.4.6
@@dirs = nil if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.1.0") && Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.5.0")
Gem.pre_reset_hooks.each { |hook| hook.call } class Gem::Specification
@@all = nil def self.reset
@@stubs = nil @@dirs = nil
_clear_load_cache Gem.pre_reset_hooks.each { |hook| hook.call }
unresolved = unresolved_deps @@all = nil
unless unresolved.empty? @@stubs = nil
unless (unresolved.size == 1 && unresolved["ffi"]) _clear_load_cache
w = "W" + "ARN" unresolved = unresolved_deps
warn "#{w}: Unresolved specs during Gem::Specification.reset:" unless unresolved.empty?
unresolved.values.each do |dep| unless (unresolved.size == 1 && unresolved["ffi"])
warn " #{dep}" w = "W" + "ARN"
warn "#{w}: Unresolved specs during Gem::Specification.reset:"
unresolved.values.each do |dep|
warn " #{dep}"
end
warn "#{w}: Clearing out unresolved specs."
warn "Please report a bug if this causes problems."
end end
warn "#{w}: Clearing out unresolved specs." unresolved.clear
warn "Please report a bug if this causes problems."
end end
unresolved.clear Gem.post_reset_hooks.each { |hook| hook.call }
end end
Gem.post_reset_hooks.each { |hook| hook.call }
end end
end end