Unregister host listener when deactivating mobility app
Change-Id: I7f81dffb3e35da9e56893085a9e1e2d793036e85
diff --git a/apps/mobility/src/main/java/org/onosproject/mobility/HostMobility.java b/apps/mobility/src/main/java/org/onosproject/mobility/HostMobility.java
index 83847d4..1569489 100644
--- a/apps/mobility/src/main/java/org/onosproject/mobility/HostMobility.java
+++ b/apps/mobility/src/main/java/org/onosproject/mobility/HostMobility.java
@@ -68,12 +68,13 @@
private ApplicationId appId;
private ExecutorService eventHandler;
+ private final HostListener hostListener = new InternalHostListener();
@Activate
public void activate() {
appId = coreService.registerApplication("org.onosproject.mobility");
eventHandler = newSingleThreadScheduledExecutor(groupedThreads("onos/app-mobility", "event-handler", log));
- hostService.addListener(new InternalHostListener());
+ hostService.addListener(hostListener);
log.info("Started with Application ID {}", appId.id());
}
@@ -81,6 +82,7 @@
public void deactivate() {
// TODO we never actually add any flow rules
flowRuleService.removeFlowRulesById(appId);
+ hostService.removeListener(hostListener);
eventHandler.shutdown();
log.info("Stopped");
}