Suggest to add setKeepAlive support for NIOServerCnxn. It can resolve some tcp connection leak issue caused by network broken. In some occasional case(network switcher broken, network card broken, iptables firewall strategy and so on....), zookeeper server would lose the FIN packet when the client close the connection. In such scenario, the connection will be treated as alive forever and never be closed.
These leaked tcp connections introduce the resource leak risk.
setKeepAlive for every client NIO connection can prevent the resource leak risk.
I will send the patch later. Hope someone can help to review it.