Remove APIs marked as deprecated for removal
Closes gh-33809
This commit is contained in:
@@ -310,7 +310,6 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||
return new Object[] {event};
|
||||
}
|
||||
|
||||
@SuppressWarnings({"removal", "unchecked", "deprecation"})
|
||||
protected void handleResult(Object result) {
|
||||
if (reactiveStreamsPresent && new ReactiveResultHandler().subscribeToPublisher(result)) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
@@ -327,9 +326,6 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (result instanceof org.springframework.util.concurrent.ListenableFuture<?> listenableFuture) {
|
||||
listenableFuture.addCallback(this::publishEvents, this::handleAsyncError);
|
||||
}
|
||||
else {
|
||||
publishEvents(result);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,6 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.concurrent.FailureCallback;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureCallback;
|
||||
import org.springframework.util.concurrent.SuccessCallback;
|
||||
|
||||
/**
|
||||
* A pass-through {@code Future} handle that can be used for method signatures
|
||||
@@ -46,8 +42,7 @@ import org.springframework.util.concurrent.SuccessCallback;
|
||||
* @deprecated as of 6.0, in favor of {@link CompletableFuture}
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
@SuppressWarnings("removal")
|
||||
public class AsyncResult<V> implements ListenableFuture<V> {
|
||||
public class AsyncResult<V> implements Future<V> {
|
||||
|
||||
@Nullable
|
||||
private final V value;
|
||||
@@ -105,38 +100,6 @@ public class AsyncResult<V> implements ListenableFuture<V> {
|
||||
return get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCallback(ListenableFutureCallback<? super V> callback) {
|
||||
addCallback(callback, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCallback(SuccessCallback<? super V> successCallback, FailureCallback failureCallback) {
|
||||
try {
|
||||
if (this.executionException != null) {
|
||||
failureCallback.onFailure(exposedException(this.executionException));
|
||||
}
|
||||
else {
|
||||
successCallback.onSuccess(this.value);
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<V> completable() {
|
||||
if (this.executionException != null) {
|
||||
CompletableFuture<V> completable = new CompletableFuture<>();
|
||||
completable.completeExceptionally(exposedException(this.executionException));
|
||||
return completable;
|
||||
}
|
||||
else {
|
||||
return CompletableFuture.completedFuture(this.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new async result which exposes the given value from {@link Future#get()}.
|
||||
@@ -144,7 +107,7 @@ public class AsyncResult<V> implements ListenableFuture<V> {
|
||||
* @since 4.2
|
||||
* @see Future#get()
|
||||
*/
|
||||
public static <V> org.springframework.util.concurrent.ListenableFuture<V> forValue(V value) {
|
||||
public static <V> Future<V> forValue(V value) {
|
||||
return new AsyncResult<>(value, null);
|
||||
}
|
||||
|
||||
@@ -156,7 +119,7 @@ public class AsyncResult<V> implements ListenableFuture<V> {
|
||||
* @since 4.2
|
||||
* @see ExecutionException
|
||||
*/
|
||||
public static <V> org.springframework.util.concurrent.ListenableFuture<V> forExecutionException(Throwable ex) {
|
||||
public static <V> Future<V> forExecutionException(Throwable ex) {
|
||||
return new AsyncResult<>(null, ex);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,14 +26,13 @@ import java.util.concurrent.Future;
|
||||
import jakarta.enterprise.concurrent.ManagedExecutors;
|
||||
import jakarta.enterprise.concurrent.ManagedTask;
|
||||
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskDecorator;
|
||||
import org.springframework.core.task.support.TaskExecutorAdapter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.SchedulingAwareRunnable;
|
||||
import org.springframework.scheduling.SchedulingTaskExecutor;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Adapter that takes a {@code java.util.concurrent.Executor} and exposes
|
||||
@@ -62,8 +61,8 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
* @see DefaultManagedTaskExecutor
|
||||
* @see ThreadPoolTaskExecutor
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, SchedulingTaskExecutor {
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ConcurrentTaskExecutor implements AsyncTaskExecutor, SchedulingTaskExecutor {
|
||||
|
||||
private static final Executor STUB_EXECUTOR = (task -> {
|
||||
throw new IllegalStateException("Executor not configured");
|
||||
@@ -172,16 +171,6 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
|
||||
return this.adaptedExecutor.submit(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<?> submitListenable(Runnable task) {
|
||||
return this.adaptedExecutor.submitListenable(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
|
||||
return this.adaptedExecutor.submitListenable(task);
|
||||
}
|
||||
|
||||
|
||||
private TaskExecutorAdapter getAdaptedExecutor(Executor originalExecutor) {
|
||||
TaskExecutorAdapter adapter =
|
||||
@@ -224,16 +213,6 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche
|
||||
public <T> Future<T> submit(Callable<T> task) {
|
||||
return super.submit(ManagedTaskBuilder.buildManagedTask(task, task.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<?> submitListenable(Runnable task) {
|
||||
return super.submitListenable(ManagedTaskBuilder.buildManagedTask(task, task.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
|
||||
return super.submitListenable(ManagedTaskBuilder.buildManagedTask(task, task.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -218,18 +218,6 @@ public class ConcurrentTaskScheduler extends ConcurrentTaskExecutor implements T
|
||||
return super.submit(new DelegatingErrorHandlingCallable<>(task, this.errorHandler));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
@Override
|
||||
public org.springframework.util.concurrent.ListenableFuture<?> submitListenable(Runnable task) {
|
||||
return super.submitListenable(TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, false));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
@Override
|
||||
public <T> org.springframework.util.concurrent.ListenableFuture<T> submitListenable(Callable<T> task) {
|
||||
return super.submitListenable(new DelegatingErrorHandlingCallable<>(task, this.errorHandler));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
|
||||
|
||||
@@ -269,18 +269,6 @@ public class SimpleAsyncTaskScheduler extends SimpleAsyncTaskExecutor implements
|
||||
return super.submit(new DelegatingErrorHandlingCallable<>(task, this.errorHandler));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
@Override
|
||||
public org.springframework.util.concurrent.ListenableFuture<?> submitListenable(Runnable task) {
|
||||
return super.submitListenable(TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, false));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
@Override
|
||||
public <T> org.springframework.util.concurrent.ListenableFuture<T> submitListenable(Callable<T> task) {
|
||||
return super.submitListenable(new DelegatingErrorHandlingCallable<>(task, this.errorHandler));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
|
||||
|
||||
@@ -30,15 +30,13 @@ import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskDecorator;
|
||||
import org.springframework.core.task.TaskRejectedException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.SchedulingTaskExecutor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureTask;
|
||||
|
||||
/**
|
||||
* JavaBean that allows for configuring a {@link java.util.concurrent.ThreadPoolExecutor}
|
||||
@@ -80,9 +78,9 @@ import org.springframework.util.concurrent.ListenableFutureTask;
|
||||
* @see ThreadPoolExecutorFactoryBean
|
||||
* @see ConcurrentTaskExecutor
|
||||
*/
|
||||
@SuppressWarnings({"serial", "deprecation", "removal"})
|
||||
@SuppressWarnings({"serial", "deprecation"})
|
||||
public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
|
||||
implements AsyncListenableTaskExecutor, SchedulingTaskExecutor {
|
||||
implements AsyncTaskExecutor, SchedulingTaskExecutor {
|
||||
|
||||
private final Object poolSizeMonitor = new Object();
|
||||
|
||||
@@ -414,32 +412,6 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<?> submitListenable(Runnable task) {
|
||||
ExecutorService executor = getThreadPoolExecutor();
|
||||
try {
|
||||
ListenableFutureTask<Object> future = new ListenableFutureTask<>(task, null);
|
||||
executor.execute(future);
|
||||
return future;
|
||||
}
|
||||
catch (RejectedExecutionException ex) {
|
||||
throw new TaskRejectedException(executor, task, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
|
||||
ExecutorService executor = getThreadPoolExecutor();
|
||||
try {
|
||||
ListenableFutureTask<T> future = new ListenableFutureTask<>(task);
|
||||
executor.execute(future);
|
||||
return future;
|
||||
}
|
||||
catch (RejectedExecutionException ex) {
|
||||
throw new TaskRejectedException(executor, task, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelRemainingTask(Runnable task) {
|
||||
super.cancelRemainingTask(task);
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.scheduling.concurrent;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Delayed;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -36,7 +35,7 @@ import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskDecorator;
|
||||
import org.springframework.core.task.TaskRejectedException;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -45,10 +44,7 @@ import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.support.TaskUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.util.concurrent.ListenableFutureTask;
|
||||
|
||||
/**
|
||||
* A standard implementation of Spring's {@link TaskScheduler} interface, wrapping
|
||||
@@ -74,9 +70,9 @@ import org.springframework.util.concurrent.ListenableFutureTask;
|
||||
* @see ThreadPoolTaskExecutor
|
||||
* @see SimpleAsyncTaskScheduler
|
||||
*/
|
||||
@SuppressWarnings({"serial", "deprecation", "removal"})
|
||||
@SuppressWarnings({"serial", "deprecation"})
|
||||
public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
implements AsyncListenableTaskExecutor, SchedulingTaskExecutor, TaskScheduler {
|
||||
implements AsyncTaskExecutor, SchedulingTaskExecutor, TaskScheduler {
|
||||
|
||||
private static final TimeUnit NANO = TimeUnit.NANOSECONDS;
|
||||
|
||||
@@ -100,10 +96,6 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
@Nullable
|
||||
private ScheduledExecutorService scheduledExecutor;
|
||||
|
||||
// Underlying ScheduledFutureTask to user-level ListenableFuture handle, if any
|
||||
private final Map<Object, ListenableFuture<?>> listenableFutureMap =
|
||||
new ConcurrentReferenceHashMap<>(16, ConcurrentReferenceHashMap.ReferenceType.WEAK);
|
||||
|
||||
|
||||
/**
|
||||
* Set the ScheduledExecutorService's pool size.
|
||||
@@ -357,49 +349,6 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<?> submitListenable(Runnable task) {
|
||||
ExecutorService executor = getScheduledExecutor();
|
||||
try {
|
||||
ListenableFutureTask<Object> listenableFuture = new ListenableFutureTask<>(task, null);
|
||||
executeAndTrack(executor, listenableFuture);
|
||||
return listenableFuture;
|
||||
}
|
||||
catch (RejectedExecutionException ex) {
|
||||
throw new TaskRejectedException(executor, task, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
|
||||
ExecutorService executor = getScheduledExecutor();
|
||||
try {
|
||||
ListenableFutureTask<T> listenableFuture = new ListenableFutureTask<>(task);
|
||||
executeAndTrack(executor, listenableFuture);
|
||||
return listenableFuture;
|
||||
}
|
||||
catch (RejectedExecutionException ex) {
|
||||
throw new TaskRejectedException(executor, task, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void executeAndTrack(ExecutorService executor, ListenableFutureTask<?> listenableFuture) {
|
||||
Future<?> scheduledFuture = executor.submit(errorHandlingTask(listenableFuture, false));
|
||||
this.listenableFutureMap.put(scheduledFuture, listenableFuture);
|
||||
listenableFuture.addCallback(result -> this.listenableFutureMap.remove(scheduledFuture),
|
||||
ex -> this.listenableFutureMap.remove(scheduledFuture));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelRemainingTask(Runnable task) {
|
||||
super.cancelRemainingTask(task);
|
||||
// Cancel associated user-level ListenableFuture handle as well
|
||||
ListenableFuture<?> listenableFuture = this.listenableFutureMap.get(task);
|
||||
if (listenableFuture != null) {
|
||||
listenableFuture.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TaskScheduler implementation
|
||||
|
||||
|
||||
@@ -81,19 +81,6 @@ public interface MethodValidationResult {
|
||||
*/
|
||||
List<ParameterValidationResult> getParameterValidationResults();
|
||||
|
||||
/**
|
||||
* Return all validation results. This includes both method parameters with
|
||||
* errors directly on them, and Object method parameters with nested errors
|
||||
* on their fields and properties.
|
||||
* @see #getValueResults()
|
||||
* @see #getBeanResults()
|
||||
* @deprecated deprecated in favor of {@link #getParameterValidationResults()}
|
||||
*/
|
||||
@Deprecated(since = "6.2", forRemoval = true)
|
||||
default List<ParameterValidationResult> getAllValidationResults() {
|
||||
return getParameterValidationResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the subset of {@link #getParameterValidationResults() allValidationResults}
|
||||
* that includes method parameters with validation errors directly on method
|
||||
|
||||
@@ -85,35 +85,6 @@ public class ParameterValidationResult {
|
||||
this.sourceLookup = sourceLookup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@code ParameterValidationResult}.
|
||||
* @deprecated in favor of
|
||||
* {@link ParameterValidationResult#ParameterValidationResult(MethodParameter, Object, Collection, Object, Integer, Object, BiFunction)}
|
||||
*/
|
||||
@Deprecated(since = "6.2", forRemoval = true)
|
||||
public ParameterValidationResult(
|
||||
MethodParameter param, @Nullable Object arg, Collection<? extends MessageSourceResolvable> errors,
|
||||
@Nullable Object container, @Nullable Integer index, @Nullable Object key) {
|
||||
|
||||
this(param, arg, errors, container, index, key, (error, sourceType) -> {
|
||||
throw new IllegalArgumentException("No source object of the given type");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@code ParameterValidationResult}.
|
||||
* @deprecated in favor of
|
||||
* {@link ParameterValidationResult#ParameterValidationResult(MethodParameter, Object, Collection, Object, Integer, Object, BiFunction)}
|
||||
*/
|
||||
@Deprecated(since = "6.1.3", forRemoval = true)
|
||||
public ParameterValidationResult(
|
||||
MethodParameter param, @Nullable Object arg, Collection<? extends MessageSourceResolvable> errors) {
|
||||
|
||||
this(param, arg, errors, null, null, null, (error, sourceType) -> {
|
||||
throw new IllegalArgumentException("No source object of the given type");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The method parameter the validation results are for.
|
||||
|
||||
@@ -279,25 +279,6 @@ class AnnotationDrivenEventListenerTests {
|
||||
this.eventCollector.assertTotalEventsCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
void listenableFutureReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
org.springframework.util.concurrent.SettableListenableFuture<String> future =
|
||||
new org.springframework.util.concurrent.SettableListenableFuture<>();
|
||||
future.set("dummy");
|
||||
AnotherTestEvent event = new AnotherTestEvent(this, future);
|
||||
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
|
||||
TestEventListener listener = this.context.getBean(TestEventListener.class);
|
||||
|
||||
this.eventCollector.assertNoEventReceived(listener);
|
||||
this.eventCollector.assertNoEventReceived(replyEventListener);
|
||||
this.context.publishEvent(event);
|
||||
this.eventCollector.assertEvent(replyEventListener, event);
|
||||
this.eventCollector.assertEvent(listener, "dummy"); // reply
|
||||
this.eventCollector.assertTotalEventsCount(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void completableFutureReply() {
|
||||
load(TestEventListener.class, ReplyEventListener.class);
|
||||
|
||||
@@ -200,20 +200,6 @@ class AsyncAnnotationBeanPostProcessorTests {
|
||||
assertFutureWithException(result, exceptionHandler);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void handleExceptionWithListenableFuture() {
|
||||
ConfigurableApplicationContext context =
|
||||
new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);
|
||||
ITestBean testBean = context.getBean("target", ITestBean.class);
|
||||
|
||||
TestableAsyncUncaughtExceptionHandler exceptionHandler =
|
||||
context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);
|
||||
assertThat(exceptionHandler.isCalled()).as("handler should not have been called yet").isFalse();
|
||||
Future<Object> result = testBean.failWithListenableFuture();
|
||||
assertFutureWithException(result, exceptionHandler);
|
||||
}
|
||||
|
||||
private void assertFutureWithException(Future<Object> result,
|
||||
TestableAsyncUncaughtExceptionHandler exceptionHandler) {
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(
|
||||
@@ -275,9 +261,6 @@ class AsyncAnnotationBeanPostProcessorTests {
|
||||
|
||||
Future<Object> failWithFuture();
|
||||
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
org.springframework.util.concurrent.ListenableFuture<Object> failWithListenableFuture();
|
||||
|
||||
void failWithVoid();
|
||||
|
||||
void await(long timeout);
|
||||
@@ -308,13 +291,6 @@ class AsyncAnnotationBeanPostProcessorTests {
|
||||
throw new UnsupportedOperationException("failWithFuture");
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
public org.springframework.util.concurrent.ListenableFuture<Object> failWithListenableFuture() {
|
||||
throw new UnsupportedOperationException("failWithListenableFuture");
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void failWithVoid() {
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
@@ -51,7 +50,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@SuppressWarnings({"resource", "deprecation", "removal"})
|
||||
class AsyncExecutionTests {
|
||||
|
||||
private static String originalThreadName;
|
||||
@@ -81,8 +79,6 @@ class AsyncExecutionTests {
|
||||
asyncTest.doSomething(10);
|
||||
Future<String> future = asyncTest.returnSomething(20);
|
||||
assertThat(future.get()).isEqualTo("20");
|
||||
ListenableFuture<String> listenableFuture = asyncTest.returnSomethingListenable(20);
|
||||
assertThat(listenableFuture.get()).isEqualTo("20");
|
||||
CompletableFuture<String> completableFuture = asyncTest.returnSomethingCompletable(20);
|
||||
assertThat(completableFuture.get()).isEqualTo("20");
|
||||
|
||||
@@ -94,14 +90,6 @@ class AsyncExecutionTests {
|
||||
asyncTest.returnSomething(-1).get())
|
||||
.withCauseInstanceOf(IOException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingListenable(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingListenable(-1).get())
|
||||
.withCauseInstanceOf(IOException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingCompletable(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
@@ -174,8 +162,6 @@ class AsyncExecutionTests {
|
||||
asyncTest.doSomething(10);
|
||||
Future<String> future = asyncTest.returnSomething(20);
|
||||
assertThat(future.get()).isEqualTo("20");
|
||||
ListenableFuture<String> listenableFuture = asyncTest.returnSomethingListenable(20);
|
||||
assertThat(listenableFuture.get()).isEqualTo("20");
|
||||
CompletableFuture<String> completableFuture = asyncTest.returnSomethingCompletable(20);
|
||||
assertThat(completableFuture.get()).isEqualTo("20");
|
||||
|
||||
@@ -183,10 +169,6 @@ class AsyncExecutionTests {
|
||||
asyncTest.returnSomething(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingListenable(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
|
||||
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() ->
|
||||
asyncTest.returnSomethingCompletable(0).get())
|
||||
.withCauseInstanceOf(IllegalArgumentException.class);
|
||||
@@ -419,18 +401,6 @@ class AsyncExecutionTests {
|
||||
return AsyncResult.forValue(Integer.toString(i));
|
||||
}
|
||||
|
||||
@Async
|
||||
public ListenableFuture<String> returnSomethingListenable(int i) {
|
||||
assertThat(Thread.currentThread().getName()).isNotEqualTo(originalThreadName);
|
||||
if (i == 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
else if (i < 0) {
|
||||
return AsyncResult.forExecutionException(new IOException());
|
||||
}
|
||||
return new AsyncResult<>(Integer.toString(i));
|
||||
}
|
||||
|
||||
@Async
|
||||
public CompletableFuture<String> returnSomethingCompletable(int i) {
|
||||
assertThat(Thread.currentThread().getName()).isNotEqualTo(originalThreadName);
|
||||
@@ -505,14 +475,6 @@ class AsyncExecutionTests {
|
||||
return new AsyncResult<>(Integer.toString(i));
|
||||
}
|
||||
|
||||
public ListenableFuture<String> returnSomethingListenable(int i) {
|
||||
assertThat(Thread.currentThread().getName()).isNotEqualTo(originalThreadName);
|
||||
if (i == 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return new AsyncResult<>(Integer.toString(i));
|
||||
}
|
||||
|
||||
@Async
|
||||
public CompletableFuture<String> returnSomethingCompletable(int i) {
|
||||
assertThat(Thread.currentThread().getName()).isNotEqualTo(originalThreadName);
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.scheduling.annotation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
class AsyncResultTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public void asyncResultWithCallbackAndValue() throws Exception {
|
||||
String value = "val";
|
||||
final Set<String> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forValue(value);
|
||||
future.addCallback(new org.springframework.util.concurrent.ListenableFutureCallback<>() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
values.add(result);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable ex) {
|
||||
throw new AssertionError("Failure callback not expected: " + ex, ex);
|
||||
}
|
||||
});
|
||||
assertThat(values).singleElement().isSameAs(value);
|
||||
assertThat(future.get()).isSameAs(value);
|
||||
assertThat(future.completable().get()).isSameAs(value);
|
||||
future.completable().thenAccept(v -> assertThat(v).isSameAs(value));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public void asyncResultWithCallbackAndException() {
|
||||
IOException ex = new IOException();
|
||||
final Set<Throwable> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forExecutionException(ex);
|
||||
future.addCallback(new org.springframework.util.concurrent.ListenableFutureCallback<>() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
throw new AssertionError("Success callback not expected: " + result);
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable ex) {
|
||||
values.add(ex);
|
||||
}
|
||||
});
|
||||
assertThat(values).singleElement().isSameAs(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future::get)
|
||||
.withCause(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future.completable()::get)
|
||||
.withCause(ex);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public void asyncResultWithSeparateCallbacksAndValue() throws Exception {
|
||||
String value = "val";
|
||||
final Set<String> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forValue(value);
|
||||
future.addCallback(values::add, ex -> new AssertionError("Failure callback not expected: " + ex));
|
||||
assertThat(values).singleElement().isSameAs(value);
|
||||
assertThat(future.get()).isSameAs(value);
|
||||
assertThat(future.completable().get()).isSameAs(value);
|
||||
future.completable().thenAccept(v -> assertThat(v).isSameAs(value));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public void asyncResultWithSeparateCallbacksAndException() {
|
||||
IOException ex = new IOException();
|
||||
final Set<Throwable> values = new HashSet<>(1);
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = AsyncResult.forExecutionException(ex);
|
||||
future.addCallback(result -> new AssertionError("Success callback not expected: " + result), values::add);
|
||||
assertThat(values).singleElement().isSameAs(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future::get)
|
||||
.withCause(ex);
|
||||
assertThatExceptionOfType(ExecutionException.class)
|
||||
.isThrownBy(future.completable()::get)
|
||||
.withCause(ex);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -47,8 +48,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
*/
|
||||
abstract class AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private org.springframework.core.task.AsyncListenableTaskExecutor executor;
|
||||
private AsyncTaskExecutor executor;
|
||||
|
||||
protected String testName;
|
||||
|
||||
@@ -64,8 +64,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
this.executor = buildExecutor();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
protected abstract org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor();
|
||||
protected abstract AsyncTaskExecutor buildExecutor();
|
||||
|
||||
@AfterEach
|
||||
void shutdownExecutor() throws Exception {
|
||||
@@ -124,22 +123,6 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitListenableRunnable() {
|
||||
TestTask task = new TestTask(this.testName, 1);
|
||||
// Act
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future = executor.submitListenable(task);
|
||||
future.addCallback(result -> outcome = result, ex -> outcome = ex);
|
||||
// Assert
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.until(future::isDone);
|
||||
assertThat(outcome).isNull();
|
||||
assertThreadNamePrefix(task);
|
||||
}
|
||||
|
||||
@Test
|
||||
void submitCompletableRunnable() {
|
||||
TestTask task = new TestTask(this.testName, 1);
|
||||
@@ -155,21 +138,6 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
assertThreadNamePrefix(task);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitFailingListenableRunnable() {
|
||||
TestTask task = new TestTask(this.testName, 0);
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future = executor.submitListenable(task);
|
||||
future.addCallback(result -> outcome = result, ex -> outcome = ex);
|
||||
|
||||
Awaitility.await()
|
||||
.dontCatchUncaughtExceptions()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.until(() -> future.isDone() && outcome != null);
|
||||
assertThat(outcome.getClass()).isSameAs(RuntimeException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void submitFailingCompletableRunnable() {
|
||||
TestTask task = new TestTask(this.testName, 0);
|
||||
@@ -184,43 +152,15 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
assertThat(outcome.getClass()).isSameAs(CompletionException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitListenableRunnableWithGetAfterShutdown() throws Exception {
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future1 = executor.submitListenable(new TestTask(this.testName, -1));
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future2 = executor.submitListenable(new TestTask(this.testName, -1));
|
||||
shutdownExecutor();
|
||||
|
||||
try {
|
||||
future1.get(1000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.untilAsserted(() -> assertThatExceptionOfType(CancellationException.class)
|
||||
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void submitCompletableRunnableWithGetAfterShutdown() throws Exception {
|
||||
CompletableFuture<?> future1 = executor.submitCompletable(new TestTask(this.testName, -1));
|
||||
CompletableFuture<?> future2 = executor.submitCompletable(new TestTask(this.testName, -1));
|
||||
shutdownExecutor();
|
||||
|
||||
try {
|
||||
assertThatExceptionOfType(TimeoutException.class).isThrownBy(() -> {
|
||||
future1.get(1000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.untilAsserted(() -> assertThatExceptionOfType(TimeoutException.class)
|
||||
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
|
||||
future2.get(1000, TimeUnit.MILLISECONDS);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,57 +185,6 @@ abstract class AbstractSchedulingTaskExecutorTests {
|
||||
Future<?> future1 = executor.submit(new TestCallable(this.testName, -1));
|
||||
Future<?> future2 = executor.submit(new TestCallable(this.testName, -1));
|
||||
shutdownExecutor();
|
||||
|
||||
try {
|
||||
future1.get(1000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.untilAsserted(() -> assertThatExceptionOfType(CancellationException.class)
|
||||
.isThrownBy(() -> future2.get(1000, TimeUnit.MILLISECONDS)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitListenableCallable() {
|
||||
TestCallable task = new TestCallable(this.testName, 1);
|
||||
// Act
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = executor.submitListenable(task);
|
||||
future.addCallback(result -> outcome = result, ex -> outcome = ex);
|
||||
// Assert
|
||||
Awaitility.await()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.until(() -> future.isDone() && outcome != null);
|
||||
assertThat(outcome.toString().substring(0, this.threadNamePrefix.length())).isEqualTo(this.threadNamePrefix);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitFailingListenableCallable() {
|
||||
TestCallable task = new TestCallable(this.testName, 0);
|
||||
// Act
|
||||
org.springframework.util.concurrent.ListenableFuture<String> future = executor.submitListenable(task);
|
||||
future.addCallback(result -> outcome = result, ex -> outcome = ex);
|
||||
// Assert
|
||||
Awaitility.await()
|
||||
.dontCatchUncaughtExceptions()
|
||||
.atMost(5, TimeUnit.SECONDS)
|
||||
.pollInterval(10, TimeUnit.MILLISECONDS)
|
||||
.until(() -> future.isDone() && outcome != null);
|
||||
assertThat(outcome.getClass()).isSameAs(RuntimeException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
void submitListenableCallableWithGetAfterShutdown() throws Exception {
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future1 = executor.submitListenable(new TestCallable(this.testName, -1));
|
||||
org.springframework.util.concurrent.ListenableFuture<?> future2 = executor.submitListenable(new TestCallable(this.testName, -1));
|
||||
shutdownExecutor();
|
||||
assertThatExceptionOfType(CancellationException.class).isThrownBy(() -> {
|
||||
future1.get(1000, TimeUnit.MILLISECONDS);
|
||||
future2.get(1000, TimeUnit.MILLISECONDS);
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.core.task.NoOpRunnable;
|
||||
import org.springframework.core.task.TaskDecorator;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -42,8 +43,7 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
concurrentExecutor.setThreadFactory(new CustomizableThreadFactory(this.threadNamePrefix));
|
||||
return new ConcurrentTaskExecutor(concurrentExecutor);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.TriggerContext;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
@@ -52,8 +53,7 @@ class ConcurrentTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
threadFactory.setThreadNamePrefix(this.threadNamePrefix);
|
||||
scheduler.setTaskDecorator(runnable -> () -> {
|
||||
taskRun.set(true);
|
||||
@@ -79,26 +79,12 @@ class ConcurrentTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
|
||||
// decorated Future cannot be cancelled on shutdown with ConcurrentTaskScheduler (see above)
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
void submitListenableRunnableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with ConcurrentTaskScheduler (see above)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
void submitCallableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with ConcurrentTaskScheduler (see above)
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
void submitListenableCallableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with ConcurrentTaskScheduler (see above)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void executeFailingRunnableWithErrorHandler() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.scheduling.concurrent;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.scheduling.support.DelegatingErrorHandlingRunnable;
|
||||
import org.springframework.scheduling.support.TaskUtils;
|
||||
|
||||
@@ -26,8 +27,7 @@ import org.springframework.scheduling.support.TaskUtils;
|
||||
class DecoratedThreadPoolTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setTaskDecorator(runnable ->
|
||||
new DelegatingErrorHandlingRunnable(runnable, TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER));
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.TriggerContext;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
@@ -45,8 +46,7 @@ class SimpleAsyncTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
scheduler.setTaskDecorator(runnable -> () -> {
|
||||
taskRun.set(true);
|
||||
runnable.run();
|
||||
@@ -62,12 +62,6 @@ class SimpleAsyncTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests
|
||||
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
void submitListenableRunnableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
void submitCompletableRunnableWithGetAfterShutdown() {
|
||||
@@ -80,13 +74,6 @@ class SimpleAsyncTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests
|
||||
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
void submitListenableCallableWithGetAfterShutdown() {
|
||||
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
void submitCompletableCallableWithGetAfterShutdown() {
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
@@ -41,8 +43,7 @@ class ThreadPoolTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
executor.setThreadNamePrefix(this.threadNamePrefix);
|
||||
executor.setMaxPoolSize(1);
|
||||
executor.afterPropertiesSet();
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.TriggerContext;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
@@ -49,8 +50,7 @@ class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("removal")
|
||||
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
|
||||
protected AsyncTaskExecutor buildExecutor() {
|
||||
scheduler.setTaskDecorator(runnable -> () -> {
|
||||
taskRun.set(true);
|
||||
runnable.run();
|
||||
|
||||
Reference in New Issue
Block a user