From 663c2db2b405537893371629fd620ca01453feda Mon Sep 17 00:00:00 2001 From: LeeJaeHoon Date: Thu, 29 Aug 2024 02:19:33 +0900 Subject: [PATCH] Apply instanceof pattern matching --- .../builder/ParentContextApplicationContextInitializer.java | 4 ++-- .../boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextApplicationContextInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextApplicationContextInitializer.java index 1c843b5d649c..8a045036da32 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextApplicationContextInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextApplicationContextInitializer.java @@ -72,8 +72,8 @@ public int getOrder() { @Override public void onApplicationEvent(ContextRefreshedEvent event) { ApplicationContext context = event.getApplicationContext(); - if (context instanceof ConfigurableApplicationContext && context == event.getSource()) { - context.publishEvent(new ParentContextAvailableEvent((ConfigurableApplicationContext) context)); + if (context instanceof ConfigurableApplicationContext configurableApplicationContext && context == event.getSource()) { + context.publishEvent(new ParentContextAvailableEvent(configurableApplicationContext)); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java index 9c15b6290bdb..9aa390f1f6c9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java @@ -201,9 +201,8 @@ private void flatten(Properties properties, Map input, String pa // Need a compound key flatten(properties, (Map) value, name); } - else if (value instanceof Collection) { + else if (value instanceof Collection collection) { // Need a compound key - Collection collection = (Collection) value; properties.put(name, StringUtils.collectionToCommaDelimitedString(collection)); int count = 0; for (Object item : collection) {