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

changhaifu pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 308e4fb4a6 Directly Throw exception when taskInstancy log path is 
empty which log need to be queried (#15511)
308e4fb4a6 is described below

commit 308e4fb4a6cebacdb05ce39635f5a7d62345f10c
Author: Wenjun Ruan <[email protected]>
AuthorDate: Sat Jan 20 16:40:30 2024 +0800

    Directly Throw exception when taskInstancy log path is empty which log need 
to be queried (#15511)
---
 .../main/java/org/apache/dolphinscheduler/api/enums/Status.java    | 2 +-
 .../dolphinscheduler/api/service/impl/LoggerServiceImpl.java       | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
index ce406519e6..f84f79847c 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
@@ -131,7 +131,7 @@ public enum Status {
     VERIFY_USERNAME_ERROR(10100, "verify username error", "用户名验证错误"),
     UNAUTHORIZED_USER_ERROR(10101, "unauthorized user error", "查询未授权用户错误"),
     AUTHORIZED_USER_ERROR(10102, "authorized user error", "查询授权用户错误"),
-    QUERY_TASK_INSTANCE_LOG_ERROR(10103, "view task instance log error", 
"查询任务实例日志错误"),
+    QUERY_TASK_INSTANCE_LOG_ERROR(10103, "view task instance log error: {0}", 
"查询任务实例日志错误: {0}"),
     DOWNLOAD_TASK_INSTANCE_LOG_FILE_ERROR(10104, "download task instance log 
file error", "下载任务日志文件错误"),
     CREATE_PROCESS_DEFINITION_ERROR(10105, "create process definition error", 
"创建工作流错误"),
     VERIFY_PROCESS_DEFINITION_NAME_UNIQUE_ERROR(10106, "verify process 
definition name unique error", "工作流定义名称验证错误"),
diff --git 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java
 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java
index e9222c715e..0663b88374 100644
--- 
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java
+++ 
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java
@@ -188,6 +188,11 @@ public class LoggerServiceImpl extends BaseServiceImpl 
implements LoggerService
         final String logPath = taskInstance.getLogPath();
         log.info("Query task instance log, taskInstanceId:{}, 
taskInstanceName:{}, host: {}, logPath:{}",
                 taskInstance.getId(), taskInstance.getName(), 
taskInstance.getHost(), logPath);
+        if (StringUtils.isBlank(logPath)) {
+            throw new ServiceException(Status.QUERY_TASK_INSTANCE_LOG_ERROR,
+                    "TaskInstanceLogPath is empty, maybe the taskInstance 
doesn't be dispatched");
+        }
+
         StringBuilder sb = new StringBuilder();
         if (skipLineNum == 0) {
             String head = String.format(LOG_HEAD_FORMAT,
@@ -213,7 +218,7 @@ public class LoggerServiceImpl extends BaseServiceImpl 
implements LoggerService
             }
             return sb.toString();
         } catch (Throwable ex) {
-            throw new ServiceException(Status.QUERY_TASK_INSTANCE_LOG_ERROR, 
ex);
+            throw new ServiceException(Status.QUERY_TASK_INSTANCE_LOG_ERROR, 
ex.getMessage(), ex);
         }
     }
 

Reply via email to