Fix NPE when processing an event when the delegate is undefined
Change-Id: I44d6c50db8804ccfda1c8b8800360ee705fb331d
diff --git a/core/store/dist/src/main/java/org/onosproject/store/app/DistributedApplicationStore.java b/core/store/dist/src/main/java/org/onosproject/store/app/DistributedApplicationStore.java
index f78b30b..720de3d 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/app/DistributedApplicationStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/app/DistributedApplicationStore.java
@@ -426,7 +426,7 @@
return new InternalApplicationHolder(v.app(), v.state(), ImmutableSet.copyOf(permissions));
});
if (permissionsChanged.get()) {
- delegate.notify(new ApplicationEvent(APP_PERMISSIONS_CHANGED, appHolder.value().app()));
+ notifyDelegate(new ApplicationEvent(APP_PERMISSIONS_CHANGED, appHolder.value().app()));
}
}
@@ -436,7 +436,7 @@
String appName = app.id().name();
installAppIfNeeded(app);
setActive(appName);
- delegate.notify(new ApplicationEvent(APP_ACTIVATED, app));
+ notifyDelegate(new ApplicationEvent(APP_ACTIVATED, app));
}
}
@@ -460,7 +460,7 @@
}
setupApplicationAndNotify(appId, newApp.app(), newApp.state());
} else if (event.type() == MapEvent.Type.REMOVE) {
- delegate.notify(new ApplicationEvent(APP_UNINSTALLED, oldApp.app()));
+ notifyDelegate(new ApplicationEvent(APP_UNINSTALLED, oldApp.app()));
purgeApplication(appId.name());
}
}
@@ -470,10 +470,10 @@
// ACTIVATED state is handled separately in NextAppToActivateValueListener
if (state == INSTALLED) {
fetchBitsIfNeeded(app);
- delegate.notify(new ApplicationEvent(APP_INSTALLED, app));
+ notifyDelegate(new ApplicationEvent(APP_INSTALLED, app));
} else if (state == DEACTIVATED) {
clearActive(appId.name());
- delegate.notify(new ApplicationEvent(APP_DEACTIVATED, app));
+ notifyDelegate(new ApplicationEvent(APP_DEACTIVATED, app));
}
}
@@ -504,7 +504,7 @@
private void installAppIfNeeded(Application app) {
if (!appBitsAvailable(app)) {
fetchBits(app);
- delegate.notify(new ApplicationEvent(APP_INSTALLED, app));
+ notifyDelegate(new ApplicationEvent(APP_INSTALLED, app));
}
}