Browse Source

Merge branch '6.1.x'

pull/32467/head
Juergen Hoeller 2 years ago
parent
commit
2086cda296
  1. 14
      spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutor.java
  2. 8
      spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java

14
spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutor.java

@ -143,11 +143,6 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche @@ -143,11 +143,6 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
* execution callback (which may be a wrapper around the user-supplied task).
* <p>The primary use case is to set some execution context around the task's
* invocation, or to provide some monitoring/statistics for task execution.
* <p><b>NOTE:</b> Exception handling in {@code TaskDecorator} implementations
* is limited to plain {@code Runnable} execution via {@code execute} calls.
* In case of {@code #submit} calls, the exposed {@code Runnable} will be a
* {@code FutureTask} which does not propagate any exceptions; you might
* have to cast it and call {@code Future#get} to evaluate exceptions.
* @since 4.3
*/
public final void setTaskDecorator(TaskDecorator taskDecorator) {
@ -188,11 +183,10 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche @@ -188,11 +183,10 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
}
private TaskExecutorAdapter getAdaptedExecutor(Executor concurrentExecutor) {
if (managedExecutorServiceClass != null && managedExecutorServiceClass.isInstance(concurrentExecutor)) {
return new ManagedTaskExecutorAdapter(concurrentExecutor);
}
TaskExecutorAdapter adapter = new TaskExecutorAdapter(concurrentExecutor);
private TaskExecutorAdapter getAdaptedExecutor(Executor originalExecutor) {
TaskExecutorAdapter adapter =
(managedExecutorServiceClass != null && managedExecutorServiceClass.isInstance(originalExecutor) ?
new ManagedTaskExecutorAdapter(originalExecutor) : new TaskExecutorAdapter(originalExecutor));
if (this.taskDecorator != null) {
adapter.setTaskDecorator(this.taskDecorator);
}

8
spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
package org.springframework.scheduling.concurrent;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@ -52,8 +52,8 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests { @@ -52,8 +52,8 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
@AfterEach
void shutdownExecutor() {
for (Runnable task : concurrentExecutor.shutdownNow()) {
if (task instanceof RunnableFuture) {
((RunnableFuture<?>) task).cancel(true);
if (task instanceof Future) {
((Future<?>) task).cancel(true);
}
}
}

Loading…
Cancel
Save