AutoLoadCache icon indicating copy to clipboard operation
AutoLoadCache copied to clipboard

magic模式下,获取缓存key存在NPE

Open DR-YangLong opened this issue 4 years ago • 1 comments

场景描述: 使用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,出现错误

DR-YangLong avatar Sep 11 '20 08:09 DR-YangLong

欢迎提PR。

qiujiayu avatar Sep 12 '20 11:09 qiujiayu