Added guards on config splitting and default value is now code

This commit is contained in:
Marcin Grzejszczak
2020-11-16 14:08:52 +01:00
parent 17aa219a0d
commit ac966b7be5
3 changed files with 13 additions and 4 deletions

View File

@@ -43,9 +43,18 @@ class ConfigurationPropertiesAggregator {
// |foo|bar|baz -> foo|bar|baz -> split ->
// foo,bar,baz
String[] strings = s.substring(1).split("\\|");
if (strings.length == 3) {
return new ConfigurationProperty(
strings[0].trim(), strings[1].trim(),
strings[2].trim());
}
else if (strings.length == 2) {
return new ConfigurationProperty(
strings[0].trim(), strings[1].trim(),
"");
}
return new ConfigurationProperty(
strings[0].trim(), strings[1].trim(),
strings[2].trim());
strings[0].trim(), "", "");
});
}
catch (IOException e) {

View File

@@ -1,7 +1,7 @@
|===
|Name | Default | Description
{{#each properties}} |{{name}} | {{defaultValue}} | {{description}}
{{#each properties}} |{{name}} | `{{defaultValue}}` | {{description}}
{{/each}}
|===

View File

@@ -104,7 +104,7 @@ public class GenerateReleaseTrainDocsTests {
BDDAssertions.then(generatedAdocs).isNotEmptyDirectory();
BDDAssertions.then(configProps(generatedAdocs)).contains(
"|spring.sleuth.async.configurer.enabled | true | Enable default AsyncConfigurer.");
"|spring.sleuth.async.configurer.enabled | `true` | Enable default AsyncConfigurer.");
}
private String configProps(File file) throws IOException {