From ba196b47ac5c712b248c1c162f0667087d053528 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Fri, 19 Apr 2019 09:37:31 -0700 Subject: [PATCH] Fix failure analyzer message See gh-16581 --- ...nvalidConfigurationPropertiesFailureAnalyzer.java | 12 ++++++------ ...dConfigurationPropertiesFailureAnalyzerTests.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertiesFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertiesFailureAnalyzer.java index ba210b5e36..3fa7e2e038 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertiesFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertiesFailureAnalyzer.java @@ -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."; } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertiesFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertiesFailureAnalyzerTests.java index 463b93721c..6aeaec3d98 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertiesFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertiesFailureAnalyzerTests.java @@ -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() {