Skip to content

Commit e60abad

Browse files
committed
Use pattern variables where possible
1 parent 02d85c4 commit e60abad

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/main/java/de/cronn/testutils/ExecutorServiceUtils.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ private static boolean shutdown(ExecutorService executorService, String executor
7070
if (success) {
7171
log.info("Finished shutdown of '{}'", executorServiceName);
7272
} else {
73-
if (executorService instanceof ThreadPoolExecutor) {
74-
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executorService;
73+
if (executorService instanceof ThreadPoolExecutor threadPoolExecutor) {
7574
log.warn("Shutdown of '{}' timed out after {} ms. Active tasks: {}", executorServiceName, timeoutMillis, threadPoolExecutor.getActiveCount());
7675
} else {
7776
log.warn("Shutdown of '{}' timed out after {} ms.", executorServiceName, timeoutMillis);
@@ -81,8 +80,7 @@ private static boolean shutdown(ExecutorService executorService, String executor
8180
}
8281

8382
private static void clearQueue(ExecutorService executorService, String executorServiceName) {
84-
if (executorService instanceof ThreadPoolExecutor) {
85-
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executorService;
83+
if (executorService instanceof ThreadPoolExecutor threadPoolExecutor) {
8684
BlockingQueue<Runnable> queue = threadPoolExecutor.getQueue();
8785
if (!queue.isEmpty()) {
8886
int queueSize = queue.size();

src/main/java/de/cronn/testutils/spring/ResetClockExtension.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public static boolean hasDeclaredMethodOrder(ExtensionContext context) {
4545
protected void resetClock(ExtensionContext context) {
4646
ApplicationContext applicationContext = SpringExtension.getApplicationContext(context);
4747
Clock clock = applicationContext.getBean(Clock.class);
48-
if (clock instanceof TestClock) {
49-
((TestClock) clock).reset();
48+
if (clock instanceof TestClock testClock) {
49+
testClock.reset();
5050
}
5151
}
5252

0 commit comments

Comments
 (0)