Skip to content

Commit

Permalink
improve `initCauseEL to handle if there is already a cause
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Oct 18, 2024
1 parent bd30f54 commit 43d065f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
17 changes: 13 additions & 4 deletions core/src/main/java/lucee/commons/lang/ExceptionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@
import java.util.Iterator;

import lucee.commons.io.SystemUtil.TemplateLine;
import lucee.commons.io.log.LogUtil;
import lucee.commons.io.res.Resource;
import lucee.commons.io.res.util.ResourceUtil;
import lucee.runtime.ComponentImpl;
import lucee.runtime.PageContext;
import lucee.runtime.PageContextImpl;
import lucee.runtime.PageSource;
import lucee.runtime.config.Config;
import lucee.runtime.config.ConfigWeb;
import lucee.runtime.exp.ApplicationException;
import lucee.runtime.exp.ExpressionException;
Expand Down Expand Up @@ -299,11 +297,22 @@ public static FileNotFoundException toFileNotFoundException(NoSuchFileException

public static void initCauseEL(Throwable e, Throwable cause) {
if (cause == null) return;

// get current root cause
Throwable tmp;
int count = 100;
do {
if (--count <= 0) break; // in case cause point to a child
tmp = e.getCause();
if (tmp == null) break;
e = tmp;
}
while (true);
// attach to root cause
try {
e.initCause(cause);
}
catch (IllegalStateException ise) { // avoid: Can't overwrite cause with ...
LogUtil.log((Config) null, "exception", cause);
catch (Exception ex) {
}
}

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.1.103-SNAPSHOT"/>
<property name="version" value="6.1.1.104-SNAPSHOT"/>

<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.1.103-SNAPSHOT</version>
<version>6.1.1.104-SNAPSHOT</version>
<packaging>jar</packaging>

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

0 comments on commit 43d065f

Please sign in to comment.