mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Fix jruby 1.7.x bug around define_singleton_method.
We were getting some bizzare errors (https://github.com/elastic/logstash/pull/4391#issuecomment-169477728) on the file output with the new OutputDelegator changes. By switching away from method(:mymethod) to blocks with define_singleton_method they went away. This bug is only present with Jruby 1.7.x (tested with 1.7.22 and 1.7.23). Jruby 9.x is fine. Fixes #4391
This commit is contained in:
parent
12d1de0bba
commit
54cd6306fc
1 changed files with 13 additions and 2 deletions
|
@ -45,11 +45,22 @@ module LogStash; class OutputDelegator
|
|||
|
||||
@events_received = Concurrent::AtomicFixnum.new(0)
|
||||
|
||||
|
||||
# One might wonder why we don't use something like
|
||||
# define_singleton_method(:multi_receive, method(:threadsafe_multi_receive)
|
||||
# and the answer is this is buggy on Jruby 1.7.x . It works 98% of the time!
|
||||
# The other 2% you get weird errors about rebinding to the same object
|
||||
# Until we switch to Jruby 9.x keep the define_singleton_method parts
|
||||
# the way they are, with a block
|
||||
if threadsafe?
|
||||
@threadsafe_worker = @workers.first
|
||||
self.define_singleton_method(:multi_receive, method(:threadsafe_multi_receive))
|
||||
define_singleton_method(:multi_receive) do |events|
|
||||
threadsafe_multi_receive(events)
|
||||
end
|
||||
else
|
||||
self.define_singleton_method(:multi_receive, method(:worker_multi_receive))
|
||||
define_singleton_method(:multi_receive) do |events|
|
||||
worker_multi_receive(events)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue