Skip to content

Commit 7c381f0

Browse files
committed
Merge upstream/main into current branch
- Resolved conflicts in DocumentConfigurationProperties - Integrated latest changes from upstream Spring Boot repository - Maintained PropertySectionDefinition approach for better maintainability
2 parents 4867f0e + 6a55d7b commit 7c381f0

File tree

141 files changed

+2025
-1291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2025
-1291
lines changed

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ Map<String, String> getAdditionalIfNotExcluded() {
142142
return coerceToStringValues(applyExclusions(getAdditional().getOrElse(Collections.emptyMap())));
143143
}
144144

145-
@SuppressWarnings("NullAway") // Doesn't detect lambda with correct nullability
146145
private <T> @Nullable T getIfNotExcluded(Property<T> property, String name) {
147-
return getIfNotExcluded(property, name, () -> null);
146+
Supplier<@Nullable T> supplier = () -> null;
147+
return getIfNotExcluded(property, name, supplier);
148148
}
149149

150150
private <T> @Nullable T getIfNotExcluded(Property<T> property, String name, Supplier<@Nullable T> defaultValue) {

build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/StartMojo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ private void waitForSpringApplication() throws MojoFailureException, MojoExecuti
156156
}
157157
}
158158

159-
@SuppressWarnings("NullAway") // Lambda isn't detected with the correct nullability
160159
private void doWaitForSpringApplication(MBeanServerConnection connection)
161160
throws MojoExecutionException, MojoFailureException {
162161
final SpringApplicationAdminClient client = new SpringApplicationAdminClient(connection, this.jmxName);
163162
try {
164-
execute(this.wait, this.maxAttempts, () -> (client.isReady() ? true : null));
163+
Callable<@Nullable Boolean> isReady = () -> (client.isReady() ? true : null);
164+
execute(this.wait, this.maxAttempts, isReady);
165165
}
166166
catch (ReflectionException ex) {
167167
throw new MojoExecutionException("Unable to retrieve 'ready' attribute", ex.getCause());

buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/CheckAutoConfigurationClasses.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,17 @@ void execute() {
136136
private List<File> classFiles() {
137137
List<File> classFiles = new ArrayList<>();
138138
for (File root : this.classpath.getFiles()) {
139-
try (Stream<Path> files = Files.walk(root.toPath())) {
140-
files.forEach((file) -> {
141-
if (Files.isRegularFile(file) && file.getFileName().toString().endsWith(".class")) {
142-
classFiles.add(file.toFile());
143-
}
144-
});
145-
}
146-
catch (IOException ex) {
147-
throw new UncheckedIOException(ex);
139+
if (root.exists()) {
140+
try (Stream<Path> files = Files.walk(root.toPath())) {
141+
files.forEach((file) -> {
142+
if (Files.isRegularFile(file) && file.getFileName().toString().endsWith(".class")) {
143+
classFiles.add(file.toFile());
144+
}
145+
});
146+
}
147+
catch (IOException ex) {
148+
throw new UncheckedIOException(ex);
149+
}
148150
}
149151
}
150152
return classFiles;

configuration-metadata/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
109109

110110
static final String READ_OPERATION_ANNOTATION = "org.springframework.boot.actuate.endpoint.annotation.ReadOperation";
111111

112-
static final String OPTIONAL_PARAMETER_ANNOTATION = "org.springframework.boot.actuate.endpoint.annotation.OptionalParameter";
113-
114112
static final String NAME_ANNOTATION = "org.springframework.boot.context.properties.bind.Name";
115113

116114
static final String ENDPOINT_ACCESS_ENUM = "org.springframework.boot.actuate.endpoint.Access";
@@ -166,10 +164,6 @@ protected String nameAnnotation() {
166164
return NAME_ANNOTATION;
167165
}
168166

169-
protected String optionalParameterAnnotation() {
170-
return OPTIONAL_PARAMETER_ANNOTATION;
171-
}
172-
173167
protected String endpointAccessEnum() {
174168
return ENDPOINT_ACCESS_ENUM;
175169
}
@@ -194,8 +188,7 @@ public synchronized void init(ProcessingEnvironment env) {
194188
this.metadataEnv = new MetadataGenerationEnvironment(env, configurationPropertiesAnnotation(),
195189
configurationPropertiesSourceAnnotation(), nestedConfigurationPropertyAnnotation(),
196190
deprecatedConfigurationPropertyAnnotation(), constructorBindingAnnotation(), autowiredAnnotation(),
197-
defaultValueAnnotation(), endpointAnnotations(), readOperationAnnotation(),
198-
optionalParameterAnnotation(), nameAnnotation());
191+
defaultValueAnnotation(), endpointAnnotations(), readOperationAnnotation(), nameAnnotation());
199192
}
200193

201194
@Override
@@ -383,18 +376,13 @@ private boolean hasMainReadOperation(TypeElement element) {
383376

384377
private boolean hasNoOrOptionalParameters(ExecutableElement method) {
385378
for (VariableElement parameter : method.getParameters()) {
386-
if (!isOptionalParameter(parameter)) {
379+
if (!this.metadataEnv.hasNullableAnnotation(parameter)) {
387380
return false;
388381
}
389382
}
390383
return true;
391384
}
392385

393-
private boolean isOptionalParameter(VariableElement parameter) {
394-
return this.metadataEnv.hasNullableAnnotation(parameter)
395-
|| this.metadataEnv.hasOptionalParameterAnnotation(parameter);
396-
}
397-
398386
private String getPrefix(AnnotationMirror annotation) {
399387
String prefix = this.metadataEnv.getAnnotationElementStringValue(annotation, "prefix");
400388
if (prefix != null) {

configuration-metadata/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironment.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ class MetadataGenerationEnvironment {
9898

9999
private final String readOperationAnnotation;
100100

101-
private final String optionalParameterAnnotation;
102-
103101
private final String nameAnnotation;
104102

105103
private final String autowiredAnnotation;
@@ -108,7 +106,7 @@ class MetadataGenerationEnvironment {
108106
String configurationPropertiesSourceAnnotation, String nestedConfigurationPropertyAnnotation,
109107
String deprecatedConfigurationPropertyAnnotation, String constructorBindingAnnotation,
110108
String autowiredAnnotation, String defaultValueAnnotation, Set<String> endpointAnnotations,
111-
String readOperationAnnotation, String optionalParameterAnnotation, String nameAnnotation) {
109+
String readOperationAnnotation, String nameAnnotation) {
112110
this.typeUtils = new TypeUtils(environment);
113111
this.elements = environment.getElementUtils();
114112
this.messager = environment.getMessager();
@@ -123,7 +121,6 @@ class MetadataGenerationEnvironment {
123121
this.defaultValueAnnotation = defaultValueAnnotation;
124122
this.endpointAnnotations = endpointAnnotations;
125123
this.readOperationAnnotation = readOperationAnnotation;
126-
this.optionalParameterAnnotation = optionalParameterAnnotation;
127124
this.nameAnnotation = nameAnnotation;
128125
}
129126

@@ -382,10 +379,6 @@ boolean hasNullableAnnotation(Element element) {
382379
return getTypeUseAnnotation(element, NULLABLE_ANNOTATION) != null;
383380
}
384381

385-
boolean hasOptionalParameterAnnotation(Element element) {
386-
return getAnnotation(element, this.optionalParameterAnnotation) != null;
387-
}
388-
389382
private boolean isElementDeprecated(Element element) {
390383
return hasAnnotation(element, "java.lang.Deprecated")
391384
|| hasAnnotation(element, this.deprecatedConfigurationPropertyAnnotation);

configuration-metadata/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/EndpointMetadataGenerationTests.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.springframework.boot.configurationsample.endpoint.EnabledEndpoint;
3030
import org.springframework.boot.configurationsample.endpoint.NoAccessEndpoint;
3131
import org.springframework.boot.configurationsample.endpoint.NullableParameterEndpoint;
32-
import org.springframework.boot.configurationsample.endpoint.OptionalParameterEndpoint;
3332
import org.springframework.boot.configurationsample.endpoint.ReadOnlyAccessEndpoint;
3433
import org.springframework.boot.configurationsample.endpoint.SimpleEndpoint;
3534
import org.springframework.boot.configurationsample.endpoint.SimpleEndpoint2;
@@ -153,7 +152,7 @@ void incrementalEndpointBuildChangeCacheFlag() {
153152
assertThat(metadata).has(access("incremental", Access.UNRESTRICTED));
154153
assertThat(metadata).has(cacheTtl("incremental"));
155154
assertThat(metadata.getItems()).hasSize(3);
156-
project.replaceText(IncrementalEndpoint.class, "@OptionalParameter String param", "String param");
155+
project.replaceText(IncrementalEndpoint.class, "@Nullable String param", "String param");
157156
metadata = project.compile();
158157
assertThat(metadata)
159158
.has(Metadata.withGroup("management.endpoint.incremental").fromSource(IncrementalEndpoint.class));
@@ -205,16 +204,6 @@ void endpointWithNullableParameter() {
205204
assertThat(metadata.getItems()).hasSize(3);
206205
}
207206

208-
@Test
209-
void endpointWithOptionalParameter() {
210-
ConfigurationMetadata metadata = compile(OptionalParameterEndpoint.class);
211-
assertThat(metadata)
212-
.has(Metadata.withGroup("management.endpoint.optional").fromSource(OptionalParameterEndpoint.class));
213-
assertThat(metadata).has(access("optional", Access.UNRESTRICTED));
214-
assertThat(metadata).has(cacheTtl("optional"));
215-
assertThat(metadata.getItems()).hasSize(3);
216-
}
217-
218207
private Metadata.MetadataItemCondition access(String endpointId, Access defaultValue) {
219208
return defaultAccess(endpointId, endpointId, defaultValue);
220209
}

configuration-metadata/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironmentFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public MetadataGenerationEnvironment apply(ProcessingEnvironment environment) {
4949
TestConfigurationMetadataAnnotationProcessor.AUTOWIRED_ANNOTATION,
5050
TestConfigurationMetadataAnnotationProcessor.DEFAULT_VALUE_ANNOTATION, endpointAnnotations,
5151
TestConfigurationMetadataAnnotationProcessor.READ_OPERATION_ANNOTATION,
52-
TestConfigurationMetadataAnnotationProcessor.OPTIONAL_PARAMETER_ANNOTATION,
5352
TestConfigurationMetadataAnnotationProcessor.NAME_ANNOTATION);
5453
}
5554

configuration-metadata/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/test/TestConfigurationMetadataAnnotationProcessor.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ public class TestConfigurationMetadataAnnotationProcessor extends ConfigurationM
7575

7676
public static final String READ_OPERATION_ANNOTATION = "org.springframework.boot.configurationsample.ReadOperation";
7777

78-
public static final String OPTIONAL_PARAMETER_ANNOTATION = "org.springframework.boot.configurationsample.OptionalParameter";
79-
8078
public static final String NAME_ANNOTATION = "org.springframework.boot.configurationsample.Name";
8179

8280
public static final String ENDPOINT_ACCESS_ENUM = "org.springframework.boot.configurationsample.Access";
@@ -130,11 +128,6 @@ protected String readOperationAnnotation() {
130128
return READ_OPERATION_ANNOTATION;
131129
}
132130

133-
@Override
134-
protected String optionalParameterAnnotation() {
135-
return OPTIONAL_PARAMETER_ANNOTATION;
136-
}
137-
138131
@Override
139132
protected String nameAnnotation() {
140133
return NAME_ANNOTATION;

configuration-metadata/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/OptionalParameter.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

configuration-metadata/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/OptionalParameterEndpoint.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)