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

Fixes #16233

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-01-13 13:27:29 +01:00 committed by GitHub
parent d5bbda6936
commit 3f4aac9485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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();
}