You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2018/04/18 11:21:00 UTC
[GitHub] brettKK opened a new pull request #2573: [CLOUDSTACK-10356] Fix NPE
in Cloudstack found with NPEDetector
brettKK opened a new pull request #2573: [CLOUDSTACK-10356] Fix NPE in Cloudstack found with NPEDetector
URL: https://github.com/apache/cloudstack/pull/2573
@lujiefsi found a potential NPE in Cloudstack
---
We have developed a static analysis tool 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 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 !=null:
```
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();
siteLb.setGslbProviderPublicIp(gslbProvider.getZoneGslbProviderPublicIp(dataCenterId,physicalNetworkId));
.........
```
So we will add below code in non-(!=null) caller GlobalLoadBalancingRulesServiceImpl#applyGlobalLoadBalancerRuleConfig
```
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.
Thanks.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services