Skip to content

Commit

Permalink
Add remaining @SuppressWarnings("removal") for ListenableFuture
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Oct 29, 2024
1 parent a1f6098 commit 1255bd1
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
abstract class AbstractSchedulingTaskExecutorTests {

@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
private org.springframework.core.task.AsyncListenableTaskExecutor executor;

protected String testName;
Expand All @@ -64,7 +64,7 @@ void setup(TestInfo testInfo) {
this.executor = buildExecutor();
}

@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected abstract org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor();

@AfterEach
Expand Down Expand Up @@ -125,7 +125,7 @@ void submitRunnableWithGetAfterShutdown() throws Exception {
}

@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
void submitListenableRunnable() {
TestTask task = new TestTask(this.testName, 1);
// Act
Expand Down Expand Up @@ -156,7 +156,7 @@ void submitCompletableRunnable() {
}

@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
void submitFailingListenableRunnable() {
TestTask task = new TestTask(this.testName, 0);
org.springframework.util.concurrent.ListenableFuture<?> future = executor.submitListenable(task);
Expand Down Expand Up @@ -185,7 +185,7 @@ void submitFailingCompletableRunnable() {
}

@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));
Expand Down Expand Up @@ -260,7 +260,7 @@ void submitCallableWithGetAfterShutdown() throws Exception {
}

@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
void submitListenableCallable() {
TestCallable task = new TestCallable(this.testName, 1);
// Act
Expand All @@ -275,7 +275,7 @@ void submitListenableCallable() {
}

@Test
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
void submitFailingListenableCallable() {
TestCallable task = new TestCallable(this.testName, 0);
// Act
Expand All @@ -291,7 +291,7 @@ void submitFailingListenableCallable() {
}

@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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> () -> {
Expand All @@ -62,8 +62,8 @@ protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecuto
return scheduler;
}

@Override
@AfterEach
@Override
void shutdownExecutor() {
for (Runnable task : ((ExecutorService) scheduler.getConcurrentExecutor()).shutdownNow()) {
if (task instanceof Future) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -26,7 +26,7 @@
class DecoratedThreadPoolTaskExecutorTests extends AbstractSchedulingTaskExecutorTests {

@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("removal")
protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setTaskDecorator(runnable ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -63,7 +63,6 @@ void submitRunnableWithGetAfterShutdown() {
}

@Test
@SuppressWarnings("deprecation")
@Override
void submitListenableRunnableWithGetAfterShutdown() {
// decorated Future cannot be cancelled on shutdown with SimpleAsyncTaskScheduler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1255bd1

Please sign in to comment.