logstash-plugins / logstash-input-gelf

Apache License 2.0
20 stars 39 forks source link

Fix exception when parsing JSON messages evaluating to nil #44

Closed sandrinr closed 7 years ago

sandrinr commented 8 years ago

This change should also (or especially) be applied to the "2.0.x" release stream.

sandrinr commented 8 years ago

Guys, this is such a trivial change. Can you take it without me signing the CLA? You can just copy it. I don't care about the attribution ;-).

ph commented 7 years ago

I am just wondering when this situation can occur, have we done some investigation why we receive an empty document, I am not really familliar with gelf.

sandrinr commented 7 years ago

For me this happened when the sending process (in my case a PHP script) was abruptly terminated and because of this sent invalid or empty messages.

ph commented 7 years ago

@sandrinr It is still the case with one of the latest version of the plugin? Because https://github.com/logstash-plugins/logstash-input-gelf/pull/44/files#diff-307abaee619bf0d2453f131f219febd5R111 should prevent nil (or incomplete) data to be parsed.

And if we try to parse any invalid data the parser will just raise an exception that we catch.

sandrinr commented 7 years ago

This is a long time ago and I am having a hard time to remember. I think something in LogStash::Event.new(o) depended o not being nil, resulting in other errors than LogStash::Json::ParserError.

ph commented 7 years ago

Thanks for the quick response @sandrinr, I went through the code with the guard next if data.nil, It wont be an issue anymore I will close this PR.