fix encoding issue on windows+jruby

Fixes #2507
This commit is contained in:
Joao Duarte 2015-02-04 11:14:10 +00:00 committed by Jordan Sissel
parent 6d56067f73
commit c4a6f41ca6
2 changed files with 5 additions and 0 deletions

View file

@ -117,6 +117,10 @@ module LogStash
@jruby ||= !!(RUBY_PLATFORM == "java") @jruby ||= !!(RUBY_PLATFORM == "java")
end end
def windows?
Gem.win_platform?
end
def vendor_path(path) def vendor_path(path)
return ::File.join(LOGSTASH_HOME, "vendor", path) return ::File.join(LOGSTASH_HOME, "vendor", path)
end end

View file

@ -296,6 +296,7 @@ class LogStash::Event
def self.validate_value(value) def self.validate_value(value)
case value case value
when String when String
value.force_encoding("UTF-8") if LogStash::Environment.windows?
raise("expected UTF-8 encoding for value=#{value}, encoding=#{value.encoding.inspect}") unless value.encoding == Encoding::UTF_8 raise("expected UTF-8 encoding for value=#{value}, encoding=#{value.encoding.inspect}") unless value.encoding == Encoding::UTF_8
raise("invalid UTF-8 encoding for value=#{value}, encoding=#{value.encoding.inspect}") unless value.valid_encoding? raise("invalid UTF-8 encoding for value=#{value}, encoding=#{value.encoding.inspect}") unless value.valid_encoding?
value value