Exclude RateLimitExceededException from fail-open checks

This commit is contained in:
Jon Chambers authored and GitHub committed 2025-05-12 15:24:57 -07:00
1 parent cc7b030a41
commit 30c194c557
2 files changed
+84 -1

No files matched your search

@@ -62,6 +62,10 @@ public class StaticRateLimiter implements RateLimiter {
throw new RateLimitExceededException(retryAfter);
}
} catch (final Exception e) {
if (e instanceof RateLimitExceededException rateLimitExceededException) {
throw rateLimitExceededException;
}
if (!config.failOpen()) {
throw e;
}
@@ -81,10 +85,15 @@ public class StaticRateLimiter implements RateLimiter {
return failedFuture(new RateLimitExceededException(retryAfter));
})
.exceptionally(throwable -> {
if (ExceptionUtils.unwrap(throwable) instanceof RateLimitExceededException rateLimitExceededException) {
throw ExceptionUtils.wrap(rateLimitExceededException);
}
if (config.failOpen()) {
return null;
}
throw ExceptionUtils.wrap(new RateLimitExceededException(null));
throw ExceptionUtils.wrap(throwable);
});
}