Home / Class/ AbstractFailureAnalyzer Class — spring-boot Architecture

AbstractFailureAnalyzer Class — spring-boot Architecture

Architecture documentation for the AbstractFailureAnalyzer class in AbstractFailureAnalyzer.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/main/java/org/springframework/boot/diagnostics/AbstractFailureAnalyzer.java lines 32–74

public abstract class AbstractFailureAnalyzer<T extends Throwable> implements FailureAnalyzer {

	@Override
	public @Nullable FailureAnalysis analyze(Throwable failure) {
		T cause = findCause(failure, getCauseType());
		return (cause != null) ? analyze(failure, cause) : null;
	}

	/**
	 * Returns an analysis of the given {@code rootFailure}, or {@code null} if no
	 * analysis was possible.
	 * @param rootFailure the root failure passed to the analyzer
	 * @param cause the actual found cause
	 * @return the analysis or {@code null}
	 */
	protected abstract @Nullable FailureAnalysis analyze(Throwable rootFailure, T cause);

	/**
	 * Return the cause type being handled by the analyzer. By default the class generic
	 * is used.
	 * @return the cause type
	 */
	@SuppressWarnings("unchecked")
	protected Class<? extends T> getCauseType() {
		Class<? extends T> type = (Class<? extends T>) ResolvableType
			.forClass(AbstractFailureAnalyzer.class, getClass())
			.resolveGeneric();
		Assert.state(type != null, "Unable to resolve generic");
		return type;
	}

	@SuppressWarnings("unchecked")
	protected final <E extends Throwable> @Nullable E findCause(@Nullable Throwable failure, Class<E> type) {
		while (failure != null) {
			if (type.isInstance(failure)) {
				return (E) failure;
			}
			failure = failure.getCause();
		}
		return null;
	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free