From bd367803d1852251c2ec1e65f1dd20ccedfae637 Mon Sep 17 00:00:00 2001 From: Jae-Young98 Date: Mon, 2 Dec 2024 18:31:21 +0900 Subject: [PATCH 1/2] Remove redundant null check for sorter See gh-43343 --- .../springframework/boot/context/annotation/Configurations.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java index b00121071f2..84b137cf176 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java @@ -92,7 +92,7 @@ public abstract class Configurations { Assert.notNull(classes, "Classes must not be null"); sorter = (sorter != null) ? sorter : UnaryOperator.identity(); Collection> sorted = sorter.apply(classes); - this.sorter = (sorter != null) ? sorter : UnaryOperator.identity(); + this.sorter = sorter; this.classes = Collections.unmodifiableSet(new LinkedHashSet<>(sorted)); this.beanNameGenerator = beanNameGenerator; } From 07bc5f256336790132a83c465a9b537ad66b2b05 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Mon, 2 Dec 2024 11:39:37 +0100 Subject: [PATCH 2/2] Polish "Remove redundant null check for sorter" See gh-43343 --- .../boot/context/annotation/Configurations.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java index 84b137cf176..744c04d3f4a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/Configurations.java @@ -90,9 +90,8 @@ public abstract class Configurations { protected Configurations(UnaryOperator>> sorter, Collection> classes, Function, String> beanNameGenerator) { Assert.notNull(classes, "Classes must not be null"); - sorter = (sorter != null) ? sorter : UnaryOperator.identity(); - Collection> sorted = sorter.apply(classes); - this.sorter = sorter; + this.sorter = (sorter != null) ? sorter : UnaryOperator.identity(); + Collection> sorted = this.sorter.apply(classes); this.classes = Collections.unmodifiableSet(new LinkedHashSet<>(sorted)); this.beanNameGenerator = beanNameGenerator; }