Apply "instanceof pattern matching"

This commit is contained in:
Sam Brannen 2022-12-02 22:53:17 +01:00
parent b366cd352e
commit aa1f3d1681
1 changed files with 3 additions and 3 deletions

View File

@ -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);
}