Skip to content

Commit

Permalink
add null check for time-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
EddeCCC committed Dec 17, 2024
1 parent afe5745 commit b290bbe
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -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;
}
}

0 comments on commit b290bbe

Please sign in to comment.