【fix sonar】RedisUtil文件

This commit is contained in:
梁琦涛
2023-04-03 18:21:53 +08:00
parent 3b1ad1a510
commit 97184275a3
@@ -141,7 +141,7 @@ public class RedisUtil {
*/ */
public long incr(String key, long delta) { public long incr(String key, long delta) {
if (delta < 0) { if (delta < 0) {
throw new RuntimeException("递增因子必须大于0"); throw new IllegalArgumentException("递增因子必须大于0");
} }
return redisTemplate.opsForValue().increment(key, delta); return redisTemplate.opsForValue().increment(key, delta);
} }
@@ -155,7 +155,7 @@ public class RedisUtil {
*/ */
public long decr(String key, long delta) { public long decr(String key, long delta) {
if (delta < 0) { if (delta < 0) {
throw new RuntimeException("递减因子必须大于0"); throw new IllegalArgumentException("递减因子必须大于0");
} }
return redisTemplate.opsForValue().increment(key, -delta); return redisTemplate.opsForValue().increment(key, -delta);
} }