You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/10/17 02:13:52 UTC

[GitHub] [dolphinscheduler] rickchengx commented on a diff in pull request #12358: [Fix-12356][k8s] fix the null exception when submitting k8s task plugin

rickchengx commented on code in PR #12358:
URL: https://github.com/apache/dolphinscheduler/pull/12358#discussion_r996558897


##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java:
##########
@@ -3169,10 +3169,11 @@ public String findConfigYamlByName(String clusterName) {
         if (Strings.isNullOrEmpty(clusterName)) {
             return null;
         }
-        QueryWrapper<K8s> nodeWrapper = new QueryWrapper<>();
-        nodeWrapper.eq("k8s_name", clusterName);
-        K8s k8s = k8sMapper.selectOne(nodeWrapper);
-        return k8s.getK8sConfig();
+
+        QueryWrapper<Cluster> nodeWrapper = new QueryWrapper<>();
+        nodeWrapper.eq("name", clusterName);
+        Cluster cluster = clusterMapper.selectOne(nodeWrapper);
+        return cluster.getConfig();

Review Comment:
   > It's better to write a sql rather than use `QueryWrapper`, and when the cluster is null here we might better return null rather than NPE?
   
   Hi, @ruanwenjun , thanks for the comment.
   
   1. I've changed `return cluster.getConfig();` to `return cluster == null ? null : cluster.getConfig();` to avoid the potential NPE.
   2. As for writing a SQL rather than using `QueryWrapper`, maybe we could do it in another PR? Since `QueryWrapper` is also used in many other places. And this NPE bug will cause the user cannot submit k8s tasks. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org