Skip to content

Commit

Permalink
Merge pull request elastic#617 from bernd/workaround-slow-openssl-load
Browse files Browse the repository at this point in the history
Add workaround for slow openssl loading (LOGSTASH-1223)
  • Loading branch information
jordansissel committed Sep 3, 2013
2 parents b454b7a + 98c55e7 commit b29fe92
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/logstash/JRUBY-6970.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit b29fe92

Please sign in to comment.