From 21dfae16523bba8f04f3cb9f703e67e971287339 Mon Sep 17 00:00:00 2001 From: Joao Duarte Date: Fri, 27 Nov 2015 10:48:19 +0000 Subject: [PATCH] fix shutdown controller when using no filters --- logstash-core/lib/logstash/pipeline.rb | 3 ++- logstash-core/spec/logstash/pipeline_spec.rb | 23 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/logstash-core/lib/logstash/pipeline.rb b/logstash-core/lib/logstash/pipeline.rb index ed943f3180c..1a74d15456e 100644 --- a/logstash-core/lib/logstash/pipeline.rb +++ b/logstash-core/lib/logstash/pipeline.rb @@ -53,6 +53,7 @@ def initialize(configstr) # @ready requires thread safety since it is typically polled from outside the pipeline thread @ready = Concurrent::AtomicBoolean.new(false) @input_threads = [] + @filter_threads = [] end # def initialize def ready? @@ -136,7 +137,7 @@ def shutdown_filters end def wait_filters - @filter_threads.each(&:join) if @filter_threads + @filter_threads.each(&:join) end def shutdown_outputs diff --git a/logstash-core/spec/logstash/pipeline_spec.rb b/logstash-core/spec/logstash/pipeline_spec.rb index 15b32cb266b..35f7acf0592 100644 --- a/logstash-core/spec/logstash/pipeline_spec.rb +++ b/logstash-core/spec/logstash/pipeline_spec.rb @@ -299,4 +299,27 @@ class TestPipeline < LogStash::Pipeline end end end + + describe "stalling_threads" do + before(:each) do + allow(LogStash::Plugin).to receive(:lookup).with("input", "dummyinput").and_return(DummyInput) + allow(LogStash::Plugin).to receive(:lookup).with("codec", "plain").and_return(DummyCodec) + allow(LogStash::Plugin).to receive(:lookup).with("output", "dummyoutput").and_return(DummyOutput) + end + + context "when the pipeline doesn't have filters" do + let(:pipeline_with_no_filters) do + <<-eos + input { dummyinput {} } + output { dummyoutput {} } + eos + end + + it "doesn't raise an error" do + pipeline = TestPipeline.new(pipeline_with_no_filters) + pipeline.run + expect { pipeline.stalling_threads }.to_not raise_error + end + end + end end