Skip to content

Commit dc76efd

Browse files
committed
LDEV-6449 fix getDisplayPath() returning null in debugger
- Ensure PageSourceImpl.getDisplayPath() never returns null by providing fallbacks (archive path or relPath) when physical file doesn't exist - Add defensive null/empty check in DebuggerImpl.writeOut() before calling getPageSources() - Fixes NullPointerException: Cannot invoke String.replace() because realPath is null
1 parent 237b5d4 commit dc76efd

4 files changed

Lines changed: 28 additions & 23 deletions

File tree

core/src/main/java/lucee/runtime/PageSourceImpl.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,16 @@ public String getDisplayPath() {
535535
if (dspPath != null) return dspPath;
536536

537537
if (!mapping.hasArchive()) {
538-
return dspPath = StringUtil.toString(getPhyscalFile(), null);
538+
String result = StringUtil.toString(getPhyscalFile(), null);
539+
return dspPath = result != null ? result : relPath;
539540
}
540541
else if (isLoad(LOAD_PHYSICAL)) {
541-
return dspPath = StringUtil.toString(getPhyscalFile(), null);
542+
String result = StringUtil.toString(getPhyscalFile(), null);
543+
return dspPath = result != null ? result : getArchiveSourcePath();
542544
}
543545
else if (isLoad(LOAD_ARCHIVE)) {
544-
return dspPath = StringUtil.toString(getArchiveSourcePath(), null);
546+
String result = StringUtil.toString(getArchiveSourcePath(), null);
547+
return dspPath = result != null ? result : relPath;
545548
}
546549
else {
547550
boolean pse = physcalExists();
@@ -550,11 +553,11 @@ else if (isLoad(LOAD_ARCHIVE)) {
550553
if (mapping.isPhysicalFirst()) {
551554
if (pse) return dspPath = getPhyscalFile().toString();
552555
else if (ase) return dspPath = getArchiveSourcePath();
553-
return dspPath = getPhyscalFile().toString();
556+
return dspPath = relPath;
554557
}
555558
if (ase) return dspPath = getArchiveSourcePath();
556559
else if (pse) return dspPath = getPhyscalFile().toString();
557-
return dspPath = getArchiveSourcePath();
560+
return dspPath = relPath;
558561
}
559562
}
560563

core/src/main/java/lucee/runtime/debug/DebuggerImpl.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -384,23 +384,25 @@ public void writeOut(PageContext pc) throws IOException {
384384

385385
// load Pagesource of the template
386386
String path = debugEntry.getPath();
387-
PageSource[] arr = ((PageContextImpl) pc).getPageSources(path);
388-
Page p = PageSourceImpl.loadPage(pc, arr, null);
389-
390-
String fullname = debugEntry.getFullname();
391-
if (p != null) {
392-
arr = ((PageContextImpl) pc).getPageSources(path);
393-
p = PageSourceImpl.loadPage(pc, arr);
394-
pc.addPageSource(p.getPageSource(), true);
395-
// load info with debug template
396-
try {
397-
Component c = pc.loadComponent(fullname);
398-
ModernAppListener.info(pc, c, args);
387+
if (!StringUtil.isEmpty(path)) {
388+
PageSource[] arr = ((PageContextImpl) pc).getPageSources(path);
389+
Page p = PageSourceImpl.loadPage(pc, arr, null);
390+
391+
String fullname = debugEntry.getFullname();
392+
if (p != null) {
393+
arr = ((PageContextImpl) pc).getPageSources(path);
394+
p = PageSourceImpl.loadPage(pc, arr);
395+
pc.addPageSource(p.getPageSource(), true);
396+
// load info with debug template
397+
try {
398+
Component c = pc.loadComponent(fullname);
399+
ModernAppListener.info(pc, c, args);
400+
}
401+
finally {
402+
pc.removeLastPageSource(true);
403+
}
404+
return;
399405
}
400-
finally {
401-
pc.removeLastPageSource(true);
402-
}
403-
return;
404406
}
405407
}
406408
}

loader/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<project default="core" basedir="." name="Lucee"
33
xmlns:resolver="antlib:org.apache.maven.resolver.ant">
44

5-
<property name="version" value="8.0.0.173-SNAPSHOT"/>
5+
<property name="version" value="8.0.0.174-SNAPSHOT"/>
66

77
<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
88
<classpath>

loader/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>org.lucee</groupId>
55
<artifactId>lucee</artifactId>
6-
<version>8.0.0.173-SNAPSHOT</version>
6+
<version>8.0.0.174-SNAPSHOT</version>
77
<packaging>jar</packaging>
88

99
<name>Lucee Loader Build</name>

0 commit comments

Comments
 (0)