Skip to content

Commit c6045c3

Browse files
committed
Merge branch '3.4.x'
Closes gh-45301
2 parents cabc261 + e47d87f commit c6045c3

File tree

5 files changed

+42
-8
lines changed

5 files changed

+42
-8
lines changed

spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata-changelog-generator/src/main/java/org/springframework/boot/configurationmetadata/changelog/Changelog.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121

2222
import org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty;
2323
import org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository;
24+
import org.springframework.boot.configurationmetadata.Deprecation.Level;
2425

2526
/**
2627
* A changelog containing differences computed from two repositories of configuration
@@ -32,6 +33,7 @@
3233
* @author Stephane Nicoll
3334
* @author Andy Wilkinson
3435
* @author Phillip Webb
36+
* @author Yoobin Yoon
3537
*/
3638
record Changelog(String oldVersionNumber, String newVersionNumber, List<Difference> differences) {
3739

@@ -54,8 +56,13 @@ static List<Difference> computeDifferences(ConfigurationMetadataRepository oldMe
5456
}
5557
}
5658
for (ConfigurationMetadataProperty newProperty : newMetadata.getAllProperties().values()) {
57-
if ((!seenIds.contains(newProperty.getId())) && (!newProperty.isDeprecated())) {
58-
differences.add(new Difference(DifferenceType.ADDED, null, newProperty));
59+
if (!seenIds.contains(newProperty.getId())) {
60+
if (newProperty.isDeprecated() && newProperty.getDeprecation().getLevel() == Level.ERROR) {
61+
differences.add(new Difference(DifferenceType.DELETED, null, newProperty));
62+
}
63+
else if (!newProperty.isDeprecated()) {
64+
differences.add(new Difference(DifferenceType.ADDED, null, newProperty));
65+
}
5966
}
6067
}
6168
return List.copyOf(differences);

spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata-changelog-generator/src/test/java/org/springframework/boot/configurationmetadata/changelog/ChangelogTests.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
*
3030
* @author Stephane Nicoll
3131
* @author Andy Wilkinson
32+
* @author Yoobin Yoon
3233
*/
3334
class ChangelogTests {
3435

@@ -38,7 +39,7 @@ void diffContainsDifferencesBetweenLeftAndRightInputs() {
3839
assertThat(differences).isNotNull();
3940
assertThat(differences.oldVersionNumber()).isEqualTo("1.0");
4041
assertThat(differences.newVersionNumber()).isEqualTo("2.0");
41-
assertThat(differences.differences()).hasSize(4);
42+
assertThat(differences.differences()).hasSize(5);
4243
List<Difference> added = differences.differences()
4344
.stream()
4445
.filter((difference) -> difference.type() == DifferenceType.ADDED)
@@ -49,10 +50,12 @@ void diffContainsDifferencesBetweenLeftAndRightInputs() {
4950
.stream()
5051
.filter((difference) -> difference.type() == DifferenceType.DELETED)
5152
.toList();
52-
assertThat(deleted).hasSize(2)
53+
assertThat(deleted).hasSize(3)
5354
.anySatisfy((entry) -> assertProperty(entry.oldProperty(), "test.delete", String.class, "delete"))
5455
.anySatisfy(
55-
(entry) -> assertProperty(entry.newProperty(), "test.delete.deprecated", String.class, "delete"));
56+
(entry) -> assertProperty(entry.newProperty(), "test.delete.deprecated", String.class, "delete"))
57+
.anySatisfy((entry) -> assertProperty(entry.newProperty(), "test.removed.directly", String.class,
58+
"directlyRemoved"));
5659
List<Difference> deprecated = differences.differences()
5760
.stream()
5861
.filter((difference) -> difference.type() == DifferenceType.DEPRECATED)

spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata-changelog-generator/src/test/resources/sample-1.0.json

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
"deprecation": {
2727
"level": "warning"
2828
}
29+
},
30+
{
31+
"name": "test.delete.error",
32+
"type": "java.lang.String",
33+
"description": "Test delete error.",
34+
"defaultValue": "delete",
35+
"deprecation": {
36+
"level": "error"
37+
}
2938
}
3039
]
3140
}

spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata-changelog-generator/src/test/resources/sample-2.0.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131
"replacement": "test.add",
3232
"reason": "it was just bad"
3333
}
34+
},
35+
{
36+
"name": "test.removed.directly",
37+
"type": "java.lang.String",
38+
"description": "Test property removed without prior deprecation.",
39+
"defaultValue": "directlyRemoved",
40+
"deprecation": {
41+
"level": "error",
42+
"replacement": "test.new.property",
43+
"reason": "removed in third-party library without deprecation"
44+
}
3445
}
3546
]
36-
}
47+
}

spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata-changelog-generator/src/test/resources/sample.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ _None_.
3232
| `test.delete.deprecated`
3333
| `test.add`
3434
| it was just bad
35+
36+
| `test.removed.directly`
37+
| `test.new.property`
38+
| removed in third-party library without deprecation
3539
|======================

0 commit comments

Comments
 (0)