lujie created CLOUDSTACK-10356:

             Summary: Fix Some Potential NPE 
                 Key: CLOUDSTACK-10356
             Project: CloudStack
          Issue Type: Bug
      Security Level: Public (Anyone can view this level - this is the default.)
    Affects Versions:
            Reporter: lujie

We have developed a static analysis tool to 
[NPEDetector|] to find some potential 
NPE. Our analysis shows that some callees may return null in corner case(e.g. 
node crash , IO exception), some of their callers have !=null check but some do 
not have. In this issue we post a patch which can add _!=null_ checker  based 
on existed _!=null_ check. For example:

Callee GlobalLoadBalancingRulesServiceImpl#lookupGslbServiceProvider:

protected GslbServiceProvider lookupGslbServiceProvider() {
    return _gslbProviders.size() == 0 ? null : _gslbProviders.get(0);// may 
return null;
Caller GlobalLoadBalancingRulesServiceImpl#checkGslbServiceEnabledInZone have 

private boolean checkGslbServiceEnabledInZone(long zoneId, long 
physicalNetworkId) {

   GslbServiceProvider gslbProvider = lookupGslbServiceProvider();
   if (gslbProvider == null) {
      throw new CloudRuntimeException("No GSLB provider is available");

   return gslbProvider.isServiceEnabledInZone(zoneId, physicalNetworkId);
but another 
GlobalLoadBalancingRulesServiceImpl#applyGlobalLoadBalancerRuleConfig does not 
have !=null check:


GslbServiceProvider gslbProvider = lookupGslbServiceProvider();
So we will add below code in non-(null!=null) caller 


if (gslbProvider == null) {
    throw new CloudRuntimeException("No GSLB provider is available");
But due to we are not very  familiar with CLOUDSTACK, hope some expert can 
review it.




This message was sent by Atlassian JIRA

Reply via email to