Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ private String detectMapValueReplacementType(String fullId) {
if (lastDot != -1) {
ConfigurationMetadataProperty property = this.allProperties
.get(fullId.substring(0, lastDot));
if (property == null) {
return null;
}
String type = property.getType();
if (type != null && type.startsWith(Map.class.getName())) {
int lastComma = type.lastIndexOf(',');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ public void reasonIsProvidedIfPropertyCouldNotBeRenamed() throws IOException {
+ "'test.inconvertible' uses an incompatible target type");
}

@Test
public void invalidReplacementHandled() throws IOException {
this.environment.getPropertySources().addFirst(loadPropertySource("first",
"config/config-error-invalid-replacement.properties"));
String report = createErrorReport(
loadRepository("metadata/sample-metadata-invalid-replacement.json"));
assertThat(report).isNotNull();
assertThat(report).containsSubsequence("Property source 'first'",
"deprecated.six.test", "Line: 1", "Reason",
"Replacement key 'does.not.exist' uses an incompatible target type");
assertThat(report).doesNotContain("null");
}

private List<String> mapToNames(PropertySources sources) {
List<String> names = new ArrayList<>();
for (PropertySource<?> source : sources) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deprecated.six.test=abc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"properties": [
{
"name": "deprecated.six.test",
"type": "java.lang.String",
"deprecation": {
"replacement": "does.not.exist",
"level": "error"
}
}
]
}