Fix for Null Dereference in Label Store
Change-Id: I76711a19585d8fd508769101e8aedc3719bcde83
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java
index eb7fac9..8eb283d 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/resource/impl/DistributedLabelResourceStore.java
@@ -312,6 +312,10 @@
DeviceId deviceId = request.deviceId();
long applyNum = request.applyNum();
Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId);
+ if (poolOld == null) {
+ log.info("label resource pool not allocated for deviceId {}.", deviceId);
+ return Collections.emptyList();
+ }
LabelResourcePool pool = poolOld.value();
Collection<LabelResource> result = new HashSet<LabelResource>();
long freeNum = this.getFreeNumOfDevicePool(deviceId);
@@ -397,6 +401,10 @@
DeviceId deviceId = request.deviceId();
Collection<LabelResource> release = request.releaseCollection();
Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId);
+ if (poolOld == null) {
+ log.info("the label resource pool of device id {} not allocated");
+ return false;
+ }
LabelResourcePool pool = poolOld.value();
if (pool == null) {
log.info("the label resource pool of device id {} does not exist");