This commit is contained in:
Phillip Webb
2018-01-29 09:46:52 -08:00
parent 488965bb06
commit af50a18da9
15 changed files with 42 additions and 43 deletions

View File

@@ -89,8 +89,9 @@ class PropertiesMigrationReport {
return deprecation.getShortReason();
}
if (StringUtils.hasText(deprecation.getReplacement())) {
return String.format("Reason: Replacement key '%s' uses an incompatible "
+ "target type", deprecation.getReplacement());
return String.format(
"Reason: Replacement key '%s' uses an incompatible " + "target type",
deprecation.getReplacement());
}
return "none";
}

View File

@@ -118,7 +118,7 @@ class PropertiesMigrationReporter {
}
private boolean isCompatibleType(String currentType, String replacementType) {
if (replacementType == null || currentType == null) {
if (replacementType == null || currentType == null) {
return false;
}
if (replacementType.equals(currentType)) {
@@ -126,20 +126,19 @@ class PropertiesMigrationReporter {
}
if (replacementType.equals(Duration.class.getName())
&& (currentType.equals(Long.class.getName())
|| currentType.equals(Integer.class.getName()))) {
|| currentType.equals(Integer.class.getName()))) {
return true;
}
return false;
}
private String detectMapValueReplacementType(String fullId) {
int i = fullId.lastIndexOf('.');
if (i != -1) {
ConfigurationMetadataProperty property = this.allProperties.get(
fullId.substring(0, i));
int lastDot = fullId.lastIndexOf('.');
if (lastDot != -1) {
ConfigurationMetadataProperty property = this.allProperties
.get(fullId.substring(0, lastDot));
String type = property.getType();
if (type != null
&& type.startsWith(Map.class.getName())) {
if (type != null && type.startsWith(Map.class.getName())) {
int lastComma = type.lastIndexOf(',');
if (lastComma != -1) {
return type.substring(lastComma + 1, type.length() - 1).trim();

View File

@@ -125,8 +125,7 @@ public class PropertiesMigrationReporterTests {
content.put("test.cache-seconds", 50);
content.put("test.time-to-live-ms", 1234L);
content.put("test.ttl", 5678L);
propertySources.addFirst(
new MapPropertySource("test", content));
propertySources.addFirst(new MapPropertySource("test", content));
assertThat(propertySources).hasSize(2);
String report = createWarningReport(
loadRepository("metadata/type-conversion-metadata.json"));