Apply ZOOKEEPER-1891.

https://issues.apache.org/jira/secure/attachment/12634073/ZOOKEEPER-1891.patch