Fix for bug ONOS-330:
Add missing "null" checks for IntentService.getIntentState()
Change-Id: Idd574227636f6cdd3a0dbae4c753ada6157e04e1
diff --git a/apps/sdnip/src/main/java/org/onlab/onos/sdnip/IntentSynchronizer.java b/apps/sdnip/src/main/java/org/onlab/onos/sdnip/IntentSynchronizer.java
index 73d9763..4ded55f 100644
--- a/apps/sdnip/src/main/java/org/onlab/onos/sdnip/IntentSynchronizer.java
+++ b/apps/sdnip/src/main/java/org/onlab/onos/sdnip/IntentSynchronizer.java
@@ -126,7 +126,8 @@
// Skip the intents that are already withdrawn
IntentState intentState =
intentService.getIntentState(intent.id());
- if (intentState.equals(IntentState.WITHDRAWING) ||
+ if ((intentState == null) ||
+ intentState.equals(IntentState.WITHDRAWING) ||
intentState.equals(IntentState.WITHDRAWN)) {
continue;
}
@@ -461,7 +462,8 @@
IntentState state =
intentService.getIntentState(fetchedIntent.id());
- if (state == IntentState.WITHDRAWING ||
+ if (state == null ||
+ state == IntentState.WITHDRAWING ||
state == IntentState.WITHDRAWN) {
// The intent has been withdrawn but according to our route
// table it should be installed. We'll reinstall it.
@@ -482,7 +484,8 @@
IntentState state =
intentService.getIntentState(fetchedIntent.id());
- if (state == IntentState.WITHDRAWING ||
+ if (state == null ||
+ state == IntentState.WITHDRAWING ||
state == IntentState.WITHDRAWN) {
// Nothing to do. The intent has been already withdrawn.
continue;
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java
index 0f24647..7f84207 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java
@@ -126,6 +126,9 @@
// Collect the summary for each intent type intents
for (Intent intent : intents) {
IntentState intentState = service.getIntentState(intent.id());
+ if (intentState == null) {
+ continue;
+ }
// Update the summary for all Intents
summaryAll.update(intentState);