diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StreamUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StreamUtils.java index b851d5cc..c8643157 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StreamUtils.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StreamUtils.java @@ -30,7 +30,8 @@ public class StreamUtils { if (CollUtil.isEmpty(collection)) { return CollUtil.newArrayList(); } - return collection.stream().filter(function).toList(); + // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 + return collection.stream().filter(function).collect(Collectors.toList()); } /** @@ -70,7 +71,8 @@ public class StreamUtils { if (CollUtil.isEmpty(collection)) { return CollUtil.newArrayList(); } - return collection.stream().sorted(comparing).toList(); + // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 + return collection.stream().sorted(comparing).collect(Collectors.toList()); } /** @@ -188,7 +190,8 @@ public class StreamUtils { .stream() .map(function) .filter(Objects::nonNull) - .toList(); + // 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题 + .collect(Collectors.toList()); } /** diff --git a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/utils/RedisUtils.java b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/utils/RedisUtils.java index 79ea3b8e..b665160d 100644 --- a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/utils/RedisUtils.java +++ b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/utils/RedisUtils.java @@ -438,7 +438,7 @@ public class RedisUtils { */ public static Collection keys(final String pattern) { Stream stream = CLIENT.getKeys().getKeysStreamByPattern(pattern); - return stream.toList(); + return stream.collect(Collectors.toList()); } /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/monitor/CacheController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/monitor/CacheController.java index 85692b33..01cb4710 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/monitor/CacheController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/monitor/CacheController.java @@ -6,6 +6,7 @@ import com.ruoyi.common.core.constant.CacheConstants; import com.ruoyi.common.core.constant.CacheNames; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.JsonUtils; +import com.ruoyi.common.core.utils.StreamUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.redis.utils.CacheUtils; import com.ruoyi.common.redis.utils.RedisUtils; @@ -90,7 +91,7 @@ public class CacheController { if (isCacheNames(cacheName)) { Set keys = CacheUtils.keys(cacheName); if (CollUtil.isNotEmpty(keys)) { - cacheKeys = keys.stream().map(Object::toString).toList(); + cacheKeys = StreamUtils.toList(keys, Object::toString); } } else { cacheKeys = RedisUtils.keys(cacheName + "*"); diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java index 937ee16d..7dcb8b88 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOssServiceImpl.java @@ -6,13 +6,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.constant.CacheNames; -import com.ruoyi.common.mybatis.core.page.PageQuery; -import com.ruoyi.common.mybatis.core.page.TableDataInfo; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.BeanCopyUtils; +import com.ruoyi.common.core.utils.SpringUtils; +import com.ruoyi.common.core.utils.StreamUtils; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.file.FileUtils; -import com.ruoyi.common.core.utils.SpringUtils; +import com.ruoyi.common.mybatis.core.page.PageQuery; +import com.ruoyi.common.mybatis.core.page.TableDataInfo; import com.ruoyi.common.oss.core.OssClient; import com.ruoyi.common.oss.entity.UploadResult; import com.ruoyi.common.oss.enumd.AccessPolicyType; @@ -22,20 +23,19 @@ import com.ruoyi.system.domain.bo.SysOssBo; import com.ruoyi.system.domain.vo.SysOssVo; import com.ruoyi.system.mapper.SysOssMapper; import com.ruoyi.system.service.ISysOssService; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.cache.annotation.Cacheable; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; -import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * 文件上传 服务层实现 @@ -52,7 +52,7 @@ public class SysOssServiceImpl implements ISysOssService { public TableDataInfo queryPageList(SysOssBo bo, PageQuery pageQuery) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); - List filterResult = result.getRecords().stream().map(this::matchingUrl).toList(); + List filterResult = StreamUtils.toList(result.getRecords(), this::matchingUrl); result.setRecords(filterResult); return TableDataInfo.build(result); }