null pointer exception in 19.8. same code path exists in master branch

This addresses a null pointer exception that can occur when restarting elasticsearch. See issue https://github.com/elasticsearch/elasticsearch/issues/2546