Home / Class/ BeanInCycle Class — spring-boot Architecture

BeanInCycle Class — spring-boot Architecture

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

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java lines 140–204

	private static final class BeanInCycle {

		private final @Nullable String name;

		private final String description;

		private BeanInCycle(BeanCreationException ex) {
			this.name = ex.getBeanName();
			this.description = determineDescription(ex);
		}

		private String determineDescription(BeanCreationException ex) {
			if (StringUtils.hasText(ex.getResourceDescription())) {
				return String.format(" defined in %s", ex.getResourceDescription());
			}
			InjectionPoint failedInjectionPoint = findFailedInjectionPoint(ex);
			if (failedInjectionPoint != null && failedInjectionPoint.getField() != null) {
				return String.format(" (field %s)", failedInjectionPoint.getField());
			}
			return "";
		}

		private @Nullable InjectionPoint findFailedInjectionPoint(BeanCreationException ex) {
			if (ex instanceof UnsatisfiedDependencyException unsatisfiedDependencyException) {
				return unsatisfiedDependencyException.getInjectionPoint();
			}
			return null;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj) {
				return true;
			}
			if (obj == null || getClass() != obj.getClass()) {
				return false;
			}
			return Objects.equals(this.name, ((BeanInCycle) obj).name);
		}

		@Override
		public int hashCode() {
			return Objects.hashCode(this.name);
		}

		@Override
		public String toString() {
			return this.name + this.description;
		}

		static @Nullable BeanInCycle get(Throwable ex) {
			if (ex instanceof BeanCreationException beanCreationException) {
				return get(beanCreationException);
			}
			return null;
		}

		private static @Nullable BeanInCycle get(BeanCreationException ex) {
			if (StringUtils.hasText(ex.getBeanName())) {
				return new BeanInCycle(ex);
			}
			return null;
		}

	}

Domain

Analyze Your Own Codebase

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

Try Supermodel Free