Skip to content

Commit c8f3a5e

Browse files
committed
Add empty event array check to multi_receive
Adds a check to return if #multi_receive is called with an empty array. If this happens, the plugin will hang indefinitely on a #pop call that will never return. Fixes logstash-plugins#80 Fixes logstash-plugins#81
1 parent 54eb781 commit c8f3a5e

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 5.1.2
2+
- Add check to avoid hanging pipeline if an empty event array is passed in. #80
3+
14
## 5.1.1
25
- Update gemspec summary
36

lib/logstash/outputs/http.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def register
113113
end # def register
114114

115115
def multi_receive(events)
116-
send_events(events)
116+
send_events(events) unless events.empty?
117117
end
118118

119119
class RetryTimerTask < java.util.TimerTask
@@ -136,7 +136,7 @@ def send_events(events)
136136

137137
pending = Queue.new
138138
events.each {|e| pending << [e, 0]}
139-
139+
140140
while popped = pending.pop
141141
break if popped == :done
142142

logstash-output-http.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-output-http'
3-
s.version = '5.1.1'
3+
s.version = '5.1.2'
44
s.licenses = ['Apache License (2.0)']
55
s.summary = "Sends events to a generic HTTP or HTTPS endpoint"
66
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"

spec/outputs/http_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ def sinatra_run_wait(app, opts)
128128
allow(subject).to receive(:log_failure).with(any_args)
129129
end
130130

131+
context 'sending no events' do
132+
it 'should not block the pipeline' do
133+
subject.multi_receive([])
134+
end
135+
end
136+
131137
context "performing a get" do
132138
describe "invoking the request" do
133139
before do

0 commit comments

Comments
 (0)