Fix failure analyzer message

See gh-16581
pull/16611/head
Madhura Bhave 6 years ago
parent e9447b0dbf
commit ba196b47ac

@ -32,21 +32,21 @@ public class InvalidConfigurationPropertiesFailureAnalyzer
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
InvalidConfigurationPropertiesException cause) {
Class<?> configurationProperties = cause.getConfigurationProperties();
String configurationProperties = cause.getConfigurationProperties().getName();
String component = cause.getComponent().getSimpleName();
return new FailureAnalysis(getDescription(configurationProperties, component),
getAction(configurationProperties, component), cause);
}
private String getDescription(Class<?> configurationProperties, String component) {
return configurationProperties.getName()
private String getDescription(String configurationProperties, String component) {
return configurationProperties
+ " is annotated with @ConfigurationProperties and @" + component
+ ". This may cause the @ConfigurationProperties bean to be registered twice.";
}
private String getAction(Class<?> configurationProperties, String component) {
return "Remove either @ConfigurationProperties or @" + component + " from "
+ configurationProperties;
private String getAction(String configurationProperties, String component) {
return "Remove @" + component + " from " + configurationProperties
+ " or consider disabling automatic @ConfigurationProperties scanning.";
}
}

@ -38,9 +38,9 @@ public class InvalidConfigurationPropertiesFailureAnalyzerTests {
public void analysisForInvalidConfigurationOfConfigurationProperties() {
FailureAnalysis analysis = performAnalysis();
assertThat(analysis.getDescription()).isEqualTo(getDescription());
assertThat(analysis.getAction())
.isEqualTo("Remove either @ConfigurationProperties or @Component from "
+ TestProperties.class);
assertThat(analysis.getAction()).isEqualTo("Remove @Component from "
+ TestProperties.class.getName()
+ " or consider disabling automatic @ConfigurationProperties scanning.");
}
private String getDescription() {

Loading…
Cancel
Save