Expose shutdown state in TaskRejectedException message

See gh-27090
This commit is contained in:
Juergen Hoeller
2023-07-07 23:59:10 +02:00
parent ac11b03cd3
commit 464b676ec5
5 changed files with 52 additions and 33 deletions

View File

@@ -206,7 +206,7 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
}
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(this.scheduledExecutor, task, ex);
}
}
@@ -217,7 +217,7 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
return this.scheduledExecutor.schedule(decorateTask(task, false), NANO.convert(delay), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(this.scheduledExecutor, task, ex);
}
}
@@ -229,7 +229,7 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
NANO.convert(initialDelay), NANO.convert(period), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(this.scheduledExecutor, task, ex);
}
}
@@ -240,7 +240,7 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
0, NANO.convert(period), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(this.scheduledExecutor, task, ex);
}
}
@@ -252,7 +252,7 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
NANO.convert(initialDelay), NANO.convert(delay), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(this.scheduledExecutor, task, ex);
}
}
@@ -263,7 +263,7 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
0, NANO.convert(delay), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(this.scheduledExecutor, task, ex);
}
}

View File

@@ -362,7 +362,7 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
executor.execute(task);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -373,7 +373,7 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
return executor.submit(task);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -384,7 +384,7 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
return executor.submit(task);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -397,7 +397,7 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
return future;
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -410,7 +410,7 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
return future;
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}

View File

@@ -290,7 +290,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
executor.execute(errorHandlingTask(task, false));
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -301,7 +301,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
return executor.submit(errorHandlingTask(task, false));
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -317,7 +317,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
return executor.submit(taskToUse);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -330,7 +330,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
return listenableFuture;
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -343,7 +343,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
return listenableFuture;
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -379,7 +379,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
return new ReschedulingRunnable(task, trigger, this.clock, executor, errorHandler).schedule();
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -391,7 +391,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
return executor.schedule(errorHandlingTask(task, false), NANO.convert(delay), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -404,7 +404,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
NANO.convert(initialDelay), NANO.convert(period), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -416,7 +416,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
0, NANO.convert(period), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -429,7 +429,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
NANO.convert(initialDelay), NANO.convert(delay), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}
@@ -441,7 +441,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
0, NANO.convert(delay), NANO);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
throw new TaskRejectedException(executor, task, ex);
}
}