Skip to content

Commit

Permalink
Fix exception handling for InfluxDB 1.x (openhab#16234)
Browse files Browse the repository at this point in the history
Fixes openhab#16233

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
  • Loading branch information
jlaur authored and andrasU committed Jan 27, 2024
1 parent 4647b5e commit 5c3ef75
Showing 1 changed file with 11 additions and 6 deletions.
Expand Up @@ -75,12 +75,17 @@ public boolean isConnected() {

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

Expand Down

0 comments on commit 5c3ef75

Please sign in to comment.