class DeadlockHealthCheck implements HealthCheck {

    @Override
    public HealthCheckResponse call() {
        if (disabled) {
            LOGGER.log(Level.FINEST, "Running in graal native image, this health-check always returns up.");
            return HealthCheckResponse.builder()
                    .name(NAME)
                    .withData("enabled", "false")
                    .withData("description", "in native image")
                    .up()
                    .build();
        }

        boolean noDeadLock = false;
        try {
            // Thanks to https://stackoverflow.com/questions/1102359/programmatic-deadlock-detection-in-java#1102410
            noDeadLock = (threadBean.findDeadlockedThreads() == null);
        } catch (Throwable e) {
            // ThreadBean does not work - probably in native image
            LOGGER.log(Level.FINEST, "Failed to find deadlocks in ThreadMXBean, ignoring this healthcheck", e);
        }
        return HealthCheckResponse.named(NAME)
                .state(noDeadLock)
                .build();
    }

    @Inject  DeadlockHealthCheck(ThreadMXBean threadBean);

}