@Test
public void testSenderFailsWhileStopping()
    throws InterruptedException, ExecutionException, IOException {

  final int numParties = 2;
  List<NetworkConfiguration> confs = getNetConfs(numParties);
  ExecutorService es = Executors.newFixedThreadPool(numParties);
  List<Future<NetworkConnector>> fs = new ArrayList<>(numParties);
  try {
    for (int i = 0; i < numParties; i++) {
      final int id = i;
      fs.add(es.submit(() -> new Connector(confs.get(id), DEFAULT_CONNECTION_TIMEOUT)));
    }
    Map<Integer, Socket> socketMap = fs.get(0).get().getSocketMap();
    Sender s = new Sender(socketMap.get(2));
    socketMap.get(2).close();
    s.stop();
  } finally {
    for (Future<NetworkConnector> futureConn : fs) {
      for (Socket s : futureConn.get().getSocketMap().values()) {
        s.close();
      }
    }
    es.shutdownNow();
  }
}