Open DR-YangLong opened 4 years ago
场景描述: 使用magic模式进行返回列表分割缓存存储,当返回值中含有NULL时,引发NPE 使用代码: @LocalCache(expire = 500) @Cache(expire = 600, expireExpression = "null == #retVal ? 30: 600", key = "", magic = @Magic(key = "'user-magic-'+ #retVal.userId"), autoload = true) @Override public List<UserInfo> loadAllUsers() { return LongStream.rangeClosed(1, 105).mapToObj(this::createUser).collect(Collectors.toList()); } 发生错误源代码: AbstractScriptParser#getDefinedCacheKey SpringELParser#getElValue 原因:未对返回值做null判断,返回值列表中有有NULL,出现错误
@LocalCache(expire = 500) @Cache(expire = 600, expireExpression = "null == #retVal ? 30: 600", key = "", magic = @Magic(key = "'user-magic-'+ #retVal.userId"), autoload = true) @Override public List<UserInfo> loadAllUsers() { return LongStream.rangeClosed(1, 105).mapToObj(this::createUser).collect(Collectors.toList()); }
欢迎提PR。
场景描述: 使用magic模式进行返回列表分割缓存存储,当返回值中含有NULL时,引发NPE 使用代码:
@LocalCache(expire = 500) @Cache(expire = 600, expireExpression = "null == #retVal ? 30: 600", key = "", magic = @Magic(key = "'user-magic-'+ #retVal.userId"), autoload = true) @Override public List<UserInfo> loadAllUsers() { return LongStream.rangeClosed(1, 105).mapToObj(this::createUser).collect(Collectors.toList()); }
发生错误源代码: AbstractScriptParser#getDefinedCacheKey SpringELParser#getElValue 原因:未对返回值做null判断,返回值列表中有有NULL,出现错误