use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BeanCurrentlyInCreationFailureAnalyzer method analyze.
@Override
protected FailureAnalysis analyze(Throwable rootFailure, BeanCurrentlyInCreationException cause) {
List<BeanInCycle> cycle = new ArrayList<>();
Throwable candidate = rootFailure;
int cycleStart = -1;
while (candidate != null) {
BeanInCycle beanInCycle = BeanInCycle.get(candidate);
if (beanInCycle != null) {
int index = cycle.indexOf(beanInCycle);
if (index == -1) {
cycle.add(beanInCycle);
}
cycleStart = (cycleStart == -1 ? index : cycleStart);
}
candidate = candidate.getCause();
}
String message = buildMessage(cycle, cycleStart);
return new FailureAnalysis(message, null, cause);
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BeanCurrentlyInCreationFailureAnalyzerTests method performAnalysis.
private FailureAnalysis performAnalysis(Class<?> configuration) {
FailureAnalysis analysis = this.analyzer.analyze(createFailure(configuration));
assertThat(analysis).isNotNull();
return analysis;
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BindFailureAnalyzerTests method bindExceptionWithFieldErrorsDueToValidationFailure.
@Test
public void bindExceptionWithFieldErrorsDueToValidationFailure() {
FailureAnalysis analysis = performAnalysis(FieldValidationFailureConfiguration.class);
assertThat(analysis.getDescription()).contains(failure("test.foo.foo", "null", "may not be null"));
assertThat(analysis.getDescription()).contains(failure("test.foo.value", "0", "at least five"));
assertThat(analysis.getDescription()).contains(failure("test.foo.nested.bar", "null", "may not be null"));
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class ValidationFailureAnalyzerTests method analyzesMissingRequiredConfiguration.
@Test
void analyzesMissingRequiredConfiguration() {
FailureAnalysis analysis = new ValidationFailureAnalyzer().analyze(createFailure(MissingAccountIdAndApiKeyConfiguration.class));
assertThat(analysis).isNotNull();
assertThat(analysis.getCause().getMessage()).contains("management.metrics.export.newrelic.apiKey was 'null'");
assertThat(analysis.getDescription()).isEqualTo(String.format("Invalid Micrometer configuration detected:%n%n" + " - management.metrics.export.newrelic.apiKey was 'null' but it is required when publishing to Insights API%n" + " - management.metrics.export.newrelic.accountId was 'null' but it is required when publishing to Insights API"));
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class HikariDriverConfigurationFailureAnalyzerTests method failureAnalysisIsPerformed.
@Test
void failureAnalysisIsPerformed() {
FailureAnalysis failureAnalysis = performAnalysis(TestConfiguration.class);
assertThat(failureAnalysis).isNotNull();
assertThat(failureAnalysis.getDescription()).isEqualTo("Configuration of the Hikari connection pool failed: 'dataSourceClassName' is not supported.");
assertThat(failureAnalysis.getAction()).contains("Spring Boot auto-configures only a driver");
}
Aggregations