Remove APIs marked as deprecated for removal

Closes gh-33809
This commit is contained in:
Juergen Hoeller
2024-12-04 13:19:39 +01:00
parent 078d683f47
commit 2b9010c2a2
150 changed files with 141 additions and 5922 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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()));
}
}

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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.