public void run() { while (!Thread.currentThread().isInterrupted()) { try { if (conn == null) { try { conn = connectToOne(); } catch (Exception e) { LOGGER.severe("Error while connecting to cluster!", e); client.getLifecycleService().shutdown(); latch.countDown(); return; } } getInvocationService().triggerFailedListeners(); loadInitialMemberList(); listenMembershipEvents(); } catch (Exception e) { if (client.getLifecycleService().isRunning()) { if (LOGGER.isFinestEnabled()) { LOGGER.warning("Error while listening cluster events! -> " + conn, e); } else { LOGGER.warning( "Error while listening cluster events! -> " + conn + ", Error: " + e.toString()); } } connectionManager.markOwnerConnectionAsClosed(); IOUtil.closeResource(conn); conn = null; clusterService.fireConnectionEvent(true); } try { Thread.sleep(SLEEP_TIME); } catch (InterruptedException e) { latch.countDown(); break; } } }