prevent NPEs if persistence service does not play nice (#426)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer 2018-11-05 16:34:17 +01:00 committed by Christoph Weitkamp
parent 24d32f877c
commit 511a1e4d9f

View File

@ -46,23 +46,25 @@ public class QueryablePersistenceServiceDelegate extends PersistenceServiceDeleg
org.openhab.core.persistence.QueryablePersistenceService pService = (org.openhab.core.persistence.QueryablePersistenceService) service;
Iterable<org.openhab.core.persistence.HistoricItem> historicItems = pService.query(mappedFilter);
ArrayList<HistoricItem> result = new ArrayList<>();
for (final org.openhab.core.persistence.HistoricItem item : historicItems) {
result.add(new HistoricItem() {
@Override
public Date getTimestamp() {
return item.getTimestamp();
}
if (historicItems != null) {
for (final org.openhab.core.persistence.HistoricItem item : historicItems) {
result.add(new HistoricItem() {
@Override
public Date getTimestamp() {
return item.getTimestamp();
}
@Override
public State getState() {
return (State) TypeMapper.mapToESHType(item.getState());
}
@Override
public State getState() {
return (State) TypeMapper.mapToESHType(item.getState());
}
@Override
public String getName() {
return item.getName();
}
});
@Override
public String getName() {
return item.getName();
}
});
}
}
return result;
}