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

benjobs 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 383f2ef73 Improvement in releasing system-provided demo job null 
pointer exception when using streampark for the first time (#3881)
383f2ef73 is described below

commit 383f2ef73c91f127e4ec8fa27d14382a50a1c4ae
Author: Kerwin <[email protected]>
AuthorDate: Wed Jul 17 21:20:16 2024 +0800

    Improvement in releasing system-provided demo job null pointer exception 
when using streampark for the first time (#3881)
---
 .../core/service/application/impl/ApplicationInfoServiceImpl.java  | 7 +------
 .../console/core/service/impl/AppBuildPipeServiceImpl.java         | 7 ++++---
 .../streampark/console/core/service/impl/FlinkEnvServiceImpl.java  | 3 +++
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationInfoServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationInfoServiceImpl.java
index 5d31b6272..6712318b6 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationInfoServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/ApplicationInfoServiceImpl.java
@@ -222,12 +222,7 @@ public class ApplicationInfoServiceImpl extends 
ServiceImpl<ApplicationMapper, A
     public boolean checkEnv(Application appParam) throws ApplicationException {
         Application application = getById(appParam.getId());
         try {
-            FlinkEnv flinkEnv;
-            if (application.getVersionId() != null) {
-                flinkEnv = 
flinkEnvService.getByIdOrDefault(application.getVersionId());
-            } else {
-                flinkEnv = flinkEnvService.getDefault();
-            }
+            FlinkEnv flinkEnv = 
flinkEnvService.getByIdOrDefault(application.getVersionId());
             if (flinkEnv == null) {
                 return false;
             }
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/AppBuildPipeServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/AppBuildPipeServiceImpl.java
index 972a2fe7c..ff92efce8 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/AppBuildPipeServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/AppBuildPipeServiceImpl.java
@@ -429,15 +429,16 @@ public class AppBuildPipeServiceImpl
         Application app = applicationManageService.getById(appId);
 
         // 1) check flink version
-        FlinkEnv env = flinkEnvService.getById(app.getVersionId());
+        String checkEnvErrorMessage = "Check flink env failed, please check 
the flink version of this job";
+        FlinkEnv env = flinkEnvService.getByIdOrDefault(app.getVersionId());
+        ApiAlertException.throwIfNull(env, checkEnvErrorMessage);
         boolean checkVersion = env.getFlinkVersion().checkVersion(false);
         ApiAlertException.throwIfFalse(
             checkVersion, "Unsupported flink version:" + 
env.getFlinkVersion().version());
 
         // 2) check env
         boolean envOk = applicationInfoService.checkEnv(app);
-        ApiAlertException.throwIfFalse(
-            envOk, "Check flink env failed, please check the flink version of 
this job");
+        ApiAlertException.throwIfFalse(envOk, checkEnvErrorMessage);
 
         // 3) Whether the application can currently start a new building 
progress
         ApiAlertException.throwIfTrue(
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkEnvServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkEnvServiceImpl.java
index b26521a25..b8ffbafea 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkEnvServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkEnvServiceImpl.java
@@ -139,6 +139,9 @@ public class FlinkEnvServiceImpl extends 
ServiceImpl<FlinkEnvMapper, FlinkEnv>
 
     @Override
     public FlinkEnv getByIdOrDefault(Long id) {
+        if (id == null) {
+            return getDefault();
+        }
         FlinkEnv flinkEnv = getById(id);
         return flinkEnv == null ? getDefault() : flinkEnv;
     }

Reply via email to