Skip to content

Commit 077d90d

Browse files
committed
Merge branch '3.4.x'
Closes gh-45653
2 parents 074d56c + 86cd7ec commit 077d90d

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureRules.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
* @author Scott Frederick
6565
* @author Ivan Malutin
6666
* @author Phillip Webb
67+
* @author Ngoc Nhan
6768
*/
6869
final class ArchitectureRules {
6970

@@ -96,6 +97,7 @@ static List<ArchRule> standard() {
9697
rules.add(classLevelConfigurationPropertiesShouldNotSpecifyOnlyPrefixAttribute());
9798
rules.add(methodLevelConfigurationPropertiesShouldNotSpecifyOnlyPrefixAttribute());
9899
rules.add(conditionsShouldNotBePublic());
100+
rules.add(allConfigurationPropertiesBindingBeanMethodsShouldBeStatic());
99101
return List.copyOf(rules);
100102
}
101103

@@ -309,6 +311,14 @@ private static ArchRule conditionsShouldNotBePublic() {
309311
.allowEmptyShould(true);
310312
}
311313

314+
private static ArchRule allConfigurationPropertiesBindingBeanMethodsShouldBeStatic() {
315+
return methodsThatAreAnnotatedWith("org.springframework.context.annotation.Bean").and()
316+
.areAnnotatedWith("org.springframework.boot.context.properties.ConfigurationPropertiesBinding")
317+
.should()
318+
.beStatic()
319+
.allowEmptyShould(true);
320+
}
321+
312322
private static boolean containsOnlySingleType(JavaType[] types, JavaType type) {
313323
return types.length == 1 && type.equals(types[0]);
314324
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public class FlywayAutoConfiguration {
113113

114114
@Bean
115115
@ConfigurationPropertiesBinding
116-
public StringOrNumberToMigrationVersionConverter stringOrNumberMigrationVersionConverter() {
116+
public static StringOrNumberToMigrationVersionConverter stringOrNumberMigrationVersionConverter() {
117117
return new StringOrNumberToMigrationVersionConverter();
118118
}
119119

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static class ConverterConfiguration {
264264

265265
@Bean
266266
@ConfigurationPropertiesBinding
267-
Converter<String, TargetType> targetTypeConverter() {
267+
static Converter<String, TargetType> targetTypeConverter() {
268268
return new Converter<>() {
269269

270270
@Override

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ static class PersonConverterConfiguration {
15931593

15941594
@Bean
15951595
@ConfigurationPropertiesBinding
1596-
Converter<String, Person> personConverter() {
1596+
static Converter<String, Person> personConverter() {
15971597
return new PersonConverter();
15981598
}
15991599

@@ -1604,7 +1604,7 @@ static class AlienConverterConfiguration {
16041604

16051605
@Bean
16061606
@ConfigurationPropertiesBinding
1607-
Converter<String, Alien> alienConverter() {
1607+
static Converter<String, Alien> alienConverter() {
16081608
return new AlienConverter();
16091609
}
16101610

@@ -1625,7 +1625,7 @@ static class GenericConverterConfiguration {
16251625

16261626
@Bean
16271627
@ConfigurationPropertiesBinding
1628-
GenericConverter genericPersonConverter() {
1628+
static GenericConverter genericPersonConverter() {
16291629
return new GenericPersonConverter();
16301630
}
16311631

@@ -1636,7 +1636,7 @@ static class FormatterConfiguration {
16361636

16371637
@Bean
16381638
@ConfigurationPropertiesBinding
1639-
Formatter<Person> personFormatter() {
1639+
static Formatter<Person> personFormatter() {
16401640
return new PersonFormatter();
16411641
}
16421642

@@ -3064,7 +3064,7 @@ static class WithCustomConverterAndObjectToObjectMethodConfiguration {
30643064

30653065
@Bean
30663066
@ConfigurationPropertiesBinding
3067-
WithObjectToObjectMethodConverter withObjectToObjectMethodConverter() {
3067+
static WithObjectToObjectMethodConverter withObjectToObjectMethodConverter() {
30683068
return new WithObjectToObjectMethodConverter();
30693069
}
30703070

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConversionServiceDeducerTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ static class CustomConverterConfiguration {
129129

130130
@Bean
131131
@ConfigurationPropertiesBinding
132-
TestConverter testConverter() {
132+
static TestConverter testConverter() {
133133
return new TestConverter();
134134
}
135135

136136
@Bean
137137
@ConfigurationPropertiesBinding
138-
StringConverter stringConverter() {
138+
static StringConverter stringConverter() {
139139
return new StringConverter();
140140
}
141141

@@ -146,13 +146,13 @@ static class CustomLambdaConverterConfiguration {
146146

147147
@Bean
148148
@ConfigurationPropertiesBinding
149-
Converter<InputStream, OutputStream> testConverter() {
149+
static Converter<InputStream, OutputStream> testConverter() {
150150
return (source) -> new TestConverter().convert(source);
151151
}
152152

153153
@Bean
154154
@ConfigurationPropertiesBinding
155-
Converter<String, InputStream> stringConverter() {
155+
static Converter<String, InputStream> stringConverter() {
156156
return (source) -> new StringConverter().convert(source);
157157
}
158158

@@ -163,7 +163,7 @@ static class PrinterConfiguration {
163163

164164
@Bean
165165
@ConfigurationPropertiesBinding
166-
Printer<InputStream> inputStreamPrinter() {
166+
static Printer<InputStream> inputStreamPrinter() {
167167
return (source, locale) -> ThrowingSupplier
168168
.of(() -> StreamUtils.copyToString(source, StandardCharsets.UTF_8))
169169
.get();

0 commit comments

Comments
 (0)