Skip to content

Commit

Permalink
Controller.Api.Backend: catch possible exception in collectData()
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeilmeier committed Mar 9, 2021
1 parent 3315bbb commit 941ac94
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,21 @@ public void deactivate() {
* @return collected data
*/
private ImmutableTable<String, String, JsonElement> collectData(List<OpenemsComponent> enabledComponents) {
return enabledComponents.parallelStream() //
.flatMap(component -> component.channels().parallelStream()) //
.filter(channel -> // Ignore WRITE_ONLY Channels
channel.channelDoc().getAccessMode() != AccessMode.WRITE_ONLY //
// Ignore Low-Priority Channels
&& channel.channelDoc().getPersistencePriority()
.isAtLeast(this.parent.config.persistencePriority()))
.collect(ImmutableTable.toImmutableTable(c -> c.address().getComponentId(),
c -> c.address().getChannelId(), c -> c.value().asJson()));
try {
return enabledComponents.parallelStream() //
.flatMap(component -> component.channels().parallelStream()) //
.filter(channel -> // Ignore WRITE_ONLY Channels
channel.channelDoc().getAccessMode() != AccessMode.WRITE_ONLY //
// Ignore Low-Priority Channels
&& channel.channelDoc().getPersistencePriority()
.isAtLeast(this.parent.config.persistencePriority()))
.collect(ImmutableTable.toImmutableTable(c -> c.address().getComponentId(),
c -> c.address().getChannelId(), c -> c.value().asJson()));
} catch (Exception e) {
// ConcurrentModificationException can happen if Channels are dynamically added
// or removed
return ImmutableTable.of();
}
}

/*
Expand Down

0 comments on commit 941ac94

Please sign in to comment.