Deprecate AsyncTaskExecutor.execute(Runnable task, long startTimeout)

Closes gh-27959
This commit is contained in:
Juergen Hoeller
2022-02-04 23:21:00 +01:00
parent 132d8c7f45
commit a71a45e719
12 changed files with 50 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 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.
@@ -31,7 +31,6 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.core.task.TaskRejectedException;
import org.springframework.core.task.TaskTimeoutException;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -143,6 +142,7 @@ public class SimpleTaskWorkManager implements WorkManager {
* (or -1 if not applicable or not known)
* @throws WorkException if the TaskExecutor did not accept the Work
*/
@SuppressWarnings("deprecation")
protected long executeWork(TaskExecutor taskExecutor, Work work, long startTimeout, boolean blockUntilStarted,
@Nullable ExecutionContext executionContext, @Nullable WorkListener workListener) throws WorkException {
@@ -164,7 +164,7 @@ public class SimpleTaskWorkManager implements WorkManager {
taskExecutor.execute(workHandle);
}
}
catch (TaskTimeoutException ex) {
catch (org.springframework.core.task.TaskTimeoutException ex) {
WorkException wex = new WorkRejectedException("TaskExecutor rejected Work because of timeout: " + work, ex);
wex.setErrorCode(WorkException.START_TIMED_OUT);
workListenerToUse.workRejected(new WorkEvent(this, WorkEvent.WORK_REJECTED, work, wex));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -33,7 +33,6 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.task.AsyncListenableTaskExecutor;
import org.springframework.core.task.TaskDecorator;
import org.springframework.core.task.TaskRejectedException;
import org.springframework.core.task.TaskTimeoutException;
import org.springframework.jca.context.BootstrapContextAware;
import org.springframework.jndi.JndiLocatorSupport;
import org.springframework.lang.Nullable;
@@ -218,11 +217,13 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
// Implementation of the Spring SchedulingTaskExecutor interface
//-------------------------------------------------------------------------
@SuppressWarnings("deprecation")
@Override
public void execute(Runnable task) {
execute(task, TIMEOUT_INDEFINITE);
}
@Deprecated
@Override
public void execute(Runnable task, long startTimeout) {
Work work = new DelegatingWork(this.taskDecorator != null ? this.taskDecorator.decorate(task) : task);
@@ -254,7 +255,8 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
}
catch (WorkRejectedException ex) {
if (WorkException.START_TIMED_OUT.equals(ex.getErrorCode())) {
throw new TaskTimeoutException("JCA WorkManager rejected task because of timeout: " + task, ex);
throw new org.springframework.core.task.TaskTimeoutException(
"JCA WorkManager rejected task because of timeout: " + task, ex);
}
else {
throw new TaskRejectedException("JCA WorkManager rejected task: " + task, ex);
@@ -265,6 +267,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
}
}
@SuppressWarnings("deprecation")
@Override
public Future<?> submit(Runnable task) {
FutureTask<Object> future = new FutureTask<>(task, null);
@@ -272,6 +275,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
return future;
}
@SuppressWarnings("deprecation")
@Override
public <T> Future<T> submit(Callable<T> task) {
FutureTask<T> future = new FutureTask<>(task);
@@ -279,6 +283,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
return future;
}
@SuppressWarnings("deprecation")
@Override
public ListenableFuture<?> submitListenable(Runnable task) {
ListenableFutureTask<Object> future = new ListenableFutureTask<>(task, null);
@@ -286,6 +291,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
return future;
}
@SuppressWarnings("deprecation")
@Override
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
ListenableFutureTask<T> future = new ListenableFutureTask<>(task);