Use pattern matching for instanceof where appropriate

See gh-31475
This commit is contained in:
dreis2211
2022-06-20 18:14:16 +02:00
committed by Andy Wilkinson
parent a7b98e7312
commit 5db04da275
278 changed files with 1049 additions and 1126 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-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.
@@ -42,8 +42,7 @@ public class TestDefaultTestExecutionListenersPostProcessor implements DefaultTe
@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
Object testInstance = testContext.getTestInstance();
if (testInstance instanceof SpringBootTestContextBootstrapperIntegrationTests) {
SpringBootTestContextBootstrapperIntegrationTests test = (SpringBootTestContextBootstrapperIntegrationTests) testInstance;
if (testInstance instanceof SpringBootTestContextBootstrapperIntegrationTests test) {
test.defaultTestExecutionListenersPostProcessorCalled = true;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-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.
@@ -56,8 +56,8 @@ class MockBeanContextCachingTests {
Map<MergedContextConfiguration, ApplicationContext> contexts = (Map<MergedContextConfiguration, ApplicationContext>) ReflectionTestUtils
.getField(this.contextCache, "contextMap");
for (ApplicationContext context : contexts.values()) {
if (context instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) context).close();
if (context instanceof ConfigurableApplicationContext configurableContext) {
configurableContext.close();
}
}
this.contextCache.clear();