Skip to content

Commit

Permalink
Use pattern variables where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaldvogel authored and rpost committed Aug 22, 2024
1 parent b20a60b commit b630a45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/main/java/de/cronn/testutils/ExecutorServiceUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<Runnable> queue = threadPoolExecutor.getQueue();
if (!queue.isEmpty()) {
int queueSize = queue.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit b630a45

Please sign in to comment.