Fixes LOGSTASH-1374, possibly also LOGSTASH-1328.