diff --git a/lib/logstash/JRUBY-6970.rb b/lib/logstash/JRUBY-6970.rb index 7188724865a..2d5ed383fa5 100644 --- a/lib/logstash/JRUBY-6970.rb +++ b/lib/logstash/JRUBY-6970.rb @@ -3,11 +3,20 @@ module Kernel alias_method :require_JRUBY_6970_hack, :require def require(path) + old_load_path = nil + if path =~ /^jar:file:.+!.+/ path = path.gsub(/^jar:/, "") puts "JRUBY-6970: require(#{path})" if ENV["REQUIRE_DEBUG"] == "1" end + # Work around slow openssl load times in flatjar. (LOGSTASH-1223) + if __FILE__ =~ /^(?:jar:)?file:.+!.+/ && path == "openssl" + old_load_path = $LOAD_PATH.dup + # For some reason loading openssl with an empty LOAD_PATH is fast. + $LOAD_PATH.clear + end + # JRUBY-7065 path = File.expand_path(path) if path.include?("/../") rc = require_JRUBY_6970_hack(path) @@ -17,6 +26,8 @@ def require(path) require "logstash/JRUBY-6970-openssl" end return rc + ensure + $LOAD_PATH.replace(old_load_path) if old_load_path end end