修复 sa-token-redis-jackson 模块代码警告

This commit is contained in:
click33 2023-05-16 16:35:57 +08:00
parent 8bbae3eb32
commit db2dfcf32f

View File

@ -104,8 +104,7 @@ public class SaTokenDaoRedisJackson implements SaTokenDao {
try { try {
Field field = GenericJackson2JsonRedisSerializer.class.getDeclaredField("mapper"); Field field = GenericJackson2JsonRedisSerializer.class.getDeclaredField("mapper");
field.setAccessible(true); field.setAccessible(true);
ObjectMapper objectMapper = (ObjectMapper) field.get(valueSerializer); this.objectMapper = (ObjectMapper) field.get(valueSerializer);
this.objectMapper = objectMapper;
// 配置[忽略未知字段] // 配置[忽略未知字段]
this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@ -138,7 +137,7 @@ public class SaTokenDaoRedisJackson implements SaTokenDao {
stringTemplate.afterPropertiesSet(); stringTemplate.afterPropertiesSet();
// 构建RedisTemplate // 构建RedisTemplate
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>(); RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory); template.setConnectionFactory(connectionFactory);
template.setKeySerializer(keySerializer); template.setKeySerializer(keySerializer);
template.setHashKeySerializer(keySerializer); template.setHashKeySerializer(keySerializer);
@ -308,7 +307,7 @@ public class SaTokenDaoRedisJackson implements SaTokenDao {
@Override @Override
public List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType) { public List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType) {
Set<String> keys = stringRedisTemplate.keys(prefix + "*" + keyword + "*"); Set<String> keys = stringRedisTemplate.keys(prefix + "*" + keyword + "*");
List<String> list = new ArrayList<String>(keys); List<String> list = new ArrayList<>(keys);
return SaFoxUtil.searchList(list, start, size, sortType); return SaFoxUtil.searchList(list, start, size, sortType);
} }