ONOS-2796: Fix removeLink NPE when links are removed concurrently from multiple nodes
Change-Id: I99d9bbe143ea4c8906f5ea4d5595a7f7bcddad49
diff --git a/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java b/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java
index 678e242..4577086 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/link/impl/ECLinkStore.java
@@ -336,8 +336,13 @@
@Override
public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
final LinkKey linkKey = LinkKey.linkKey(src, dst);
+ ProviderId primaryProviderId = getBaseProviderId(linkKey);
+ // Stop if there is no base provider.
+ if (primaryProviderId == null) {
+ return null;
+ }
LinkDescription removedLinkDescription =
- linkDescriptions.remove(new Provided<>(linkKey, checkNotNull(getBaseProviderId(linkKey))));
+ linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId));
if (removedLinkDescription != null) {
return purgeLinkCache(linkKey);
}