Add remaining @SuppressWarnings("removal") for ListenableFuture

See gh-33780
This commit is contained in:
Juergen Hoeller
2024-10-29 23:15:53 +01:00
parent a1f6098158
commit 1255bd1fc9
7 changed files with 17 additions and 18 deletions

View File

@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*/
abstract class AbstractSchedulingTaskExecutorTests {
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
private org.springframework.core.task.AsyncListenableTaskExecutor executor;
protected String testName;
@@ -64,7 +64,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
this.executor = buildExecutor();
}
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected abstract org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor();
@AfterEach
@@ -125,7 +125,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
}
@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
void submitListenableRunnable() {
TestTask task = new TestTask(this.testName, 1);
// Act
@@ -156,7 +156,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
}
@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
void submitFailingListenableRunnable() {
TestTask task = new TestTask(this.testName, 0);
org.springframework.util.concurrent.ListenableFuture<?> future = executor.submitListenable(task);
@@ -185,7 +185,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
}
@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("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));
@@ -260,7 +260,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
}
@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
void submitListenableCallable() {
TestCallable task = new TestCallable(this.testName, 1);
// Act
@@ -275,7 +275,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
}
@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
void submitFailingListenableCallable() {
TestCallable task = new TestCallable(this.testName, 0);
// Act
@@ -291,7 +291,7 @@ abstract class AbstractSchedulingTaskExecutorTests {
}
@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("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));

View File

@@ -41,15 +41,15 @@ class ConcurrentTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
@SuppressWarnings("deprecation")
@Override
@SuppressWarnings("removal")
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
concurrentExecutor.setThreadFactory(new CustomizableThreadFactory(this.threadNamePrefix));
return new ConcurrentTaskExecutor(concurrentExecutor);
}
@Override
@AfterEach
@Override
void shutdownExecutor() {
for (Runnable task : concurrentExecutor.shutdownNow()) {
if (task instanceof Future) {

View File

@@ -51,8 +51,8 @@ class ConcurrentTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
private final AtomicBoolean taskRun = new AtomicBoolean();
@SuppressWarnings("deprecation")
@Override
@SuppressWarnings("removal")
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
threadFactory.setThreadNamePrefix(this.threadNamePrefix);
scheduler.setTaskDecorator(runnable -> () -> {
@@ -62,8 +62,8 @@ class ConcurrentTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
return scheduler;
}
@Override
@AfterEach
@Override
void shutdownExecutor() {
for (Runnable task : ((ExecutorService) scheduler.getConcurrentExecutor()).shutdownNow()) {
if (task instanceof Future) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 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.
@@ -26,7 +26,7 @@ import org.springframework.scheduling.support.TaskUtils;
class DecoratedThreadPoolTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setTaskDecorator(runnable ->

View File

@@ -44,8 +44,8 @@ class SimpleAsyncTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests
private final AtomicBoolean taskRun = new AtomicBoolean();
@SuppressWarnings("deprecation")
@Override
@SuppressWarnings("removal")
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
scheduler.setTaskDecorator(runnable -> () -> {
taskRun.set(true);
@@ -63,7 +63,6 @@ class SimpleAsyncTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests
}
@Test
@SuppressWarnings("deprecation")
@Override
void submitListenableRunnableWithGetAfterShutdown() {
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler

View File

@@ -41,7 +41,7 @@ class ThreadPoolTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {
@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
executor.setThreadNamePrefix(this.threadNamePrefix);
executor.setMaxPoolSize(1);

View File

@@ -48,8 +48,8 @@ class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
private final AtomicBoolean taskRun = new AtomicBoolean();
@SuppressWarnings("deprecation")
@Override
@SuppressWarnings("removal")
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
scheduler.setTaskDecorator(runnable -> () -> {
taskRun.set(true);