diff --git a/paimon-core/src/test/java/org/apache/paimon/metrics/commit/CommitMetricsTest.java b/paimon-core/src/test/java/org/apache/paimon/metrics/commit/CommitMetricsTest.java index b2599238aae3..0ca839fee7c9 100644 --- a/paimon-core/src/test/java/org/apache/paimon/metrics/commit/CommitMetricsTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/metrics/commit/CommitMetricsTest.java @@ -25,6 +25,7 @@ import org.apache.paimon.metrics.Metric; import org.apache.paimon.metrics.MetricGroup; import org.apache.paimon.metrics.Metrics; +import org.apache.paimon.utils.ExceptionUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -58,7 +59,19 @@ public void afterEach() { @Test public void testGenericMetricsRegistration() { MetricGroup genericMetricGroup = commitMetrics.getMetricGroup(); - assertThat(Metrics.getInstance().getMetricGroups().size()).isEqualTo(1); + AssertionError error = null; + try { + assertThat(Metrics.getInstance().getMetricGroups().size()).isEqualTo(1); + } catch (AssertionError e) { + error = + ExceptionUtils.firstOrSuppressed( + e, + new AssertionError( + "Please close the created TableCommit objects in case of metrics resource leak.")); + } + if (error != null) { + throw error; + } assertThat(genericMetricGroup.getGroupName()).isEqualTo(CommitMetrics.GROUP_NAME); Map registeredMetrics = genericMetricGroup.getMetrics(); assertThat(registeredMetrics.keySet())