fix PersionalRateLimitService
Showing
1 changed file
with
1 additions
and
4 deletions
@@ -19,10 +19,7 @@ public class PersionalRateLimitService { | @@ -19,10 +19,7 @@ public class PersionalRateLimitService { | ||
19 | public boolean isPersionalRateLimit(String rateLimitName, PersionalRateLimitConfig limitConfig) { | 19 | public boolean isPersionalRateLimit(String rateLimitName, PersionalRateLimitConfig limitConfig) { |
20 | try { | 20 | try { |
21 | long expireTime = System.currentTimeMillis() + limitConfig.getSecond() * 1000L; | 21 | long expireTime = System.currentTimeMillis() + limitConfig.getSecond() * 1000L; |
22 | - KeyCountWithExpiredTime keyCountWithExpiredTime = keyCountMap.putIfAbsent(rateLimitName, new KeyCountWithExpiredTime(expireTime)); | ||
23 | - if (keyCountWithExpiredTime == null) { | ||
24 | - keyCountWithExpiredTime = keyCountMap.get(rateLimitName); | ||
25 | - } | 22 | + KeyCountWithExpiredTime keyCountWithExpiredTime = keyCountMap.computeIfAbsent(rateLimitName, k->new KeyCountWithExpiredTime(expireTime)); |
26 | int currentCount = keyCountWithExpiredTime.incrementAndGet(expireTime); | 23 | int currentCount = keyCountWithExpiredTime.incrementAndGet(expireTime); |
27 | Integer oldCount = oldCountMap.get(rateLimitName); | 24 | Integer oldCount = oldCountMap.get(rateLimitName); |
28 | //第二轮再开始打上一轮降级日志 | 25 | //第二轮再开始打上一轮降级日志 |
-
Please register or login to post a comment