From 9c2857d6cc7e903988c3a8f362463006b8d8f29c Mon Sep 17 00:00:00 2001 From: Jens Kutzsche Date: Wed, 4 May 2022 22:31:33 +0200 Subject: [PATCH] chore: fixes NPE in case of unfavorable SD entries and improves logging to find a hidden exceptions --- .../java/iris/client_bff/status/eps/EPSStatusClient.java | 2 ++ .../java/iris/client_bff/status/web/AppStatusController.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/iris-client-bff/src/main/java/iris/client_bff/status/eps/EPSStatusClient.java b/iris-client-bff/src/main/java/iris/client_bff/status/eps/EPSStatusClient.java index 2b7abb097..986956836 100644 --- a/iris-client-bff/src/main/java/iris/client_bff/status/eps/EPSStatusClient.java +++ b/iris-client-bff/src/main/java/iris/client_bff/status/eps/EPSStatusClient.java @@ -14,6 +14,7 @@ import java.net.ConnectException; import java.net.SocketTimeoutException; import java.util.List; +import java.util.Objects; import java.util.Set; import javax.validation.Valid; @@ -43,6 +44,7 @@ public Apps getAvailableApps() { return epsRpcClient.invoke(methodName, null, Directory.class).entries().stream() .filter(directoryEntry -> directoryEntry.groups().contains("checkin-apps")) .map(DirectoryEntry::name) + .filter(Objects::nonNull) .map(App::new) .collect(collectingAndThen(toList(), Apps::new)); diff --git a/iris-client-bff/src/main/java/iris/client_bff/status/web/AppStatusController.java b/iris-client-bff/src/main/java/iris/client_bff/status/web/AppStatusController.java index 6cb8321d1..39d5c89f1 100644 --- a/iris-client-bff/src/main/java/iris/client_bff/status/web/AppStatusController.java +++ b/iris-client-bff/src/main/java/iris/client_bff/status/web/AppStatusController.java @@ -8,6 +8,7 @@ import iris.client_bff.status.web.AppStatusController.AppStatusInfo.Info; import lombok.AllArgsConstructor; import lombok.Value; +import lombok.extern.slf4j.Slf4j; import java.util.List; @@ -27,6 +28,7 @@ @RequestMapping("/status/checkin-apps") @Validated @AllArgsConstructor +@Slf4j public class AppStatusController { private StatusService statusService; @@ -37,6 +39,9 @@ public List getApps() { try { return statusService.getApps().toList(); } catch (Exception e) { + + log.error("Can't get apps from StatusService: ", e); + throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getMessage()); } }