Retry code does not fire RetryOnRetryEvent when rety caused by predicate

Author: bbakermanCreated May 20, 2021Updated Sep 27, 2026
Labelsbug

Resilience4j version: 1.7.0

Java version: 11

The Retry impl does not fire a RetryOnRetryEvent event when the retry is caused by the retry predicate. It does when the retry is caused by an exception

Our goal was to know how many times a CompletionStage has been retried and to debug log that. We planned to use the RetryOnRetryEvent event for that but it does not fire on predicate based decisions.

Our expectation is that if a rety occurs, the event would fire.

BTW - great library and thank you

        private void onResult(T result) {
            final long delay = retryContext.onResult(result);

            if (delay < 1) {
                try {
                    retryContext.onComplete();
                    promise.complete(result);
                } catch (Exception e) {
                    promise.completeExceptionally(e);
                }
            } else {
                scheduler.schedule(this, delay, TimeUnit.MILLISECONDS);
            }
        }

and from the retry context code

        public long onResult(T result) {
            if (null != resultPredicate && resultPredicate.test(result)) {
                int attempt = numOfAttempts.incrementAndGet();
                if (attempt >= maxAttempts) {
                    return -1;
                }
                return intervalBiFunction.apply(attempt, Either.right(result));
            } else {
                return -1;
            }
        }

Source: resilience4j/resilience4j