diff --git a/src/main/java/de/cronn/testutils/ExecutorServiceUtils.java b/src/main/java/de/cronn/testutils/ExecutorServiceUtils.java index 38218b0..4ef7e88 100644 --- a/src/main/java/de/cronn/testutils/ExecutorServiceUtils.java +++ b/src/main/java/de/cronn/testutils/ExecutorServiceUtils.java @@ -70,8 +70,7 @@ private static boolean shutdown(ExecutorService executorService, String executor if (success) { log.info("Finished shutdown of '{}'", executorServiceName); } else { - if (executorService instanceof ThreadPoolExecutor) { - ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executorService; + if (executorService instanceof ThreadPoolExecutor threadPoolExecutor) { log.warn("Shutdown of '{}' timed out after {} ms. Active tasks: {}", executorServiceName, timeoutMillis, threadPoolExecutor.getActiveCount()); } else { log.warn("Shutdown of '{}' timed out after {} ms.", executorServiceName, timeoutMillis); @@ -81,8 +80,7 @@ private static boolean shutdown(ExecutorService executorService, String executor } private static void clearQueue(ExecutorService executorService, String executorServiceName) { - if (executorService instanceof ThreadPoolExecutor) { - ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executorService; + if (executorService instanceof ThreadPoolExecutor threadPoolExecutor) { BlockingQueue queue = threadPoolExecutor.getQueue(); if (!queue.isEmpty()) { int queueSize = queue.size(); diff --git a/src/main/java/de/cronn/testutils/spring/ResetClockExtension.java b/src/main/java/de/cronn/testutils/spring/ResetClockExtension.java index 44d8779..e124d35 100644 --- a/src/main/java/de/cronn/testutils/spring/ResetClockExtension.java +++ b/src/main/java/de/cronn/testutils/spring/ResetClockExtension.java @@ -45,8 +45,8 @@ public static boolean hasDeclaredMethodOrder(ExtensionContext context) { protected void resetClock(ExtensionContext context) { ApplicationContext applicationContext = SpringExtension.getApplicationContext(context); Clock clock = applicationContext.getBean(Clock.class); - if (clock instanceof TestClock) { - ((TestClock) clock).reset(); + if (clock instanceof TestClock testClock) { + testClock.reset(); } }