public static Result isRetryableException()

in gremlin-client/src/main/java/software/amazon/utils/RetryUtils.java [23:70]


    public static Result isRetryableException(Exception ex) {
        Throwable e = ExceptionUtils.getRootCause(ex);

        Class<? extends Throwable> exceptionClass = e.getClass();

        String message = getMessage(e);

        if (NoHostAvailableException.class.isAssignableFrom(exceptionClass)) {
            return Result.RETRYABLE(e, message);
        }

        if (ConnectException.class.isAssignableFrom(exceptionClass)) {
            return Result.RETRYABLE(e, message);
        }

        // Check for connection issues
        if (message.contains("Timed out while waiting for an available host") ||
                message.contains("waiting for connection") ||
                message.contains("Connection to server is no longer active") ||
                message.contains("Connection reset by peer") ||
                message.contains("Connection refused") ||
                message.contains("SSLEngine closed already") ||
                message.contains("Pool is shutdown") ||
                message.contains("ExtendedClosedChannelException") ||
                message.contains("Broken pipe") ||
                message.contains("StacklessClosedChannelException") ) {
            return Result.RETRYABLE(e, message);
        }

        // Concurrent writes can sometimes trigger a ConcurrentModificationException.
        // In these circumstances you may want to backoff and retry.
        if (message.contains("ConcurrentModificationException")) {
            return Result.RETRYABLE(e, message);
        }

        // If the primary fails over to a new instance, existing connections to the old primary will
        // throw a ReadOnlyViolationException. You may want to back and retry.
        if (message.contains("ReadOnlyViolationException")) {
            return Result.RETRYABLE(e, message);
        }

        // CVEs can sometimes occur if a previous transaction is not yet visible to the current transaction.
        if (message.contains("ConstraintViolationException")) {
            return Result.RETRYABLE(e, message);
        }

        return Result.NOT_RETRYABLE(e, message);
    }