You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by mo...@apache.org on 2022/11/16 09:56:01 UTC

[incubator-streampark] branch dev updated: [Bug] project list modules bug fixed (#2026)

This is an automated email from the ASF dual-hosted git repository.

monster pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev by this push:
     new 6f383e0ae [Bug] project list modules bug fixed (#2026)
6f383e0ae is described below

commit 6f383e0aeb29e886068055d67105d51c04eb1226
Author: benjobs <be...@apache.org>
AuthorDate: Wed Nov 16 17:55:55 2022 +0800

    [Bug] project list modules bug fixed (#2026)
---
 .../core/service/impl/ProjectServiceImpl.java      | 25 ++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
index 1e4d9b9f9..7abe4154e 100644
--- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
+++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
@@ -28,6 +28,7 @@ import org.apache.streampark.console.base.domain.ResponseCode;
 import org.apache.streampark.console.base.domain.RestRequest;
 import org.apache.streampark.console.base.domain.RestResponse;
 import org.apache.streampark.console.base.mybatis.pager.MybatisPager;
+import org.apache.streampark.console.base.util.CommonUtils;
 import org.apache.streampark.console.base.util.FileUtils;
 import org.apache.streampark.console.base.util.GZipUtils;
 import org.apache.streampark.console.core.entity.Application;
@@ -56,6 +57,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -186,10 +188,25 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project>
     @Override
     public List<String> modules(Long id) {
         Project project = getById(id);
-        File appHome = project.getDistHome();
-        List<String> list = new ArrayList<>();
-        Arrays.stream(Objects.requireNonNull(appHome.listFiles())).forEach((x) -> list.add(x.getName()));
-        return list;
+        AssertUtils.state(project != null);
+        BuildState buildState = BuildState.of(project.getBuildState());
+        if (BuildState.SUCCESSFUL.equals(buildState)) {
+            File appHome = project.getDistHome();
+            if (appHome.exists()) {
+                List<String> list = new ArrayList<>();
+                File[] files = appHome.listFiles();
+                if (CommonUtils.notEmpty(files)) {
+                    for (File file: files) {
+                        list.add(file.getName());
+                    }
+                }
+                return list;
+            } else {
+                return Collections.emptyList();
+            }
+        } else {
+            return Collections.emptyList();
+        }
     }
 
     @Override