# Race condition causes Exception when using json\_lines with UDP input

**URL:** <https://discuss.elastic.co/t/race-condition-causes-exception-when-using-json-lines-with-udp-input/84790>\
**Category:** Logstash\
**Created:** [May 5, 2017, 9:55pm UTC](https://discuss.elastic.co/t/race-condition-causes-exception-when-using-json-lines-with-udp-input/84790 "2017-05-05T21:55:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![qmando](https://avatars.discourse-cdn.com/v4/letter/q/b9e5f3/32.png) [@qmando](https://discuss.elastic.co/u/qmando)\
**Post date:** [May 5, 2017, 9:55pm UTC](https://discuss.elastic.co/t/race-condition-causes-exception-when-using-json-lines-with-udp-input/84790/1 "2017-05-05T21:55:41Z")

</div>

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

Logstash config:

```auto
input {
    udp {
        port => 13371
        codec => json_lines
    }
}

```

test script (python)

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

```

This consistently produces the following error:

```auto
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

```auto
output {
  stdout {
    codec => rubydebug
  }
}

```

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 2, 2017, 10:03pm UTC](https://discuss.elastic.co/t/race-condition-causes-exception-when-using-json-lines-with-udp-input/84790/2 "2017-06-02T22:03:05Z")

</div>

Closed on June 2, 2017, 10:03pm UTC

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