From 1255bd1fc9880506e7017758fe91d5f9135c6fc8 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 29 Oct 2024 23:15:53 +0100 Subject: [PATCH] Add remaining @SuppressWarnings("removal") for ListenableFuture See gh-33780 --- .../AbstractSchedulingTaskExecutorTests.java | 16 ++++++++-------- .../concurrent/ConcurrentTaskExecutorTests.java | 4 ++-- .../concurrent/ConcurrentTaskSchedulerTests.java | 4 ++-- .../DecoratedThreadPoolTaskExecutorTests.java | 4 ++-- .../SimpleAsyncTaskSchedulerTests.java | 3 +-- .../concurrent/ThreadPoolTaskExecutorTests.java | 2 +- .../concurrent/ThreadPoolTaskSchedulerTests.java | 2 +- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java index 5d817ee9e1..8d49d5ee91 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java @@ -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)); diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java index 7b011c9eb6..b1357b1217 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java @@ -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) { diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskSchedulerTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskSchedulerTests.java index 1ef701fff6..11711fbc71 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskSchedulerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskSchedulerTests.java @@ -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) { diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/DecoratedThreadPoolTaskExecutorTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/DecoratedThreadPoolTaskExecutorTests.java index d946ff8bde..d69ac85a64 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/DecoratedThreadPoolTaskExecutorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/DecoratedThreadPoolTaskExecutorTests.java @@ -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 -> diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskSchedulerTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskSchedulerTests.java index 9a7a751f74..b3cd12d52e 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskSchedulerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/SimpleAsyncTaskSchedulerTests.java @@ -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 diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutorTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutorTests.java index 2be063371f..5201af2a34 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutorTests.java @@ -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); diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java index 48c0192c13..63cbeafbcb 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java @@ -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);