Skip to content

Commit 6045bfc

Browse files
committed
Fix changelog generator missing directly removed properties
The changelog generator did not detect properties that were added to a new version with error-level deprecation (indicating immediate removal). This commonly occurs when upgrading dependencies like Flyway 10, where properties are removed without prior deprecation. Modified the computeDifferences method to detect properties that only exist in the new metadata with error-level deprecation and properly mark them as DELETED in the changelog. Signed-off-by: yybmion <[email protected]>
1 parent c46d19f commit 6045bfc

File tree

4 files changed

+41
-11
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata-changelog-generator/src

4 files changed

+41
-11
lines changed

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

+18-6
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;
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

@@ -48,14 +50,24 @@ static List<Difference> computeDifferences(ConfigurationMetadataRepository oldMe
4850
String id = oldProperty.getId();
4951
seenIds.add(id);
5052
ConfigurationMetadataProperty newProperty = newMetadata.getAllProperties().get(id);
51-
Difference difference = Difference.compute(oldProperty, newProperty);
52-
if (difference != null) {
53-
differences.add(difference);
53+
if (newProperty == null) {
54+
differences.add(new Difference(DifferenceType.DELETED, oldProperty, null));
55+
}
56+
else {
57+
Difference difference = Difference.compute(oldProperty, newProperty);
58+
if (difference != null) {
59+
differences.add(difference);
60+
}
5461
}
5562
}
5663
for (ConfigurationMetadataProperty newProperty : newMetadata.getAllProperties().values()) {
57-
if ((!seenIds.contains(newProperty.getId())) && (!newProperty.isDeprecated())) {
58-
differences.add(new Difference(DifferenceType.ADDED, null, newProperty));
64+
if (!seenIds.contains(newProperty.getId())) {
65+
if (newProperty.isDeprecated() && newProperty.getDeprecation().getLevel() == Deprecation.Level.ERROR) {
66+
differences.add(new Difference(DifferenceType.DELETED, null, newProperty));
67+
}
68+
else if (!newProperty.isDeprecated()) {
69+
differences.add(new Difference(DifferenceType.ADDED, null, newProperty));
70+
}
5971
}
6072
}
6173
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-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 Upgrade 10"
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 Upgrade 10
3539
|======================

0 commit comments

Comments
 (0)