} catch (Throwable e) {
result.addFailureMessage(ThrowableUtil.getAllMessages(e, true, remainingResultSize(result)));
return result;
} finally {
if (subjectWithSession != null) {
sessionManager.invalidate(subjectWithSession.getSessionId());
}
if (engine != null) {
returnEngine(engine, language);
}