From cb72fc93a96df5e9a7942310e11fdb06b1ddbad6 Mon Sep 17 00:00:00 2001 From: "tobias.pobocik" Date: Tue, 12 Sep 2023 18:27:47 +0200 Subject: [PATCH] Refactor getting netconf devices Add a null check to ensure that the values are not null. JIRA: LIGHTY-235 Signed-off-by: tobias.pobocik --- .../springboot/rest/NetconfDeviceRestService.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lighty-examples/lighty-controller-springboot-netconf/src/main/java/io/lighty/core/controller/springboot/rest/NetconfDeviceRestService.java b/lighty-examples/lighty-controller-springboot-netconf/src/main/java/io/lighty/core/controller/springboot/rest/NetconfDeviceRestService.java index 4bf8982bdd..0642acba12 100644 --- a/lighty-examples/lighty-controller-springboot-netconf/src/main/java/io/lighty/core/controller/springboot/rest/NetconfDeviceRestService.java +++ b/lighty-examples/lighty-controller-springboot-netconf/src/main/java/io/lighty/core/controller/springboot/rest/NetconfDeviceRestService.java @@ -96,11 +96,7 @@ public ResponseEntity getNetconfDevicesIds(Authentication authentication) throws private List getNetconfDevices(final Topology netconfTopology) throws InterruptedException, TimeoutException, ExecutionException { final List devices = new ArrayList<>(); - final Map netconfNodes = - Optional.ofNullable(netconfTopology.getNode()) - .orElse(Collections.emptyMap()); - - for (Node node : netconfNodes.values()) { + for (Node node : netconfTopology.nonnullNode().values()) { NetconfDeviceResponse nodeResponse = NetconfDeviceResponse.from(node); final Optional netconfMountPoint = mountPointService.getMountPoint(NETCONF_TOPOLOGY_IID .child(Node.class, new NodeKey(node.getNodeId())));