【fix sonar】RedisUtil文件

This commit is contained in:
梁琦涛
2023-03-08 10:01:43 +08:00
parent 8775331948
commit 7d978355e9
@@ -1,9 +1,6 @@
package com.jero.common.util;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
@@ -320,7 +317,7 @@ public class RedisUtil {
return redisTemplate.opsForSet().members(key);
} catch (Exception e) {
e.printStackTrace();
return null;
return Collections.emptySet();
}
}
@@ -401,8 +398,7 @@ public class RedisUtil {
*/
public long setRemove(String key, Object... values) {
try {
Long count = redisTemplate.opsForSet().remove(key, values);
return count;
return redisTemplate.opsForSet().remove(key, values);
} catch (Exception e) {
e.printStackTrace();
return 0;
@@ -423,7 +419,7 @@ public class RedisUtil {
return redisTemplate.opsForList().range(key, start, end);
} catch (Exception e) {
e.printStackTrace();
return null;
return Collections.emptyList();
}
}
@@ -564,8 +560,7 @@ public class RedisUtil {
*/
public long lRemove(String key, long count, Object value) {
try {
Long remove = redisTemplate.opsForList().remove(key, count, value);
return remove;
return redisTemplate.opsForList().remove(key, count, value);
} catch (Exception e) {
e.printStackTrace();
return 0;
@@ -592,11 +587,11 @@ public class RedisUtil {
return binaryKeys;
});
} catch (Throwable e) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
return Collections.emptySet();
}
/**
@@ -606,8 +601,11 @@ public class RedisUtil {
public void removeAll(String keyPrefix) {
try {
Set<String> keys = keys(keyPrefix);
if(keys == null){
return;
}
redisTemplate.delete(keys);
} catch (Throwable e) {
}catch (Exception e){
e.printStackTrace();
}
}