Skip to content

Commit 19b21b1

Browse files
committed
Polishing
1 parent 5474252 commit 19b21b1

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

Diff for: spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -183,6 +183,7 @@ public void setErrorHandler(ErrorHandler errorHandler) {
183183
* @see Clock#systemDefaultZone()
184184
*/
185185
public void setClock(Clock clock) {
186+
Assert.notNull(clock, "Clock must not be null");
186187
this.clock = clock;
187188
}
188189

Diff for: spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,8 +46,9 @@
4646
import org.springframework.util.concurrent.ListenableFutureTask;
4747

4848
/**
49-
* Implementation of Spring's {@link TaskScheduler} interface, wrapping
50-
* a native {@link java.util.concurrent.ScheduledThreadPoolExecutor}.
49+
* A standard implementation of Spring's {@link TaskScheduler} interface, wrapping
50+
* a native {@link java.util.concurrent.ScheduledThreadPoolExecutor} and providing
51+
* all applicable configuration options for it.
5152
*
5253
* @author Juergen Hoeller
5354
* @author Mark Fisher
@@ -158,6 +159,7 @@ public void setErrorHandler(ErrorHandler errorHandler) {
158159
* @see Clock#systemDefaultZone()
159160
*/
160161
public void setClock(Clock clock) {
162+
Assert.notNull(clock, "Clock must not be null");
161163
this.clock = clock;
162164
}
163165

Diff for: spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,8 +17,8 @@
1717
package org.springframework.scheduling.concurrent;
1818

1919
import java.util.concurrent.Executor;
20+
import java.util.concurrent.Future;
2021
import java.util.concurrent.LinkedBlockingQueue;
21-
import java.util.concurrent.RunnableFuture;
2222
import java.util.concurrent.ThreadPoolExecutor;
2323
import java.util.concurrent.TimeUnit;
2424

@@ -52,8 +52,8 @@ protected org.springframework.core.task.AsyncListenableTaskExecutor buildExecuto
5252
@AfterEach
5353
void shutdownExecutor() {
5454
for (Runnable task : concurrentExecutor.shutdownNow()) {
55-
if (task instanceof RunnableFuture) {
56-
((RunnableFuture<?>) task).cancel(true);
55+
if (task instanceof Future) {
56+
((Future<?>) task).cancel(true);
5757
}
5858
}
5959
}

Diff for: spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -101,7 +101,7 @@ void scheduleOneTimeTask() throws Exception {
101101

102102
@Test
103103
@SuppressWarnings("deprecation")
104-
void scheduleOneTimeFailingTaskWithoutErrorHandler() throws Exception {
104+
void scheduleOneTimeFailingTaskWithoutErrorHandler() {
105105
TestTask task = new TestTask(this.testName, 0);
106106
Future<?> future = scheduler.schedule(task, new Date());
107107
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() -> future.get(1000, TimeUnit.MILLISECONDS));
@@ -147,7 +147,7 @@ private void await(CountDownLatch latch) {
147147
catch (InterruptedException ex) {
148148
throw new IllegalStateException(ex);
149149
}
150-
assertThat(latch.getCount()).as("latch did not count down,").isEqualTo(0);
150+
assertThat(latch.getCount()).as("latch did not count down").isEqualTo(0);
151151
}
152152

153153

0 commit comments

Comments
 (0)