Skip to content

Commit ffd59bf

Browse files
committed
LDEV-6086 avoid killing the parent request
1 parent d6da9eb commit ffd59bf

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

core/src/main/java/lucee/runtime/functions/system/InternalRequest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
import lucee.runtime.config.Config;
2727
import lucee.runtime.engine.ThreadLocalPageContext;
2828
import lucee.runtime.exp.Abort;
29+
import lucee.runtime.exp.ApplicationException;
2930
import lucee.runtime.exp.FunctionException;
31+
import lucee.runtime.exp.RequestTimeoutException;
3032
import lucee.runtime.exp.PageException;
3133
import lucee.runtime.ext.function.Function;
3234
import lucee.runtime.functions.other.CreatePageContext;
@@ -135,7 +137,15 @@ else if (body != null) {
135137
catch (Throwable t) {
136138
ExceptionUtil.rethrowIfNecessary(t);
137139
if (!Abort.isSilentAbort(t)) {
138-
if (throwonerror) throw Caster.toPageException(t);
140+
if (throwonerror) {
141+
// wrap RequestTimeoutException so it doesn't kill the parent request
142+
if (t instanceof RequestTimeoutException) {
143+
ApplicationException ae = new ApplicationException(t.getMessage());
144+
ae.initCause(t);
145+
throw ae;
146+
}
147+
throw Caster.toPageException(t);
148+
}
139149
pe = Caster.toPageException(t);
140150
}
141151
}

test/tickets/LDEV6086.cfc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="internalRequest" {
1313
throwonerror: false
1414
);
1515
expect( result ).toHaveKey( "error" );
16-
expect( result.error.type ).toBe( "lucee.runtime.exp.RequestTimeoutException" );
16+
expect( result.error.message ).toInclude( "timeout" );
1717
});
1818

19-
it( title="InternalRequest should throw RequestTimeoutException with throwonerror=true", body=function() {
20-
expect( function() {
19+
it( title="InternalRequest should throw with throwonerror=true on RequestTimeoutException", body=function() {
20+
try {
2121
_InternalRequest(
2222
template: "#variables.uri#/timeout.cfm",
2323
throwonerror: true
2424
);
25-
}).toThrow( "lucee.runtime.exp.RequestTimeoutException" );
25+
fail( "expected exception was not thrown" );
26+
}
27+
catch ( application e ) {
28+
// wrapped in ApplicationException so it doesn't kill the parent request
29+
expect( e.message ).toInclude( "timeout" );
30+
}
2631
});
2732

2833
});

0 commit comments

Comments
 (0)