@Override public ServerLocation findBestServer(ServerLocation currentServer, Set excludedServers) { if (currentServer != null && source.isBalanced()) { return currentServer; } final Set origExcludedServers = excludedServers; excludedServers = new HashSet(excludedServers); Set denyListedServers = denyList.getBadServers(); excludedServers.addAll(denyListedServers); ServerLocation server = source.findReplacementServer(currentServer, excludedServers); if (server == null) { // Nothing worked! Let's try without the denylist. if (excludedServers.size() > origExcludedServers.size()) { // We had some servers denylisted so lets give this another whirl. server = source.findReplacementServer(currentServer, origExcludedServers); } } if (server == null && logger.isDebugEnabled()) { logger.debug("Source was unable to findForReplacement any servers"); } return server; }