Fixes LOGSTASH-1328

I've tried more or less everything, but this consistently fixes [LOGSTASH-1328](https://logstash.jira.com/browse/LOGSTASH-1328)