Skip to content

Commit

Permalink
LDEV-2230 - improve getting template path
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Feb 9, 2024
1 parent 22b38f0 commit 6612b5d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
41 changes: 26 additions & 15 deletions core/src/main/java/lucee/runtime/exp/PageExceptionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,27 +594,38 @@ public static String toString(PageContext pc, StackTraceElement trace) {
if (trace.getFileName() == null || trace.getFileName().endsWith(".java")) return trace.toString();
Config config = ThreadLocalPageContext.getConfig(pc);
if (config != null) {
Resource res = pc.getConfig().getResource(trace.getFileName());
if (res.exists()) path = trace.getFileName();

// get path from source
if (path == null) {
SourceInfo si = MappingUtil.getMatch(pc, trace);
if (si != null) {
if (si.absolutePath(pc) != null) {
res = pc.getConfig().getResource(si.absolutePath(pc));
if (res.exists()) path = si.absolutePath(pc);
}
if (path == null && si.relativePath != null) path = si.relativePath;
}
if (path == null) path = trace.getFileName();
}
path = abs((PageContextImpl) pc, config, trace.getFileName());
/*
* Resource res = pc.getConfig().getResource(trace.getFileName()); if (res.exists()) path =
* trace.getFileName();
*
* // get path from source if (path == null) { SourceInfo si = MappingUtil.getMatch(pc, trace); if
* (si != null) { if (si.absolutePath(pc) != null) { res =
* pc.getConfig().getResource(si.absolutePath(pc)); if (res.exists()) path = si.absolutePath(pc); }
* if (path == null && si.relativePath != null) path = si.relativePath; } if (path == null) path =
* trace.getFileName(); }
*/
}
return trace.getClassName() + "." + trace.getMethodName() + (trace.isNativeMethod() ? "(Native Method)"
: (path != null && trace.getLineNumber() >= 0 ? "(" + path + ":" + trace.getLineNumber() + ")" : (path != null ? "(" + path + ")" : "(Unknown Source)")));

}

private static String abs(PageContextImpl pci, Config config, String template) {

Resource res = config.getResource(template);
if (res.exists()) return template;

PageSource ps = pci == null ? null : pci.getPageSource(template);
res = ps == null ? null : ps.getPhyscalFile();
if (res == null || !res.exists()) {
res = config.getResource(ps.getDisplayPath());
if (res != null && res.exists()) return res.getAbsolutePath();
}
else return res.getAbsolutePath();
return template;
}

private static StackTraceElement[] getStackTraceElements(Throwable t) {
StackTraceElement[] st = getStackTraceElements(t, true);
if (st == null) st = getStackTraceElements(t, false);
Expand Down
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.1.0.29-BETA"/>
<property name="version" value="6.1.0.30-BETA"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.1.0.29-BETA</version>
<version>6.1.0.30-BETA</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down

0 comments on commit 6612b5d

Please sign in to comment.