From aa1f3d1681c314d224e4a406d7e7e4d04465b793 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 2 Dec 2022 22:53:17 +0100 Subject: [PATCH] Apply "instanceof pattern matching" --- .../test/context/cache/DefaultContextCache.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java index 9a205249586..bfb1b70452f 100644 --- a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java +++ b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -203,8 +203,8 @@ public class DefaultContextCache implements ContextCache { // Physically remove and close leaf nodes first (i.e., on the way back up the // stack as opposed to prior to the recursive call). ApplicationContext context = this.contextMap.remove(key); - if (context instanceof ConfigurableApplicationContext) { - ((ConfigurableApplicationContext) context).close(); + if (context instanceof ConfigurableApplicationContext cac) { + cac.close(); } removedContexts.add(key); }