Source:
public void onException(Connection connection, Exception exception, long latency, int retryCount) { QueryState queryState = queryStateRef.get(); if (!queryState.isInProgressAt(retryCount) || !queryStateRef.compareAndSet(queryState, queryState.complete())) { logger.debug("onException triggered but the response was completed by another thread, cancelling (retryCount = {}, queryState = {}, queryStateRef = {})", retryCount, queryState, queryStateRef.get()); return; } Host queriedHost = current; try { connection.release(); if (exception instanceof ConnectionException) { ConnectionException ce = (ConnectionException)exception; RetryPolicy retryPolicy = retryPolicy(); RetryPolicy.RetryDecision decision; if (retryPolicy instanceof ExtendedRetryPolicy) decision = ((ExtendedRetryPolicy)retryPolicy).onConnectionError(statement, request().consistency(), ce, retriesByPolicy); else decision = RetryPolicy.RetryDecision.tryNextHost(null); if (metricsEnabled()) { metrics().getErrorMetrics().getConnectionErrors().inc(); if (decision.getType() == Type.RETRY) metrics().getErrorMetrics().getRetriesOnConnectionError().inc(); if (decision.getType() == Type.IGNORE) metrics().getErrorMetrics().getIgnoresOnConnectionError().inc(); } processRetryDecision(decision, connection, exception); return; } setFinalException(connection, exception); } catch (Exception e) { setFinalException(null, new DriverInternalError("An unexpected error happened while handling exception " + exception, e)); } finally { if (queriedHost != null && statement != Statement.DEFAULT) manager.cluster.manager.reportLatency(queriedHost, statement, exception, latency); } }

Target:
public void onException(Connection connection, Exception exception, long latency, int retryCount) { QueryState queryState = queryStateRef.get(); if (!queryState.isInProgressAt(retryCount) || !queryStateRef.compareAndSet(queryState, queryState.complete())) { logger.debug("onException triggered but the response was completed by another thread, cancelling (retryCount = {}, queryState = {}, queryStateRef = {})", retryCount, queryState, queryStateRef.get()); return; } Host queriedHost = current; try { connection.release(); if (exception instanceof ConnectionException) { RetryPolicy retryPolicy = retryPolicy(); RetryPolicy.RetryDecision decision; if (retryPolicy instanceof ExtendedRetryPolicy) decision = ((ExtendedRetryPolicy)retryPolicy).onRequestError(statement, request().consistency(), exception, retriesByPolicy); else decision = RetryPolicy.RetryDecision.tryNextHost(request().consistency()); if (metricsEnabled()) { metrics().getErrorMetrics().getConnectionErrors().inc(); if (decision.getType() == Type.RETRY) metrics().getErrorMetrics().getRetriesOnConnectionError().inc(); if (decision.getType() == Type.IGNORE) metrics().getErrorMetrics().getIgnoresOnConnectionError().inc(); } processRetryDecision(decision, connection, exception); return; } setFinalException(connection, exception); } catch (Exception e) { setFinalException(null, new DriverInternalError("An unexpected error happened while handling exception " + exception, e)); } finally { if (queriedHost != null && statement != Statement.DEFAULT) manager.cluster.manager.reportLatency(queriedHost, statement, exception, latency); } }