From 834fb6abc013b10bd9616eaebee78cde97686ea6 Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Fri, 4 Jan 2013 15:06:17 -0800 Subject: [PATCH] Add File.expand_path monkeypatch for JRUBY-6970 --- lib/logstash/JRUBY-6970.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/logstash/JRUBY-6970.rb b/lib/logstash/JRUBY-6970.rb index 47501d7a6..a1329ba6e 100644 --- a/lib/logstash/JRUBY-6970.rb +++ b/lib/logstash/JRUBY-6970.rb @@ -30,3 +30,25 @@ class OpenSSL::SSL::SSLContext return ca_path_JRUBY_6970=(arg) end end + +# Work around for a bug in File.expand_path that doesn't account for resources +# in jar paths. +# +# Should solve this error: +# Exception in thread "LogStash::Runner" org.jruby.exceptions.RaiseException: +# (Errno::ENOENT) file:/home/jls/projects/logstash/build/data/unicode.data +class File + class << self + alias_method :expand_path_JRUBY_6970, :expand_path + + def expand_path(path, dir=nil) + if path =~ /(jar:)?file:\/.*\.jar!/ + jar, resource = path.split("!", 2) + return "#{jar}!#{expand_path_JRUBY_6970(resource, dir)}" + else + return expand_path_JRUBY_6970(path, dir) + end + end + end +end +