private void invoke()

in src/main/java/com/amazonaws/services/simpleworkflow/flow/interceptors/AsyncRetryingExecutor.java [97:133]


    private void invoke(final AsyncRunnable command, final int attempt, final long timeOfFirstAttempt) {
        final Settable<Throwable> shouldRetry = new Settable<Throwable>();

        new TryCatchFinally() {

            Throwable failureToRetry = null;

            @Override
            protected void doTry() throws Throwable {
                command.run();
            }

            @Override
            protected void doCatch(Throwable failure) throws Throwable {
                if (failure instanceof CancellationException) {
                    throw failure;
                }
                failureToRetry = failure;
            }

            @Override
            protected void doFinally() throws Throwable {
                shouldRetry.set(failureToRetry);
            }
        };

        new Task(shouldRetry) {

            @Override
            protected void doExecute() throws Throwable {
                Throwable failure = shouldRetry.get();
                if (failure != null) {
                    scheduleWithRetry(command, failure, attempt + 1, timeOfFirstAttempt, clock.currentTimeMillis());
                }
            }
        };
    }