From 8f1744d71891171a614aec758e7534f872b86351 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 17 Dec 2024 17:24:20 +0100 Subject: [PATCH] LDEV-5206 cleanup, avoid possible NPE --- .../java/lucee/runtime/engine/ConsoleExecutionLog.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/lucee/runtime/engine/ConsoleExecutionLog.java b/core/src/main/java/lucee/runtime/engine/ConsoleExecutionLog.java index e034027b14..b86d9ae498 100644 --- a/core/src/main/java/lucee/runtime/engine/ConsoleExecutionLog.java +++ b/core/src/main/java/lucee/runtime/engine/ConsoleExecutionLog.java @@ -26,8 +26,8 @@ import lucee.commons.io.res.util.ResourceSnippet; import lucee.commons.io.res.util.ResourceSnippetsMap; import lucee.runtime.PageContext; +import lucee.runtime.PageSource; import lucee.runtime.PageContextImpl; -import lucee.runtime.functions.math.Int; import lucee.runtime.op.Caster; public class ConsoleExecutionLog extends ExecutionLogSupport { @@ -52,11 +52,12 @@ protected void _init(PageContext pc, Map arguments) { @Override protected void _log(int startPos, int endPos, long startTime, long endTime) { - + PageSource ps = pc.getCurrentPageSource(null); + if (ps == null) return; long diff = endTime - startTime; - String log = pc.getId() + ":" + pc.getCurrentPageSource().getDisplayPath() + ":"; + String log = pc.getId() + ":" + ps.getDisplayPath() + ":"; if (snippet) { - ResourceSnippet snippet = snippetsMap.getSnippet(pc.getCurrentPageSource(), startPos, endPos, ((PageContextImpl) pc).getResourceCharset().name()); + ResourceSnippet snippet = snippetsMap.getSnippet(ps, startPos, endPos, ((PageContextImpl) pc).getResourceCharset().name()); log += positions(snippet.getEndLine(), snippet.getEndLine()) + " > " + timeLongToString(diff) + " [" + snippet.getContent() + "]"; } else { log += positions(startPos, endPos) + " > " + timeLongToString(diff);