- fix LOGSTASH-1015 (problem was 'require openssl.rb' wanted to load

"../../1.9/openssl.rb" relative to __FILE__

when in the jar, __FILE__ is file:/some/logstash.jar!/openssl.rb
So 'expand_path' was incorrectly going outside the jar when it should
stay rooted in it.
This commit is contained in:
Jordan Sissel 2013-04-21 22:47:36 -07:00
parent 25c6d79cdd
commit 56a9331c61

View file

@ -32,6 +32,7 @@ class File
def expand_path(path, dir=nil)
if path =~ /(jar:)?file:\/.*\.jar!/
p :expand_path_path => [path, dir]
jar, resource = path.split("!", 2)
#p :expand_path => [jar, resource]
if resource.nil? || resource == ""
@ -40,6 +41,13 @@ class File
else
return "#{jar}!#{expand_path_JRUBY_6970(resource, dir)}"
end
elsif dir =~ /(jar:)?file:\/.*\.jar!/
jar, dir = dir.split("!", 2)
if dir.empty?
# sometimes the original dir is just 'file:/foo.jar!'
return File.join("#{jar}!", path)
end
return "#{jar}!#{expand_path_JRUBY_6970(path, dir)}"
else
return expand_path_JRUBY_6970(path, dir)
end