Satish K
Committed by Gerrit Code Review

Fix for Null Dereference in Label Store

Change-Id: I76711a19585d8fd508769101e8aedc3719bcde83
...@@ -312,6 +312,10 @@ public class DistributedLabelResourceStore ...@@ -312,6 +312,10 @@ public class DistributedLabelResourceStore
312 DeviceId deviceId = request.deviceId(); 312 DeviceId deviceId = request.deviceId();
313 long applyNum = request.applyNum(); 313 long applyNum = request.applyNum();
314 Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId); 314 Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId);
315 + if (poolOld == null) {
316 + log.info("label resource pool not allocated for deviceId {}.", deviceId);
317 + return Collections.emptyList();
318 + }
315 LabelResourcePool pool = poolOld.value(); 319 LabelResourcePool pool = poolOld.value();
316 Collection<LabelResource> result = new HashSet<LabelResource>(); 320 Collection<LabelResource> result = new HashSet<LabelResource>();
317 long freeNum = this.getFreeNumOfDevicePool(deviceId); 321 long freeNum = this.getFreeNumOfDevicePool(deviceId);
...@@ -397,6 +401,10 @@ public class DistributedLabelResourceStore ...@@ -397,6 +401,10 @@ public class DistributedLabelResourceStore
397 DeviceId deviceId = request.deviceId(); 401 DeviceId deviceId = request.deviceId();
398 Collection<LabelResource> release = request.releaseCollection(); 402 Collection<LabelResource> release = request.releaseCollection();
399 Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId); 403 Versioned<LabelResourcePool> poolOld = resourcePool.get(deviceId);
404 + if (poolOld == null) {
405 + log.info("the label resource pool of device id {} not allocated");
406 + return false;
407 + }
400 LabelResourcePool pool = poolOld.value(); 408 LabelResourcePool pool = poolOld.value();
401 if (pool == null) { 409 if (pool == null) {
402 log.info("the label resource pool of device id {} does not exist"); 410 log.info("the label resource pool of device id {} does not exist");
......