ComponentHealth { static ComponentHealth ofComponent(Component component) { Throwable t = null; try { CheckResult check = component.check(); if (!check.ok()) t = check.error(); } catch (Throwable unexpected) { Call.propagateIfFatal(unexpected); t = unexpected; } if (t == null) return new ComponentHealth(component.toString(), STATUS_UP, null); String message = t.getMessage(); String error = t.getClass().getName() + (message != null ? ": " + message : ""); return new ComponentHealth(component.toString(), STATUS_DOWN, error); } ComponentHealth(String name, String status, String error);   }
@Test public void addsMessageToDetails() { ComponentHealth health = ComponentHealth.ofComponent(new Component() { @Override public CheckResult check() { return CheckResult.failed(new IOException("socket disconnect")); } }); assertThat(health.error) .isEqualTo("java.io.IOException: socket disconnect"); }
@Test public void doesntAddNullMessageToDetails() { ComponentHealth health = ComponentHealth.ofComponent(new Component() { @Override public CheckResult check() { return CheckResult.failed(ClosedSessionException.get()); } }); assertThat(health.error) .isEqualTo("com.linecorp.armeria.common.ClosedSessionException"); }