[VOL-3591] Using getReadableIdentifier throughout the app to cleanup logs
Change-Id: Id977851e8e9a5a02b76d8ee43f5356d4185ea803
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 56c3912..02b5105 100644
--- a/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
+++ b/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
@@ -1071,7 +1071,7 @@
if (log.isTraceEnabled()) {
log.trace("Sending ATTR_IDENTITY packet to RADIUS for supplicant at dev/port: " +
"{}/{} with MacAddress {} and Identifier {}", deviceId, portNumber,
- srcMac, radiusIdentifier.identifier() & 0xff);
+ srcMac, radiusIdentifier.getReadableIdentifier());
}
sendRadiusPacket(radiusPayload, inPacket);
@@ -1127,7 +1127,7 @@
if (log.isTraceEnabled()) {
log.trace("Sending ATTR_MD5 packet to RADIUS for supplicant at dev/port: {}/{}" +
" with MacAddress {} and Identifier {}", deviceId, portNumber, srcMac,
- radiusIdentifier.identifier() & 0xff);
+ radiusIdentifier.getReadableIdentifier());
}
sendRadiusPacket(radiusPayload, inPacket);
stateMachine.setWaitingForRadiusResponse(true);
@@ -1178,7 +1178,7 @@
if (log.isTraceEnabled()) {
log.trace("Sending ATTR_TLS packet to RADIUS for supplicant at dev/port: {}/{} with " +
"MacAddress {} and Identifier {}", deviceId, portNumber, srcMac,
- radiusIdentifier.identifier() & 0xff);
+ radiusIdentifier.getReadableIdentifier());
}
sendRadiusPacket(radiusPayload, inPacket);
stateMachine.setWaitingForRadiusResponse(true);
diff --git a/app/src/main/java/org/opencord/aaa/impl/IdentifierManager.java b/app/src/main/java/org/opencord/aaa/impl/IdentifierManager.java
index 6b4bffb..911f577 100644
--- a/app/src/main/java/org/opencord/aaa/impl/IdentifierManager.java
+++ b/app/src/main/java/org/opencord/aaa/impl/IdentifierManager.java
@@ -137,23 +137,23 @@
*/
public synchronized void releaseIdentifier(RequestIdentifier id) {
if (log.isTraceEnabled()) {
- log.trace("Releasing identifier {}", id.identifier() & 0xff);
+ log.trace("Releasing identifier {}", id.getReadableIdentifier());
}
Pair<String, Long> session = idToSession.remove(id);
if (session == null) {
if (log.isTraceEnabled()) {
- log.trace("Unable to released identifier {} for session null", id.identifier() & 0xff);
+ log.trace("Unable to released identifier {} for session null", id.getReadableIdentifier());
}
// this id wasn't mapped to a session so is still free
return;
}
// add id number back to set of free ids
- freeIdNumbers.add(id.identifier() & 0xff);
+ freeIdNumbers.add(id.getReadableIdentifier());
if (log.isTraceEnabled()) {
- log.trace("Released identifier {} for session {}", id.identifier() & 0xff, session.getKey());
+ log.trace("Released identifier {} for session {}", id.getReadableIdentifier(), session.getKey());
}
}
@@ -191,7 +191,7 @@
if (diff >= timeout) {
if (log.isTraceEnabled()) {
log.trace("Identifier {} for session {} has exceeded timeout {}, releasing",
- id.identifier() & 0xff, info.getKey(), timeout);
+ id.getReadableIdentifier(), info.getKey(), timeout);
}
releaseIdentifier(id);
}
diff --git a/app/src/main/java/org/opencord/aaa/impl/RequestIdentifier.java b/app/src/main/java/org/opencord/aaa/impl/RequestIdentifier.java
index 564c45a..18b73e3 100644
--- a/app/src/main/java/org/opencord/aaa/impl/RequestIdentifier.java
+++ b/app/src/main/java/org/opencord/aaa/impl/RequestIdentifier.java
@@ -46,6 +46,15 @@
}
/**
+ * Get the identifier in a readable format.
+ *
+ * @return identifier
+ */
+ public int getReadableIdentifier() {
+ return this.identifier & 0xff;
+ }
+
+ /**
* Creates a new request identifier.
*
* @param identifier id number
diff --git a/app/src/test/java/org/opencord/aaa/impl/IdentifierManagerTest.java b/app/src/test/java/org/opencord/aaa/impl/IdentifierManagerTest.java
index afc5ec2..668ac0f 100644
--- a/app/src/test/java/org/opencord/aaa/impl/IdentifierManagerTest.java
+++ b/app/src/test/java/org/opencord/aaa/impl/IdentifierManagerTest.java
@@ -67,7 +67,7 @@
public void testIdSequence() {
for (int i = 1; i <= 300; i++) {
RequestIdentifier id = idManager.getNewIdentifier(Integer.toString(i));
- log.trace("Id: {}", id.identifier() & 0xff);
+ log.trace("Id: {}", id.getReadableIdentifier());
assertNotEquals(id.identifier(), 0);
assertNotEquals(id.identifier(), 1);
idManager.releaseIdentifier(id);