]> git.basschouten.com Git - openhab-addons.git/commitdiff
[rrd4j] Error handling for broken rrd4j files (#13955)
authorHolger Friedrich <holgerfriedrich@users.noreply.github.com>
Thu, 15 Dec 2022 10:31:20 +0000 (11:31 +0100)
committerGitHub <noreply@github.com>
Thu, 15 Dec 2022 10:31:20 +0000 (11:31 +0100)
* [rrd4j] Error handling for broken rrd4j files

Catch exceptions thrown by getDB(..) and print the name of the affected
database file. This allows to identify a broken rrd4j file.

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
bundles/org.openhab.persistence.rrd4j/src/main/java/org/openhab/persistence/rrd4j/internal/RRD4jPersistenceService.java

index d29170d508b7644c283e4adffb609967f4af9617..147e675409470701867fc77a75799c7155aca6f0 100644 (file)
@@ -152,7 +152,12 @@ public class RRD4jPersistenceService implements QueryablePersistenceService {
         }
         final String name = alias == null ? item.getName() : alias;
 
-        RrdDb db = getDB(name);
+        RrdDb db = null;
+        try {
+            db = getDB(name);
+        } catch (Exception e) {
+            logger.warn("Failed to open rrd4j database '{}' ({})", name, e.getClass().getName());
+        }
         if (db == null) {
             return;
         }
@@ -249,7 +254,13 @@ public class RRD4jPersistenceService implements QueryablePersistenceService {
     public Iterable<HistoricItem> query(FilterCriteria filter) {
         String itemName = filter.getItemName();
 
-        RrdDb db = getDB(itemName);
+        RrdDb db = null;
+        try {
+            db = getDB(itemName);
+        } catch (Exception e) {
+            logger.warn("Failed to open rrd4j database '{}' ({})", itemName, e.getClass().getName());
+            return List.of();
+        }
         if (db == null) {
             logger.debug("Could not find item '{}' in rrd4j database", itemName);
             return List.of();