[VOL-2651] aaa-users throws exception after ONU delete
Change-Id: I203aacac31faaa33d6418e76184bbe4fcccfcdda
diff --git a/app/src/main/java/org/opencord/aaa/impl/AaaManager.java b/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
index 85b1ce2..d1a85d7 100644
--- a/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
+++ b/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
@@ -1036,6 +1036,16 @@
PortNumber portNumber = event.port().number();
String sessionId = deviceId.toString() + portNumber.toString();
log.debug("Received PORT_REMOVED event. Clearing AAA Session with Id {}", sessionId);
+
+ StateMachine stateMachine = stateMachines.get(sessionId);
+ if (stateMachine == null) {
+ // No active AAA sessions for this UNI port
+ log.debug("No Active AAA Session found with Id {}", sessionId);
+ return;
+ }
+
+ authentications.remove(stateMachine.supplicantConnectpoint());
+
flushStateMachineSession(sessionId,
StateMachine.SessionTerminationReasons.PORT_REMOVED.getReason());