Skip to content

Commit 533df5e

Browse files
committed
Merge branch '4.1.x'
Closes gh-51099
2 parents a370fa9 + b0c21aa commit 533df5e

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ protected ItemDeprecation resolveItemDeprecation(MetadataGenerationEnvironment e
5454

5555
@Override
5656
protected boolean isMarkedAsNested(MetadataGenerationEnvironment environment) {
57-
return environment.getNestedConfigurationPropertyAnnotation(this.recordComponent) != null;
57+
return environment.getNestedConfigurationPropertyAnnotation(this.recordComponent) != null
58+
|| environment.getNestedConfigurationPropertyAnnotation(getGetter()) != null;
5859
}
5960

6061
@Override

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.boot.configurationsample.method.NestedPropertiesMethod;
3636
import org.springframework.boot.configurationsample.method.NestedPropertiesMethodImmutable;
3737
import org.springframework.boot.configurationsample.record.ExampleRecord;
38+
import org.springframework.boot.configurationsample.record.NestedPropertiesOnMethodRecord;
3839
import org.springframework.boot.configurationsample.record.NestedPropertiesRecord;
3940
import org.springframework.boot.configurationsample.record.RecordWithGetter;
4041
import org.springframework.boot.configurationsample.recursive.RecursiveProperties;
@@ -599,6 +600,15 @@ void recordNested() {
599600
assertThat(metadata).has(Metadata.withProperty("record-nested.inner.nested.my-nested-property"));
600601
}
601602

603+
@Test
604+
void recordNestedMethod() {
605+
ConfigurationMetadata metadata = compile(NestedPropertiesOnMethodRecord.class);
606+
assertThat(metadata).has(Metadata.withGroup("record-nested.nested"));
607+
assertThat(metadata).has(Metadata.withProperty("record-nested.nested.my-nested-property"));
608+
assertThat(metadata).has(Metadata.withGroup("record-nested.inner.nested"));
609+
assertThat(metadata).has(Metadata.withProperty("record-nested.inner.nested.my-nested-property"));
610+
}
611+
602612
@Test
603613
void shouldNotMarkDbcp2UsernameOrPasswordAsDeprecated() {
604614
ConfigurationMetadata metadata = compile(Dbcp2Configuration.class);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.configurationsample.record;
18+
19+
import org.springframework.boot.configurationsample.TestConfigurationProperties;
20+
import org.springframework.boot.configurationsample.TestNestedConfigurationProperty;
21+
22+
@TestConfigurationProperties("record-nested")
23+
public record NestedPropertiesOnMethodRecord(String myProperty, NestedRecord nested, InnerPropertiesRecord inner) {
24+
25+
@TestNestedConfigurationProperty
26+
public NestedRecord nested() {
27+
return this.nested;
28+
}
29+
30+
public record InnerPropertiesRecord(String myInnerProperty, NestedRecord nested) {
31+
32+
@TestNestedConfigurationProperty
33+
public NestedRecord nested() {
34+
return this.nested;
35+
}
36+
}
37+
38+
}

0 commit comments

Comments
 (0)