From 564a5e1095fffe1759b7f79b31a80ad87d5dce12 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Wed, 19 Jun 2024 16:48:05 -0500 Subject: [PATCH] Avoid NPE if adding a log line before the script header is set --- .../BuildScriptLogAndScriptLogLineExecutionLogger.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/scripts/logging/BuildScriptLogAndScriptLogLineExecutionLogger.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/scripts/logging/BuildScriptLogAndScriptLogLineExecutionLogger.java index d577425b..fda254e0 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/scripts/logging/BuildScriptLogAndScriptLogLineExecutionLogger.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/scripts/logging/BuildScriptLogAndScriptLogLineExecutionLogger.java @@ -94,7 +94,7 @@ public class BuildScriptLogAndScriptLogLineExecutionLogger implements QCodeExecu protected QRecord buildDetailLogRecord(String logLine) { return (new QRecord() - .withValue("scriptLogId", scriptLog.getValue("id")) + .withValue("scriptLogId", scriptLog == null ? null : scriptLog.getValue("id")) .withValue("timestamp", Instant.now()) .withValue("text", truncate(logLine))); } @@ -145,6 +145,14 @@ public class BuildScriptLogAndScriptLogLineExecutionLogger implements QCodeExecu { this.executeCodeInput = executeCodeInput; this.scriptLog = buildHeaderRecord(executeCodeInput); + + if(scriptLogLines != null) + { + for(QRecord scriptLogLine : scriptLogLines) + { + scriptLogLine.setValue("scriptLogId", scriptLog.getValue("id")); + } + } } catch(Exception e) {