Source:
<code>protected void ping(InetAddress address) throws Exception { Socket socket = null; int ping = 1; for (; ; ) { if (isDebug()) { LOGGER.debug("Trial #{}/{} - creating socket connected to on port {}", ping, getMaxPings(), address, getPort()); } try { socket = new Socket(address, getPort()); break; } catch (ConnectException ce) { <START> LOGGER.debug("Trial #{}/{} - exception caught: while creating socket connected to on port {}", ping, getMaxPings(), ce, address, getPort()); <END> ping++; if (ping <= getMaxPings()) { LOGGER.debug("Waiting milliseconds before retrying ...", getPingIntervalMilli()); Thread.sleep(getPingIntervalMilli()); } else { break; } } } if (socket == null) { throw new ConnectException("maxPings exceeded: " + getMaxPings() + ". Giving up. The clamd daemon seems not to be running"); } try { BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "ASCII")); PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true); LOGGER.debug("Sending: \"PING\" to ...", address); writer.println("PING"); writer.flush(); boolean pongReceived = false; for (; ; ) { String answer = reader.readLine(); if (answer != null) { answer = answer.trim(); LOGGER.debug("Received: \"{}\"", answer); answer = answer.trim(); if (answer.equals("PONG")) { pongReceived = true; } } else { break; } } reader.close(); writer.close(); if (!pongReceived) { throw new ConnectException("Bad answer from \"PING\" probe: expecting \"PONG\""); } } finally { socket.close(); } }</code><technical_language>This log line poor. LOGGER.debug("Trial #{}/{} - exception caught while creating socket connected port {}", ping, getMaxPings(), address, getPort(), ce); avoid loosing stacktrace..</technical_language>

Target:
protected void ping(InetAddress address) throws Exception { Socket socket = null; int ping = 1; for (; ; ) { if (isDebug()) { LOGGER.debug("Trial #{}/{} - creating socket connected to on port {}", ping, getMaxPings(), address, getPort()); } try { socket = new Socket(address, getPort()); break; } catch (ConnectException ce) { LOGGER.debug("Trial #{}/{} - exception caught while creating socket connected to on port {}", ping, getMaxPings(), address, getPort(), ce); ping++; if (ping <= getMaxPings()) { LOGGER.debug("Waiting milliseconds before retrying ...", getPingIntervalMilli()); Thread.sleep(getPingIntervalMilli()); } else { break; } } } if (socket == null) { throw new ConnectException("maxPings exceeded: " + getMaxPings() + ". Giving up. The clamd daemon seems not to be running"); } try { BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "ASCII")); PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true); LOGGER.debug("Sending: \"PING\" to ...", address); writer.println("PING"); writer.flush(); boolean pongReceived = false; for (; ; ) { String answer = reader.readLine(); if (answer != null) { answer = answer.trim(); LOGGER.debug("Received: \"{}\"", answer); answer = answer.trim(); if (answer.equals("PONG")) { pongReceived = true; } } else { break; } } reader.close(); writer.close(); if (!pongReceived) { throw new ConnectException("Bad answer from \"PING\" probe: expecting \"PONG\""); } } finally { socket.close(); } }