Skip to content

Commit 51d70dc

Browse files
committed
Polishing
1 parent 61f7087 commit 51d70dc

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

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.
@@ -177,6 +177,7 @@ public void setErrorHandler(ErrorHandler errorHandler) {
177177
* @see Clock#systemDefaultZone()
178178
*/
179179
public void setClock(Clock clock) {
180+
Assert.notNull(clock, "Clock must not be null");
180181
this.clock = clock;
181182
}
182183

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.
@@ -45,8 +45,9 @@
4545
import org.springframework.util.concurrent.ListenableFutureTask;
4646

4747
/**
48-
* Implementation of Spring's {@link TaskScheduler} interface, wrapping
49-
* a native {@link java.util.concurrent.ScheduledThreadPoolExecutor}.
48+
* A standard implementation of Spring's {@link TaskScheduler} interface, wrapping
49+
* a native {@link java.util.concurrent.ScheduledThreadPoolExecutor} and providing
50+
* all applicable configuration options for it.
5051
*
5152
* @author Juergen Hoeller
5253
* @author Mark Fisher
@@ -154,6 +155,7 @@ public void setErrorHandler(ErrorHandler errorHandler) {
154155
* @see Clock#systemDefaultZone()
155156
*/
156157
public void setClock(Clock clock) {
158+
Assert.notNull(clock, "Clock must not be null");
157159
this.clock = clock;
158160
}
159161

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 AsyncListenableTaskExecutor buildExecutor() {
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
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 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.
@@ -39,7 +39,7 @@
3939
* @author Sam Brannen
4040
* @since 3.0
4141
*/
42-
public class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
42+
class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests {
4343

4444
private final ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
4545

@@ -97,7 +97,7 @@ void scheduleOneTimeTask() throws Exception {
9797
}
9898

9999
@Test
100-
void scheduleOneTimeFailingTaskWithoutErrorHandler() throws Exception {
100+
void scheduleOneTimeFailingTaskWithoutErrorHandler() {
101101
TestTask task = new TestTask(this.testName, 0);
102102
Future<?> future = scheduler.schedule(task, new Date());
103103
assertThatExceptionOfType(ExecutionException.class).isThrownBy(() -> future.get(1000, TimeUnit.MILLISECONDS));
@@ -149,7 +149,7 @@ private void await(CountDownLatch latch) {
149149
catch (InterruptedException ex) {
150150
throw new IllegalStateException(ex);
151151
}
152-
assertThat(latch.getCount()).as("latch did not count down,").isEqualTo(0);
152+
assertThat(latch.getCount()).as("latch did not count down").isEqualTo(0);
153153
}
154154

155155

0 commit comments

Comments
 (0)