Fix exception handling for InfluxDB 1.x (#16234)

Fixes #16233

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Jacob Laursen 2024-01-13 13:27:29 +01:00 committed by Ciprian Pascu
parent 923a568af9
commit e759c85353

View File

@ -75,12 +75,17 @@ public class InfluxDB1RepositoryImpl implements InfluxDBRepository {
@Override
public boolean connect() {
final InfluxDB createdClient = InfluxDBFactory.connect(configuration.getUrl(), configuration.getUser(),
configuration.getPassword());
createdClient.setDatabase(configuration.getDatabaseName());
createdClient.setRetentionPolicy(configuration.getRetentionPolicy());
createdClient.enableBatch(200, 100, TimeUnit.MILLISECONDS);
this.client = createdClient;
try {
final InfluxDB createdClient = InfluxDBFactory.connect(configuration.getUrl(), configuration.getUser(),
configuration.getPassword());
createdClient.setDatabase(configuration.getDatabaseName());
createdClient.setRetentionPolicy(configuration.getRetentionPolicy());
createdClient.enableBatch(200, 100, TimeUnit.MILLISECONDS);
this.client = createdClient;
} catch (InfluxException | InfluxDBException e) {
logger.debug("Connection failed", e);
return false;
}
return checkConnectionStatus();
}