Fix from https://github.com/logstash/logstash/pull/924/files