diff --git a/inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/utils/RetryUtils.java b/inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/utils/RetryUtils.java index 62844b2850..01ace045f0 100644 --- a/inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/utils/RetryUtils.java +++ b/inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/utils/RetryUtils.java @@ -18,7 +18,7 @@ private RetryUtils() { } public static Retry buildRetry(RetrySettings retrySettings, String retryName) { - if (retrySettings != null && retrySettings.isEnabled()) { + if (useRetry(retrySettings)) { RetryConfig retryConfig = RetryConfig.custom() .maxAttempts(retrySettings.getMaxAttempts()) .intervalFunction(IntervalFunction @@ -35,7 +35,7 @@ public static Retry buildRetry(RetrySettings retrySettings, String retryName) { } public static TimeLimiter buildTimeLimiter(RetrySettings retrySettings, String timeLimiterName) { - if(retrySettings != null && retrySettings.isEnabled()) { + if(useTimeLimiter(retrySettings)) { TimeLimiterConfig timeLimiterConfig = TimeLimiterConfig.custom() .cancelRunningFuture(true) .timeoutDuration(retrySettings.getTimeLimit()) @@ -46,4 +46,12 @@ public static TimeLimiter buildTimeLimiter(RetrySettings retrySettings, String t } return null; } + + private static boolean useRetry(RetrySettings retrySettings) { + return retrySettings != null && retrySettings.isEnabled(); + } + + private static boolean useTimeLimiter(RetrySettings retrySettings) { + return useRetry(retrySettings) && retrySettings.getTimeLimit() != null; + } }