Module: Kernel

Defined in:
lib/logstash/JRUBY-6970.rb,
lib/logstash/monkeypatches-for-debugging.rb

Overview

Monkeypatch for JRUBY-6970

Instance Method Summary collapse

Instance Method Details

#load(path) ⇒ Object



42
43
44
45
# File 'lib/logstash/monkeypatches-for-debugging.rb', line 42

def load(path)
  puts "load(\"#{path}\")"
  return load_debug(path)
end

#load_debugObject



40
# File 'lib/logstash/monkeypatches-for-debugging.rb', line 40

alias_method :load_debug, :load

#require(path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/logstash/JRUBY-6970.rb', line 6

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)
  # I don't know why this works, I don't care either. This problem only
  # exists in the 'jar' builds of logstash which are going to be going away
  # soon in favor of the much-better tarball/zip releases!
  if __FILE__ =~ /^(?:jar:)?file:.+!.+/ && path == "openssl"
    # Loading shared/jruby-openssl first seems to make openssl load faster
    # I have no idea. Computers.
    require_JRUBY_6970_hack "shared/jruby-openssl"
    return require_JRUBY_6970_hack "openssl"
  end

  # JRUBY-7065
  path = File.expand_path(path) if path.include?("/../")
  rc = require_JRUBY_6970_hack(path)

  # Only monkeypatch openssl after it's been loaded.
  if path == "openssl"
    require "logstash/JRUBY-6970-openssl"
  end
  return rc
end

#require_debugObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/logstash/monkeypatches-for-debugging.rb', line 5

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)
  # I don't know why this works, I don't care either. This problem only
  # exists in the 'jar' builds of logstash which are going to be going away
  # soon in favor of the much-better tarball/zip releases!
  if __FILE__ =~ /^(?:jar:)?file:.+!.+/ && path == "openssl"
    # Loading shared/jruby-openssl first seems to make openssl load faster
    # I have no idea. Computers.
    require_JRUBY_6970_hack "shared/jruby-openssl"
    return require_JRUBY_6970_hack "openssl"
  end

  # JRUBY-7065
  path = File.expand_path(path) if path.include?("/../")
  rc = require_JRUBY_6970_hack(path)

  # Only monkeypatch openssl after it's been loaded.
  if path == "openssl"
    require "logstash/JRUBY-6970-openssl"
  end
  return rc
end

#require_JRUBY_6970_hackObject



4
# File 'lib/logstash/JRUBY-6970.rb', line 4

alias_method :require_JRUBY_6970_hack, :require