Skip to content

Commit 60b2e35

Browse files
committed
Merge branch '4.0.x'
Closes gh-49061
2 parents 5922311 + 05e61ff commit 60b2e35

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,9 @@ private String cleanUpJavaDoc(String javadoc) {
272272
char lastChar = '.';
273273
for (int i = 0; i < javadoc.length(); i++) {
274274
char ch = javadoc.charAt(i);
275-
boolean repeatedSpace = ch == ' ' && lastChar == ' ';
276-
if (ch != '\r' && ch != '\n' && !repeatedSpace) {
275+
ch = (ch == '\r' || ch == '\n') ? ' ' : ch;
276+
boolean repeatedSpace = (ch == ' ' && lastChar == ' ');
277+
if (!repeatedSpace) {
277278
result.append(ch);
278279
lastChar = ch;
279280
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ void descriptionProperties() {
234234
.fromSource(DescriptionProperties.class)
235235
.withDescription(
236236
"This is a lengthy description that spans across multiple lines to showcase that the line separators are cleaned automatically."));
237+
assertThat(metadata).has(Metadata.withProperty("description.multi-line-whitespace", String.class)
238+
.fromSource(DescriptionProperties.class)
239+
.withDescription("This is an example of a description with unusual whitespace after a new line."));
237240
}
238241

239242
@Test

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ public class DescriptionProperties {
3737
*/
3838
private String multiLine;
3939

40+
// @formatter:off
41+
/**
42+
* This is an example of a description
43+
*with unusual whitespace after a new line.
44+
*/
45+
private String multiLineWhitespace;
46+
// @formatter:on
47+
4048
public String getSimple() {
4149
return this.simple;
4250
}
@@ -53,4 +61,12 @@ public void setMultiLine(String multiLine) {
5361
this.multiLine = multiLine;
5462
}
5563

64+
public String getMultiLineWhitespace() {
65+
return this.multiLineWhitespace;
66+
}
67+
68+
public void setMultiLineWhitespace(String multiLineWhitespace) {
69+
this.multiLineWhitespace = multiLineWhitespace;
70+
}
71+
5672
}

0 commit comments

Comments
 (0)