Showing
1 changed file
with
5 additions
and
0 deletions
@@ -22,6 +22,7 @@ public class PersionalRateLimitService { | @@ -22,6 +22,7 @@ public class PersionalRateLimitService { | ||
22 | private Map<String, Integer> oldCountMap = new ConcurrentHashMap<String, Integer>(); | 22 | private Map<String, Integer> oldCountMap = new ConcurrentHashMap<String, Integer>(); |
23 | 23 | ||
24 | public boolean isPersionalRateLimit(String rateLimitName, PersionalRateLimitConfig limitConfig) { | 24 | public boolean isPersionalRateLimit(String rateLimitName, PersionalRateLimitConfig limitConfig) { |
25 | + try { | ||
25 | long expireTime = System.currentTimeMillis() + limitConfig.getSecond() * 1000L; | 26 | long expireTime = System.currentTimeMillis() + limitConfig.getSecond() * 1000L; |
26 | KeyCountWithExpiredTime keyCountWithExpiredTime = keyCountMap.putIfAbsent(rateLimitName, new KeyCountWithExpiredTime(expireTime)); | 27 | KeyCountWithExpiredTime keyCountWithExpiredTime = keyCountMap.putIfAbsent(rateLimitName, new KeyCountWithExpiredTime(expireTime)); |
27 | if (keyCountWithExpiredTime == null) { | 28 | if (keyCountWithExpiredTime == null) { |
@@ -38,6 +39,10 @@ public class PersionalRateLimitService { | @@ -38,6 +39,10 @@ public class PersionalRateLimitService { | ||
38 | oldCountMap.put(rateLimitName, currentCount); | 39 | oldCountMap.put(rateLimitName, currentCount); |
39 | DOWNGRADE.error("PersionalRateLimit happen ,rateLimitName is [{}],currentCount is[{}], limitConfig is [{}]", rateLimitName,currentCount, limitConfig.toLogInfo()); | 40 | DOWNGRADE.error("PersionalRateLimit happen ,rateLimitName is [{}],currentCount is[{}], limitConfig is [{}]", rateLimitName,currentCount, limitConfig.toLogInfo()); |
40 | return true; | 41 | return true; |
42 | + }catch (Exception e){ | ||
43 | + DOWNGRADE.error(e.getMessage(),e); | ||
44 | + return false; | ||
45 | + } | ||
41 | } | 46 | } |
42 | 47 | ||
43 | } | 48 | } |
-
Please register or login to post a comment