bug fix: NPE in hazelcast multiRead
- Correctly handle value does not exist in table error case.
Change-Id: I4d3c190f7fdeca29723fda7d8fb1a060a11e289d
diff --git a/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZMultiEntryOperation.java b/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZMultiEntryOperation.java
index 0a7fc5e..d3df22c 100644
--- a/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZMultiEntryOperation.java
+++ b/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZMultiEntryOperation.java
@@ -124,9 +124,14 @@
private VersionedValue get() {
try {
VersionedValue value = future.get();
- setValue(value.getValue(), value.getVersion());
- setStatus(STATUS.SUCCESS);
- return value;
+ if (value == null) {
+ setStatus(STATUS.FAILED);
+ return null;
+ } else {
+ setValue(value.getValue(), value.getVersion());
+ setStatus(STATUS.SUCCESS);
+ return value;
+ }
} catch (CancellationException | InterruptedException | ExecutionException e) {
log.error(this + " has failed.", e);
setStatus(STATUS.FAILED);