diff --git a/lib/logstash/patches.rb b/lib/logstash/patches.rb index 8a3b3aa85..1515ddc32 100644 --- a/lib/logstash/patches.rb +++ b/lib/logstash/patches.rb @@ -3,3 +3,4 @@ require "logstash/patches/bugfix_jruby_2558" require "logstash/patches/cabin" require "logstash/patches/profile_require_calls" require "logstash/patches/stronger_openssl_defaults" +require "logstash/patches/silence_concurrent_ruby_warning" diff --git a/lib/logstash/patches/silence_concurrent_ruby_warning.rb b/lib/logstash/patches/silence_concurrent_ruby_warning.rb new file mode 100644 index 000000000..ca6d9c432 --- /dev/null +++ b/lib/logstash/patches/silence_concurrent_ruby_warning.rb @@ -0,0 +1,54 @@ +# encoding: utf-8 +require "logstash/namespace" +require "concurrent/concern/logging" +require "concurrent/concern/deprecation" +require "concurrent/version" +require "cabin" + +# Concurrent-ruby is throwing warning when the code is run under jdk7, and they +# will provide best effort support, logstash has to support JDK7 for a few months. +# +# By default all deprecation warnings of the concurrent ruby +# library use the `WARN` level which is show everytime we boot logstash, +# This monkeypatch change the log level of the deprecation warning to be `debug` +# instead. This monkey patch might be a bit over kill but there is no +# easy way to override the java version check. +# +# ref: https://github.com/ruby-concurrency/concurrent-ruby/blob/v0.9.1/lib/concurrent/configuration.rb#L284-L295 +# +# This patch is only valid for 0.9.1 +if Concurrent::VERSION == "0.9.1" + module Concurrent + module Concern + module Deprecation + include Concern::Logging + + def deprecated(message, strip = 2) + caller_line = caller(strip).first if strip > 0 + klass = if Module === self + self + else + self.class + end + message = if strip > 0 + format("[DEPRECATED] %s\ncalled on: %s", message, caller_line) + else + format('[DEPRECATED] %s', message) + end + + # lets use our logger + logger = Cabin::Channel.get(LogStash) + logger.debug(message, :class => klass.to_s) + end + + extend self + end + end + end +else + # This is added a guard to check if we need to update this code or not. + # Keep in mind, the latest releases of concurrent-ruby brokes a few stuff. + # + # Even the latest master version changed how they handle deprecation. + raise "Logstash expects concurrent-ruby version 0.9.1 and version #{Concurrent::VERSION} is installed, please verify this patch: #{__FILE__}" +end diff --git a/logstash-core.gemspec b/logstash-core.gemspec index 2df64952a..e383d835e 100644 --- a/logstash-core.gemspec +++ b/logstash-core.gemspec @@ -23,6 +23,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency "clamp", "~> 0.6.5" #(MIT license) for command line args/flags gem.add_runtime_dependency "filesize", "0.0.4" #(MIT license) for :bytes config validator gem.add_runtime_dependency "gems", "~> 0.8.3" #(MIT license) + gem.add_runtime_dependency "concurrent-ruby", "0.9.1" # TODO(sissel): Treetop 1.5.x doesn't seem to work well, but I haven't # investigated what the cause might be. -Jordan