Skip to content

Commit af2474b

Browse files
committed
Merge pull request #42049 from abc5259
* pr/42049: Apply instanceof pattern matching Closes gh-42049
2 parents 53e7371 + d0fe5c2 commit af2474b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextApplicationContextInitializer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ public int getOrder() {
7272
@Override
7373
public void onApplicationEvent(ContextRefreshedEvent event) {
7474
ApplicationContext context = event.getApplicationContext();
75-
if (context instanceof ConfigurableApplicationContext && context == event.getSource()) {
76-
context.publishEvent(new ParentContextAvailableEvent((ConfigurableApplicationContext) context));
75+
if (context instanceof ConfigurableApplicationContext configurableApplicationContext
76+
&& context == event.getSource()) {
77+
context.publishEvent(new ParentContextAvailableEvent(configurableApplicationContext));
7778
}
7879
}
7980

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,8 @@ private void flatten(Properties properties, Map<String, Object> input, String pa
201201
// Need a compound key
202202
flatten(properties, (Map<String, Object>) value, name);
203203
}
204-
else if (value instanceof Collection) {
204+
else if (value instanceof Collection<?> collection) {
205205
// Need a compound key
206-
Collection<Object> collection = (Collection<Object>) value;
207206
properties.put(name, StringUtils.collectionToCommaDelimitedString(collection));
208207
int count = 0;
209208
for (Object item : collection) {

0 commit comments

Comments
 (0)