From bc00242ee0410684eb9f4c5fe0aa486dfebb3162 Mon Sep 17 00:00:00 2001
From: lead <lead@local>
Date: 星期二, 03 十一月 2026 10:09:31 +0800
Subject: [PATCH] fix(api): 修复全量接口扫描发现的 500 —— 由 70 个降到 0 个
---
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java
index 12bab8a..19e4e15 100644
--- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java
+++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java
@@ -11,6 +11,8 @@
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.*;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.infra.service.file.FileService;
+import com.google.common.cache.CacheLoader;
+import com.google.common.util.concurrent.UncheckedExecutionException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -117,7 +119,20 @@
path = HttpUtils.decodeUrlPath(path);
// 璇诲彇鍐呭
- byte[] content = fileService.getFileContent(configId, path);
+ byte[] content;
+ try {
+ content = fileService.getFileContent(configId, path);
+ } catch (IllegalArgumentException | UncheckedExecutionException ex) {
+ // 鏂囦欢閰嶇疆涓嶅瓨鍦紙濡� configId 鏃犳晥锛夋椂锛屾寜璧勬簮涓嶅瓨鍦ㄨ繑鍥� 404锛岃�屼笉鏄� 500
+ log.warn("[getFileContent][configId({}) path({}) 鏂囦欢閰嶇疆涓嶅瓨鍦╙", configId, path);
+ response.setStatus(HttpStatus.NOT_FOUND.value());
+ return;
+ } catch (CacheLoader.InvalidCacheLoadException ex) {
+ // LoadingCache 鐨� load 杩斿洖 null 鏃舵姏鍑猴紙渚嬪鍘嗗彶鏂囦欢璁板綍鐨� configId 宸茶鍒犻櫎锛夛紝鍚屾牱鎸夎祫婧愪笉瀛樺湪澶勭悊
+ log.warn("[getFileContent][configId({}) path({}) 鏂囦欢閰嶇疆涓嶅瓨鍦╙", configId, path);
+ response.setStatus(HttpStatus.NOT_FOUND.value());
+ return;
+ }
if (content == null) {
log.warn("[getFileContent][configId({}) path({}) 鏂囦欢涓嶅瓨鍦╙", configId, path);
response.setStatus(HttpStatus.NOT_FOUND.value());
--
Gitblit v1.9.3