From f9a00a5ce0796e3420f0ee2ccbace7d771fa8e7d Mon Sep 17 00:00:00 2001 From: pierventre Date: Mon, 25 Oct 2021 18:49:09 +0200 Subject: [PATCH] Fix npe during hostVanished handling java.lang.NullPointerException: null at org.onosproject.net.host.impl.HostManager$InternalHostProviderService.hostVanished(HostManager.java:573) ~[?:?] at org.onosproject.provider.netcfghost.NetworkConfigHostProvider.removeHost(NetworkConfigHostProvider.java:189) ~[?:?] at org.onosproject.provider.netcfghost.NetworkConfigHostProvider$InternalNetworkConfigListener.event(NetworkConfigHostProvider.java:274) ~[?:?] at org.onosproject.provider.netcfghost.NetworkConfigHostProvider$InternalNetworkConfigListener.event(NetworkConfigHostProvider.java:222) ~[?:?] at org.onosproject.event.ListenerRegistry.process(ListenerRegistry.java:66) [!/:?] at org.onosproject.event.impl.CoreEventDispatcher$DispatchLoop.process(CoreEventDispatcher.java:198) [!/:?] at org.onosproject.event.impl.CoreEventDispatcher$DispatchLoop.run(CoreEventDispatcher.java:180) [!/:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] at java.lang.Thread.run(Thread.java:834) [?:?] Change-Id: If6e3978798d5fb11b3f5b1344b551b9f3cd3e51d (cherry picked from commit 3a615560678cb83fa41f393fa59c346cdae659e2) --- .../java/org/onosproject/net/host/impl/HostManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java b/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java index 46cbc0a7da..a02159c933 100644 --- a/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java +++ b/core/net/src/main/java/org/onosproject/net/host/impl/HostManager.java @@ -562,6 +562,7 @@ public class HostManager public void hostVanished(HostId hostId) { checkNotNull(hostId, HOST_ID_NULL); checkValidity(); + // TODO SDFAB-718 rethink HostStore APIs to allow atomic operations Host host = store.getHost(hostId); if (!allowedToChange(hostId)) { @@ -569,6 +570,11 @@ public class HostManager return; } + if (host == null) { + log.info("Request to remove {} is ignored due to host not present in the store", hostId); + return; + } + if (monitorHosts) { host.ipAddresses().forEach(ip -> { monitor.stopMonitoring(ip);