The deadlock prevention approach used in
HBASE-14241 introduces unnecessary logic which is not intuitive.
Depending on the value for config hbase.ipc.client.specificThreadForWriting , there may or may not be CallSender threads running.
The attached patch simplifies deadlock prevention by using a Set which represents the Connections to be closed. Outside the synchronized (connections) block, this Set is iterated where the Connections are closed.