mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 13:06:53 +00:00
Exclude RateLimitExceededException from fail-open checks
This commit is contained in:
1 parent
cc7b030a41
commit
30c194c557
2 files changed
+84
-1
No files matched your search
+10
-1
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user