Skip to content

Commit

Permalink
LDEV-438 - do not use CatchBlock cond^structor because it bypass Cust…
Browse files Browse the repository at this point in the history
…omType additions
  • Loading branch information
michaeloffner committed Oct 2, 2023
1 parent e54d767 commit 7da61c9
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 19 deletions.
14 changes: 6 additions & 8 deletions core/src/main/java/lucee/runtime/exp/CatchBlockImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import lucee.commons.lang.StringUtil;
import lucee.runtime.PageContext;
import lucee.runtime.PageContextImpl;
import lucee.runtime.config.Config;
import lucee.runtime.dump.DumpData;
import lucee.runtime.dump.DumpProperties;
import lucee.runtime.engine.ThreadLocalPageContext;
Expand Down Expand Up @@ -68,11 +69,8 @@ public class CatchBlockImpl extends StructImpl implements CatchBlock, Castable,

private final PageException exception;

public CatchBlockImpl(PageException pe) {
this(pe, 0);
}

private CatchBlockImpl(PageException pe, int level) {
CatchBlockImpl(PageException pe, int level) {
if (level < 0) level = 0;
this.exception = pe;

setEL(KeyConstants._Message, new SpecialItem(KeyConstants._Message, level));
Expand Down Expand Up @@ -121,7 +119,7 @@ public SpecialItem(Key key, int level) {

public Object get() {
if (level < MAX) {
if (key == CAUSE) return getCauseAsCatchBlock();
if (key == CAUSE) return getCauseAsCatchBlock(ThreadLocalPageContext.getConfig());
if (key == ADDITIONAL) return exception.getAdditional();

}
Expand All @@ -136,11 +134,11 @@ public Object get() {
return null;
}

private CatchBlock getCauseAsCatchBlock() {
private CatchBlock getCauseAsCatchBlock(Config config) {
Throwable cause = exception.getCause();
if (cause == null || exception == cause) return null;
if (exception instanceof NativeException && ((NativeException) exception).getException() == cause) return null;
return new CatchBlockImpl(NativeException.newInstance(cause), level + 1);
return Caster.toPageException(cause).getCatchBlock(config);
}

public void set(Object o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public final Struct getCatchBlock(PageContext pc) {

@Override
public CatchBlock getCatchBlock(Config config) {
return new CatchBlockImpl(this);
return new CatchBlockImpl(this, 0);
}

public Array getTagContext(Config config) {
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/lucee/runtime/future/Future.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.exp.ApplicationException;
import lucee.runtime.exp.CasterException;
import lucee.runtime.exp.CatchBlockImpl;
import lucee.runtime.exp.ExpressionException;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.exp.PageException;
Expand Down Expand Up @@ -107,7 +106,7 @@ private Future handleExecutionError(PageContext pc, Exception e) throws PageExce

private Future executeErrorHandler(PageContext pc, UDF udf, long timeout, Exception e) {
ExecutorService executor = Executors.newSingleThreadExecutor();
return new Future(executor.submit(new CallableUDF(pc, udf, new CatchBlockImpl(Caster.toPageException(e)))), timeout);
return new Future(executor.submit(new CallableUDF(pc, udf, Caster.toPageException(e).getCatchBlock(ThreadLocalPageContext.getConfig(pc)))), timeout);
}

public boolean cancel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import lucee.runtime.config.Config;
import lucee.runtime.config.ConfigWeb;
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.exp.CatchBlockImpl;
import lucee.runtime.exp.PageException;
import lucee.runtime.op.Caster;
import lucee.runtime.spooler.mail.MailSpoolerTask;
Expand Down Expand Up @@ -67,7 +66,7 @@ public void listen(Config config, Exception e, boolean before) {
args.set("remainingtries", e == null ? 0 : task.getPlans().length - task.tries());
args.set("closed", task.closed());
if (!before) args.set("passed", e == null);
if (e != null) args.set("exception", new CatchBlockImpl(Caster.toPageException(e)));
if (e != null) args.set("exception", Caster.toPageException(e).getCatchBlock(cw));

Struct curr = new StructImpl();
args.set("caller", curr);
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/lucee/runtime/tag/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import lucee.runtime.engine.ThreadLocalPageContext;
import lucee.runtime.exp.ApplicationException;
import lucee.runtime.exp.CasterException;
import lucee.runtime.exp.CatchBlockImpl;
import lucee.runtime.exp.DatabaseException;
import lucee.runtime.exp.PageException;
import lucee.runtime.ext.tag.BodyTagTryCatchFinallyImpl;
Expand Down Expand Up @@ -787,7 +786,7 @@ else if ((queryResult.getColumncount() + queryResult.getRecordcount()) > 0 && !S
if (data.listener != null && data.listener.hasError()) {
long addExe = System.nanoTime();
Struct args = createArgStruct(data, strSQL, tl);
args.set(KeyConstants._exception, new CatchBlockImpl(pe));
args.set(KeyConstants._exception, pe.getCatchBlock(pageContext.getConfig()));
ResMeta rm = writeBackResult(pageContext, data, data.listener.error(pageContext, args), setVars);
if (data.result == null || (rm.meta == null && rm.asQueryResult() != null))
rm.meta = createMetaData(pageContext, data, rm.asQueryResult(), null, setVars, exe + (System.nanoTime() - addExe));
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/lucee/runtime/tag/Timeout.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import lucee.runtime.PageContextImpl;
import lucee.runtime.exp.Abort;
import lucee.runtime.exp.ApplicationException;
import lucee.runtime.exp.CatchBlockImpl;
import lucee.runtime.exp.PageException;
import lucee.runtime.ext.tag.BodyTagImpl;
import lucee.runtime.op.Caster;
Expand Down Expand Up @@ -119,7 +118,7 @@ private void handleException(ThreadImpl thread2) throws PageException {
if (ex != null) {
ex = CFMLEngineFactory.getInstance().getCastUtil().toPageException(new Exception(ex));

if (onError != null) onError.call(pc, new Object[] { new CatchBlockImpl(ex) }, true);
if (onError != null) onError.call(pc, new Object[] { ex.getCatchBlock(pageContext.getConfig()) }, true);
else throw 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.0.0.566-SNAPSHOT"/>
<property name="version" value="6.0.0.567-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.0.0.566-SNAPSHOT</version>
<version>6.0.0.567-SNAPSHOT</version>
<packaging>jar</packaging>

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

0 comments on commit 7da61c9

Please sign in to comment.