From 13964e0f657a71e0c3e01728fa9363ed641a764b Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 14 Apr 2024 10:01:35 +0100 Subject: [PATCH] cleanup --- src/main/java/xyz/mcutils/backend/service/MetricService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/xyz/mcutils/backend/service/MetricService.java b/src/main/java/xyz/mcutils/backend/service/MetricService.java index dc5e770..27c1ef4 100644 --- a/src/main/java/xyz/mcutils/backend/service/MetricService.java +++ b/src/main/java/xyz/mcutils/backend/service/MetricService.java @@ -1,5 +1,6 @@ package xyz.mcutils.backend.service; +import com.influxdb.client.InfluxDBClient; import com.influxdb.client.WriteApiBlocking; import com.influxdb.spring.influx.InfluxDB2AutoConfiguration; import lombok.extern.log4j.Log4j2; @@ -32,7 +33,9 @@ public class MetricService { @Autowired public MetricService(InfluxDB2AutoConfiguration influxAutoConfiguration, MetricsRepository metricsRepository) { - this.influxWriteApi = influxAutoConfiguration.influxDBClient().getWriteApiBlocking(); + try (InfluxDBClient client = influxAutoConfiguration.influxDBClient()) { + this.influxWriteApi = client.getWriteApiBlocking(); + } this.metricsRepository = metricsRepository; // Register the metrics