org.springframework.boot.diagnostics.FailureAnalysis Java Examples

The following examples show how to use org.springframework.boot.diagnostics.FailureAnalysis. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WicketDependencyVersionCheckerFailureAnalyzer.java    From wicket-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, WicketDependencyMismatchDetectedException cause) {
	String descriptionMessage = "One or more Wicket dependencies (jars) doesn't match the wicket-core dependency.\n\r" 
			+"Wicket Core Version: " + cause.getWicketCoreVersion() + newline;
	for(MavenDependency dependency :cause.getDependencies()) {
		descriptionMessage += "\t" + dependency + newline;
	}
	
	String actionMessage = "Please check the Wicket versions configured in your dependency management system (Maven, Gradle, ...) " + newline
			+ "You can disable this check via the property:" + newline
			+ "\twicket.verifier.dependencies.enabled=false." + newline
			+ "You can prevent throwing the exception but still log the detected problems via the property:" + newline
			+ "\twicket.verifier.dependencies.throw-exception-on-dependency-version-mismatch=false";
	
	return new FailureAnalysis(descriptionMessage, actionMessage, cause);
}
 
Example #2
Source File: LiquibaseXmlElementClassNotFoundFailureAnalyzerTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
void analysisWhenStackTraceContainsLiquibaseProPackage() {
    ClassNotFoundException failure = new ClassNotFoundException("javax.xml.bind.annotation.XmlElement");
    StackTraceElement[] stackTrace = new StackTraceElement[] {
        new StackTraceElement("com.example.test.TestClass", "test()", null, -1),
        new StackTraceElement("com.example.test.TestClass", "testAgain()", null, -1),
        new StackTraceElement("liquibase.pro.packaged.k1", "k()", null, -1)
    };
    failure.setStackTrace(stackTrace);

    FailureAnalysis analysis = underTest.analyze(failure);
    assertThat(analysis).isNotNull();
    assertThat(analysis.getCause()).isSameAs(failure);
    assertThat(analysis.getAction()).isEqualTo("Set the liquibase version to 3.8.0");
    assertThat(analysis.getDescription()).isEqualTo("Liquibase failed to initialize due to javax.xml.bin.annotation.XmlElement not being present."
        + " Liquibase Versions starting from 3.8.1 have problems on Java 11."
        + " See https://liquibase.jira.com/browse/CORE-3537 for more information.");
}
 
Example #3
Source File: LiquibaseXmlElementClassNotFoundFailureAnalyzer.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, ClassNotFoundException cause) {
    String causeMessage = cause.getMessage();

    if (causeMessage != null && causeMessage.contains("javax.xml.bind.annotation.XmlElement")) {
        for (StackTraceElement stackTraceElement : cause.getStackTrace()) {
            if (stackTraceElement.getClassName().startsWith("liquibase.pro.packaged")) {
                return new FailureAnalysis(
                    "Liquibase failed to initialize due to javax.xml.bin.annotation.XmlElement not being present."
                        + " Liquibase Versions starting from 3.8.1 have problems on Java 11."
                        + " See https://liquibase.jira.com/browse/CORE-3537 for more information.",
                    "Set the liquibase version to 3.8.0",
                    cause
                );
            }
        }
    }

    return null;
}
 
Example #4
Source File: QuickFixJAutoConfigFailureAnalyzer.java    From quickfixj-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, QuickFixJBaseException cause) {
	String descriptionMessage = cause.getMessage();
	String actionMessage = cause.getMessage();

	if (cause instanceof ConfigurationException) {
		descriptionMessage = "A configuration error has been detected in the QuickFixJ settings provided.";
		actionMessage = "Please configure your QuickFixJ settings as per the documentation: https://www.quickfixj.org/usermanual/2.1.0/usage/configuration.html";
	}

	if (cause instanceof SettingsNotFoundException) {
		descriptionMessage = "The QuickFixJ settings file could not be found.";
		actionMessage = "Please provide a QuickFixJ settings file on the property 'config' for the client/server section in your configuration file.";
	}

	return new FailureAnalysis(descriptionMessage, actionMessage, cause);
}
 
Example #5
Source File: QuickFixJAutoConfigFailureAnalyzerTest.java    From quickfixj-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAnalyzeSettingsNotFoundException() {

	// Given
	QuickFixJAutoConfigFailureAnalyzer analyzer = new QuickFixJAutoConfigFailureAnalyzer();
	SettingsNotFoundException exception = new SettingsNotFoundException("Error", new RuntimeException());

	// When
	FailureAnalysis analyze = analyzer.analyze(null, exception);

	assertThat(analyze.getAction()).contains("Please provide a QuickFixJ settings file");
	assertThat(analyze.getDescription()).contains("The QuickFixJ settings file could not be found.");
	assertThat(analyze.getCause()).isEqualTo(exception);
}
 
Example #6
Source File: RequiredServiceInstanceServiceBeanFailureAnalyzer.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, ServiceInstanceServiceBeanDoesNotExistException cause) {
	String description = String.format("Service brokers must implement the '%s' and " +
			"provide implementations of the required methods of that interface.", ServiceInstanceService.class);
	String action = String.format("Consider defining a bean of type '%s' in your configuration. See " +
					"the reference documentation for more information: " + REFERENCE_DOC,
			ServiceInstanceService.class);
	return new FailureAnalysis(description, action, cause);
}
 
Example #7
Source File: RequiredCatalogBeanFailureAnalyzer.java    From spring-cloud-open-service-broker with Apache License 2.0 5 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, CatalogDefinitionDoesNotExistException cause) {
	String description = "A 'service broker catalog' is required for Spring Cloud Open Service Broker applications";
	String action = String.format("Consider defining a catalog in properties or a bean of type" +
					" '%s' in your configuration. Alternatively, you may implement a service of type '%s'. See " +
					"the reference documentation for more information: " + REFERENCE_DOC, Catalog.class,
			CatalogService.class);
	return new FailureAnalysis(description, action, cause);
}
 
Example #8
Source File: ModelMapConfigurationFailureAnalyzer.java    From building-microservices with Apache License 2.0 5 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
		ConfigurationException cause) {
	StringBuilder description = new StringBuilder();
	description.append("ModelMapper configuration failed:\n");
	for (ErrorMessage message : cause.getErrorMessages()) {
		description.append(message.getMessage());
	}
	return new FailureAnalysis(description.toString(),
			"Fix ModelMapper configuration", cause);
}
 
Example #9
Source File: ClientNotConfiguredFailureAnalyzer.java    From spring-credhub with Apache License 2.0 5 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, NoSuchBeanDefinitionException cause) {
	if (hasCredHubProperties() && isMissingSpringSecurityOAuth2Bean(cause.getBeanType())) {
		return new FailureAnalysis(getDescription(), getAction(), cause);
	}
	return null;
}
 
Example #10
Source File: QuickFixJAutoConfigFailureAnalyzerTest.java    From quickfixj-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAnalyzeAnyException() {

	// Given
	QuickFixJAutoConfigFailureAnalyzer analyzer = new QuickFixJAutoConfigFailureAnalyzer();
	QuickFixJBaseException exception = new QuickFixJBaseException("Error message", new RuntimeException());

	// When
	FailureAnalysis analyze = analyzer.analyze(null, exception);

	assertThat(analyze.getAction()).contains("Error message");
	assertThat(analyze.getDescription()).contains("Error message");
	assertThat(analyze.getCause()).isEqualTo(exception);
}
 
Example #11
Source File: QuickFixJAutoConfigFailureAnalyzerTest.java    From quickfixj-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAnalyzeConfigurationException() {

	// Given
	QuickFixJAutoConfigFailureAnalyzer analyzer = new QuickFixJAutoConfigFailureAnalyzer();
	ConfigurationException exception = new ConfigurationException("Error", new RuntimeException());

	// When
	FailureAnalysis analyze = analyzer.analyze(null, exception);

	assertThat(analyze.getAction()).contains("Please configure your QuickFixJ settings");
	assertThat(analyze.getDescription()).contains("A configuration error has been detected in the QuickFixJ settings provided.");
	assertThat(analyze.getCause()).isEqualTo(exception);
}
 
Example #12
Source File: NacosConnectionFailureAnalyzer.java    From spring-cloud-alibaba with Apache License 2.0 5 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
		NacosConnectionFailureException cause) {
	return new FailureAnalysis(
			"Application failed to connect to Nacos server: \""
					+ cause.getServerAddr() + "\"",
			"Please check your Nacos server config", cause);
}
 
Example #13
Source File: GitUriFailureAnalyzer.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
		IllegalStateException cause) {
	if (JGitEnvironmentRepository.MESSAGE.equalsIgnoreCase(cause.getMessage())) {
		return new FailureAnalysis(DESCRIPTION, ACTION, cause);
	}
	return null;
}
 
Example #14
Source File: UnknownErrorFailureAnalyzer.java    From thinking-in-spring-boot-samples with Apache License 2.0 5 votes vote down vote up
@Override
public FailureAnalysis analyze(Throwable failure) {
    if (failure instanceof UnknownError) { // 判断上游异常类型判断
        return new FailureAnalysis("未知错误", "请重启尝试", failure);
    }
    return null;
}
 
Example #15
Source File: ConsoleFailureAnalysisReporter.java    From thinking-in-spring-boot-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void report(FailureAnalysis analysis) {
    System.out.printf("故障描述:%s \n执行动作:%s \n异常堆栈:%s \n",
            analysis.getDescription(),
            analysis.getAction(),
            analysis.getCause());
}
 
Example #16
Source File: MyBeanNotOfRequiredTypeFailureAnalyzer.java    From tutorials with MIT License 4 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, BeanNotOfRequiredTypeException cause) {
    return new FailureAnalysis(getDescription(cause), getAction(cause), cause);
}
 
Example #17
Source File: CompatibilityNotMetFailureAnalyzer.java    From spring-cloud-commons with Apache License 2.0 4 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
		CompatibilityNotMetException cause) {
	return new FailureAnalysis(getDescription(cause), getAction(cause), cause);
}
 
Example #18
Source File: NoSuchBeanExceptionAnalyzer.java    From WeBASE-Collect-Bee with Apache License 2.0 4 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, NoSuchBeanDefinitionException cause) {
    return new FailureAnalysis(cause.getMessage(),
            "please check your package path of java contract files and system.contractPackName in application.properties. Ensure your config is equal to your java package. eg. the default config is system.contractPackName=org.fisco.bcos.temp just as it in HelloWorld.Java",
            cause);
}
 
Example #19
Source File: AbstractServiceBrokerWebAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 4 votes vote down vote up
protected void assertFailureAnalysis(Throwable t) {
	FailureAnalyzer analyzer = new RequiredServiceInstanceServiceBeanFailureAnalyzer();
	FailureAnalysis analysis = analyzer.analyze(t);
	assertThat(analysis).isNotNull();
	assertThat(analysis.getDescription()).isEqualTo(ANALYZER_DESCRIPTION);
}
 
Example #20
Source File: ServiceBrokerAutoConfigurationTest.java    From spring-cloud-open-service-broker with Apache License 2.0 4 votes vote down vote up
private void assertFailureAnalysis(Throwable t) {
	FailureAnalyzer analyzer = new RequiredCatalogBeanFailureAnalyzer();
	FailureAnalysis analysis = analyzer.analyze(t);
	assertThat(analysis).isNotNull();
	assertThat(analysis.getDescription()).isEqualTo(ANALYZER_DESCRIPTION);
}
 
Example #21
Source File: NacosFailureAnalyzer.java    From nacos-spring-boot-project with Apache License 2.0 4 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, NacosException cause) {
	StringBuilder description = new StringBuilder();
	switch (cause.getErrCode()) {
	case NacosException.CLIENT_INVALID_PARAM:
		description.append("client error: invalid param");
		break;
	case NacosException.CLIENT_OVER_THRESHOLD:
		description.append("client error: over client threshold");
		break;
	case NacosException.BAD_GATEWAY:
		description.append("server error: bad gateway");
		break;
	case NacosException.CONFLICT:
		description.append("server error: conflict");
		break;
	case NacosException.INVALID_PARAM:
		description.append("server error: invalid param");
		break;
	case NacosException.NO_RIGHT:
		description.append("server error: no right");
		break;
	case NacosException.OVER_THRESHOLD:
		description.append("server error: over threshold");
		break;
	case NacosException.SERVER_ERROR:
		description.append("server error: such as timeout");
		break;
	default:
		description.append("unknown reason");
	}
	description.append(". ").append(cause.getErrMsg());
	String action;
	if (description.toString().contains("client")) {
		action = "please check your client configuration";
	}
	else {
		action = "please check server status";
	}
	return new FailureAnalysis(description.toString(), action, cause);
}
 
Example #22
Source File: EclairFailureAnalyzer.java    From eclair with Apache License 2.0 4 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, AnnotationUsageException cause) {
    return new FailureAnalysis(buildDescription(cause), cause.getAction(), cause);
}
 
Example #23
Source File: JwtTokenFailureAnalyzer.java    From alibaba-rsocket-broker with Apache License 2.0 4 votes vote down vote up
@Override
protected FailureAnalysis analyze(Throwable rootFailure, JwtTokenNotFoundException cause) {
    return new FailureAnalysis(getDescription(cause), getAction(cause), cause);
}