From 2021f90444604cc67989054b50643502c1006914 Mon Sep 17 00:00:00 2001 From: alsin Date: Fri, 15 Sep 2023 18:16:56 +0200 Subject: [PATCH] Don't try to cast metric registry before it is checked for null (#2076) * Don't try to cast metric registry before it is checked for null * Simplify the condition check * Use previously obtained object instead of calling the same getter one more time --------- Co-authored-by: Alexander Sinuskin --- .../metrics/dropwizard/CodahaleHealthChecker.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zaxxer/hikari/metrics/dropwizard/CodahaleHealthChecker.java b/src/main/java/com/zaxxer/hikari/metrics/dropwizard/CodahaleHealthChecker.java index 4ccde1fd..c46f9f81 100644 --- a/src/main/java/com/zaxxer/hikari/metrics/dropwizard/CodahaleHealthChecker.java +++ b/src/main/java/com/zaxxer/hikari/metrics/dropwizard/CodahaleHealthChecker.java @@ -16,10 +16,6 @@ package com.zaxxer.hikari.metrics.dropwizard; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.concurrent.TimeUnit; - import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.Timer; import com.codahale.metrics.health.HealthCheck; @@ -27,6 +23,10 @@ import com.codahale.metrics.health.HealthCheckRegistry; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.pool.HikariPool; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.concurrent.TimeUnit; + /** * Provides Dropwizard HealthChecks. Two health checks are provided: *