فهرست منبع

fix: ContentRecommendService NPE when type is null

switch(type) throws NullPointerException when request type is missing. Added null guard before switch.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Xiaogang Liao 1 ماه پیش
والد
کامیت
ad28e68b90
1فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  1. 3 1
      cfc-backend/src/main/java/com/etotem/cfc/service/ContentRecommendService.java

+ 3 - 1
cfc-backend/src/main/java/com/etotem/cfc/service/ContentRecommendService.java

@@ -68,7 +68,9 @@ public class ContentRecommendService {
 
 
         List<RecommendItemVO> items;
         List<RecommendItemVO> items;
 
 
-        switch (type) {
+        if (type == null) {
+            items = new ArrayList<>();
+        } else switch (type) {
             case "article":
             case "article":
                 items = recommendArticles(dimensionCode, userId, familyId, childId, excludeIds);
                 items = recommendArticles(dimensionCode, userId, familyId, childId, excludeIds);
                 break;
                 break;