After some experimenting with a local cluster, I think I figured out the behavior.
I started a local cluster of 5 nodes, and then took down 2 of the nodes. The remaining 3 nodes still formed a majority, so the cluster was up and running. I connected a client at this point.
Then I took down another server, at which point the remaining 2 nodes cannot maintain the cluster up and running.
1) In the log of one of the two remaining nodes (which happened to be the leader), I could see:
[myid:5] - WARN
[RecvWorker:3:QuorumCnxManager$RecvWorker@762] - Connection broken for
id 3, my id = 5, error = java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:392)
at org.apache.zookeeper.server.quorum.QuorumCnxManager$RecvWorker.run(QuorumCnxManager.java:747)
and later
[myid:5] - INFO
[QuorumPeer[myid=5]/127.0.0.1:2185:FastLeaderElection@740] - New
election. My id = 5, proposed zxid=0x300000002
So it seems that the nodes are actively monitoring connectivity and react to dropped connections (in this case try to elect another leader).
2) In the logs of the connected client, I could see:
[myid:] - INFO
[main-SendThread(localhost:2185):ClientCnxn$SendThread@966] - Opening
socket connection to server localhost/127.0.0.1:2185. Will not attempt
to authenticate using SASL (unknown error)
[myid:] - INFO
[main-SendThread(localhost:2185):ClientCnxn$SendThread@849] - Socket
connection established to localhost/127.0.0.1:2185, initiating
session
[myid:] - INFO
[main-SendThread(localhost:2185):ClientCnxn$SendThread@1085] - Unable
to read additional data from server sessionid 0x343d9a80f220000,
likely server has closed socket, closing socket connection and
attempting reconnect
So the node closes the connection opened by the client, due to the fact that the cluster is down.
In this case the entire cluster was down so the client keeps on trying to connect to one of the nodes, without luck. But I assume that in the case of a split-brain scenario, when the majority is still up and running somewhere, the client will eventually be able to connect to it (given that it has network connectivity, of course).