Race condition causes Exception when using json_lines with UDP input

I've discovered a race condition while using UDP input with json_lines codec. I tested using the latest logstash docker image.

Logstash config:

input {
    udp {
        port => 13371
        codec => json_lines

test script (python)

from socket import *
while True:
        a.sendto('{"foo": "bar"}\n', ('localhost', 13371))

This consistently produces the following error:

21:46:51.401 [<udp.0] ERROR logstash.inputs.udp - Exception in inputworker {"exception"=>#<TypeError: can't convert nil into String>, "backtrace"=>["org/jruby/RubyArray.java:1892:in `join'", "org/jruby/RubyArray.java:1898:in `join'", "/usr/share/logstash/logstash-core/lib/logstash/util/buftok.rb:87:in `extract'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-codec-json_lines-3.0.2/lib/logstash/codecs/json_lines.rb:40:in `decode'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-udp-3.1.0/lib/logstash/inputs/udp.rb:118:in `inputworker'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-udp-3.1.0/lib/logstash/inputs/udp.rb:89:in `udp_listener'"]}

If I add an output, the error never occurs

output {
  stdout {
    codec => rubydebug

If I add a sleep(.1) to the python script, it also does not throw the exception.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.