Return null instead of throw exception for invalid event states.
Change-Id: Ie40ca4dc1c241aa4f27652aa4e8b3f99eb924169
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
index c78b5f9..6ddf58f 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
@@ -268,9 +268,8 @@
@Override
public void addPending(IntentData data) {
- log.debug("new call to pending {}", data);
+ log.debug("new pending {} {} {}", data.key(), data.state(), data.version());
if (data.version() == null) {
- log.debug("updating timestamp");
data.setVersion(new SystemClockTimestamp());
}
pending.put(data.key(), copyData(data));
@@ -293,16 +292,9 @@
public void event(
EventuallyConsistentMapEvent<Key, IntentData> event) {
if (event.type() == EventuallyConsistentMapEvent.Type.PUT) {
- IntentEvent externalEvent;
IntentData intentData = event.value();
- try {
- externalEvent = IntentEvent.getEvent(intentData.state(), intentData.intent());
- } catch (IllegalArgumentException e) {
- externalEvent = null;
- }
-
- notifyDelegateIfNotNull(externalEvent);
+ notifyDelegateIfNotNull(IntentEvent.getEvent(intentData));
}
}
}
@@ -322,12 +314,7 @@
}
}
- try {
- notifyDelegate(IntentEvent.getEvent(event.value()));
- } catch (IllegalArgumentException e) {
- //no-op
- log.trace("ignore this exception: {}", e);
- }
+ notifyDelegateIfNotNull(IntentEvent.getEvent(event.value()));
}
}
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/SimpleIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/SimpleIntentStore.java
index 2bc5b63..8778e93 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/SimpleIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/SimpleIntentStore.java
@@ -198,16 +198,17 @@
pending.remove(newData.key());
}
- try {
- notifyDelegate(IntentEvent.getEvent(newData));
- } catch (IllegalArgumentException e) {
- //no-op
- log.trace("ignore this exception: {}", e);
- }
+ notifyDelegateIfNotNull(IntentEvent.getEvent(newData));
}
}
}
+ private void notifyDelegateIfNotNull(IntentEvent event) {
+ if (event != null) {
+ notifyDelegate(event);
+ }
+ }
+
@Override
public void batchWrite(Iterable<IntentData> updates) {
for (IntentData data : updates) {
@@ -241,7 +242,7 @@
pending.put(data.key(), data);
checkNotNull(delegate, "Store delegate is not set")
.process(data);
- notifyDelegate(IntentEvent.getEvent(data));
+ notifyDelegateIfNotNull(IntentEvent.getEvent(data));
} else {
log.debug("IntentData {} is older than existing: {}",
data, existingData);