Skip to content

Commit

Permalink
[rrd4j] Error handling for broken rrd4j files (openhab#13955)
Browse files Browse the repository at this point in the history
* [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 <[email protected]>
  • Loading branch information
holgerfriedrich authored Dec 15, 2022
1 parent 04f059c commit 6ab0561
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ public synchronized void store(final Item item, @Nullable final String alias) {
}
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;
}
Expand Down Expand Up @@ -249,7 +254,13 @@ public void store(Item item) {
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();
Expand Down

0 comments on commit 6ab0561

Please sign in to comment.