From f78a7c8c859f55df004423dd20b92dadd1a64f80 Mon Sep 17 00:00:00 2001 From: Ondro Mihalyi Date: Sun, 3 Mar 2024 14:26:58 +0100 Subject: [PATCH] Throw exception so that it has to be handled or logged. To avoid that the exception is swallowed in case there's no ManagedTask listener. Also add the original exception as the cause to add it to the stacktrace. Signed-off-by:Ondro Mihalyi --- .../enterprise/concurrent/internal/ManagedFutureTask.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/glassfish/enterprise/concurrent/internal/ManagedFutureTask.java b/src/main/java/org/glassfish/enterprise/concurrent/internal/ManagedFutureTask.java index 565f147..2960d9b 100644 --- a/src/main/java/org/glassfish/enterprise/concurrent/internal/ManagedFutureTask.java +++ b/src/main/java/org/glassfish/enterprise/concurrent/internal/ManagedFutureTask.java @@ -245,13 +245,14 @@ public String getTaskIdentityName() { private void abort() { // Context handle not in valid state, throws AbortedException and // do not run the task - AbortedException ex = new AbortedException(contextSetupException.getMessage()); + AbortedException ex = new AbortedException(contextSetupException.getMessage(), contextSetupException); setException(ex); if (taskListener != null) { // notify listener. No need to set context here as it wouldn't work // anyway taskListener.taskAborted(this, executor.getExecutorForTaskListener(), task, ex); } + throw new RuntimeException(ex); } }