mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Fix NPE with uninitialized state trackers (#1378)
This fixes a NPE which occurs when a ItemStateChangedEvent is broadcasted by the ItemStatesSseBroadcaster while some SseStateEventOutputs haven't initialized their list of tracked items. Signed-off-by: Yannick Schaus <github@schaus.net>
This commit is contained in:
+1
-2
@@ -128,8 +128,7 @@ public class ItemStatesSseBroadcaster extends SseBroadcaster {
|
||||
for (String itemName : itemNames) {
|
||||
try {
|
||||
// Check that the item is tracked by at least one connection
|
||||
if (itemRegistry != null
|
||||
&& eventOutputs.values().stream().anyMatch(c -> c.getTrackedItems().contains(itemName))) {
|
||||
if (eventOutputs.values().stream().anyMatch(c -> c.getTrackedItems().contains(itemName))) {
|
||||
Item item = itemRegistry.getItem(itemName);
|
||||
StateDTO stateDto = new StateDTO();
|
||||
stateDto.state = item.getState().toString();
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ package org.openhab.core.io.rest.sse.internal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -33,7 +34,7 @@ import org.glassfish.jersey.media.sse.OutboundEvent;
|
||||
public class SseStateEventOutput extends EventOutput {
|
||||
|
||||
private String connectionId;
|
||||
private Collection<String> trackedItems;
|
||||
private Collection<String> trackedItems = Collections.emptySet();
|
||||
|
||||
public SseStateEventOutput() {
|
||||
super();
|
||||
|
||||
Reference in New Issue
Block a user