Skip to content

Commit

Permalink
LDEV-5206 cleanup, avoid possible NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Dec 17, 2024
1 parent 3b336c7 commit 020bfdd
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -52,11 +52,12 @@ protected void _init(PageContext pc, Map<String, String> 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);
Expand Down

0 comments on commit 020bfdd

Please sign in to comment.