From 69af5d242630adde0ebf8ed633d5d630d37f866e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AC=B8=EC=A0=95=ED=99=98?= <70272622+bazzi2548@users.noreply.github.com> Date: Sun, 25 Aug 2024 02:11:29 +0900 Subject: [PATCH] Use List.copyOf() instead of Collections.unmodifiableList() We can safely use List.copyOf() because we check if (providers) is null. If use List.copyOf() - Clean code - Performance optimization - Guarantees a truly immutable list. --- .../jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java index 47b360cf426d..dbfda1b95416 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java @@ -40,8 +40,7 @@ public class CompositeDataSourcePoolMetadataProvider implements DataSourcePoolMe * @param providers the data source pool metadata providers */ public CompositeDataSourcePoolMetadataProvider(Collection providers) { - this.providers = (providers != null) ? Collections.unmodifiableList(new ArrayList<>(providers)) - : Collections.emptyList(); + this.providers = (providers != null) ? List.copyOf(providers) : Collections.emptyList(); } @Override