diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java index 15f4dc96665..13c5114aca3 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/addons/AddonResource.java @@ -275,13 +275,9 @@ private void postFailureEvent(String addonId, @Nullable String msg) { eventPublisher.post(event); } - private AddonService getDefaultService() { - for (AddonService addonService : addonServices) { - if (addonService.getId().equals(DEFAULT_ADDON_SERVICE)) { - return addonService; - } - } - return addonServices.iterator().next(); + private @Nullable AddonService getDefaultService() { + return addonServices.stream().filter(addonService -> DEFAULT_ADDON_SERVICE.equals(addonService.getId())) + .findFirst().orElse(addonServices.stream().findFirst().orElse(null)); } private Stream getAllAddons(Locale locale) {