@Override
    public RetryResult recordResult(MethodResult<?> methodResult) {
        ResultCategory resultCategory = null;

        attempts++;
        long duration = System.nanoTime() - startNanos;

        if (methodResult.isFailure()) {
            // Failure case
            if (abortOn(methodResult.getFailure())) {
                resultCategory = ResultCategory.EXCEPTION_IN_ABORT_ON;
            } else if (retryOn(methodResult.getFailure())) {
                resultCategory = ResultCategory.EXCEPTION_IN_RETRY_ON;
            } else {
                resultCategory = ResultCategory.EXCEPTION_NOT_IN_RETRY_ON;
            }
        } else {
            // Successful case
            resultCategory = ResultCategory.NO_EXCEPTION;
        }

        // Capture whether this result was considered a retry-able failure by the Retry
        boolean resultWasRetryableFailure = shouldRetry(resultCategory);

        // If we want to retry based on the methodResult, check if there's some other reason we shouldn't
        if (resultWasRetryableFailure) {
            int maxAttempts = policy.getMaxRetries() + 1;
            if (maxAttempts != 0 && attempts >= maxAttempts) {
                resultCategory = ResultCategory.MAX_RETRIES_REACHED;
            } else if (overMaxDuration(duration)) {
                resultCategory = ResultCategory.MAX_DURATION_REACHED;
            }
        }

        if (shouldRetry(resultCategory)) {
            metricRecorder.incrementRetriesCount();
        } else {
            // Finished execution, record metrics
            if (resultWasRetryableFailure) {
                metricRecorder.incrementRetryCallsFailureCount();
            } else {
                if (attempts > 1) {
                    metricRecorder.incrementRetryCallsSuccessRetriesCount();
                } else {
                    metricRecorder.incrementRetryCallsSuccessImmediateCount();
                }
            }
        }

        return createResult(resultCategory);
    }
@ Override public RetryResult recordResult ( MethodResult < ? > methodResult ) { ResultCategory resultCategory = null ; attempts ++ ; long duration = System . nanoTime ( ) - startNanos ; if ( methodResult . isFailure ( ) ) { if ( abortOn ( methodResult . getFailure ( ) ) ) { resultCategory = ResultCategory . EXCEPTION_IN_ABORT_ON ; } else if ( retryOn ( methodResult . getFailure ( ) ) ) { resultCategory = ResultCategory . EXCEPTION_IN_RETRY_ON ; } else { resultCategory = ResultCategory . EXCEPTION_NOT_IN_RETRY_ON ; } } else { resultCategory = ResultCategory . NO_EXCEPTION ; } boolean resultWasRetryableFailure = shouldRetry ( resultCategory ) ; if ( resultWasRetryableFailure ) { int maxAttempts = policy . getMaxRetries ( ) + 1 ; if ( maxAttempts != 0 && attempts >= maxAttempts ) { resultCategory = ResultCategory . MAX_RETRIES_REACHED ; } else if ( overMaxDuration ( duration ) ) { resultCategory = ResultCategory . MAX_DURATION_REACHED ; } } if ( shouldRetry ( resultCategory ) ) { metricRecorder . incrementRetriesCount ( ) ; } else { if ( resultWasRetryableFailure ) { metricRecorder . incrementRetryCallsFailureCount ( ) ; } else { if ( attempts > 1 ) { metricRecorder . incrementRetryCallsSuccessRetriesCount ( ) ; } else { metricRecorder . incrementRetryCallsSuccessImmediateCount ( ) ; } } } return createResult ( resultCategory ) ; }
{@inheritDoc}