Skip to content

Commit

Permalink
Prevent NSEE when there is no AddonService (openhab#2493)
Browse files Browse the repository at this point in the history
The code was already prepared for a nullable default service and then returns a 404 not found.

Fixes openhab#2491

Signed-off-by: Wouter Born <[email protected]>
  • Loading branch information
wborn authored Sep 25, 2021
1 parent cfabfbc commit 641b923
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Addon> getAllAddons(Locale locale) {
Expand Down

0 comments on commit 641b923

Please sign in to comment.