CLOUDSTACK-10144: fix possible NPE in listVlanIpRanges

This commit is contained in:
Rene Moser 2017-11-16 13:43:00 +01:00 committed by Rohit Yadav
parent 7f6ae15972
commit 55c059c098
1 changed files with 10 additions and 4 deletions

View File

@ -2365,12 +2365,18 @@ public class ApiResponseHelper implements ResponseGenerator {
private void populateAccount(ControlledEntityResponse response, long accountId) {
Account account = ApiDBUtils.findAccountById(accountId);
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
if (account == null) {
s_logger.debug("Unable to find account with id: " + accountId);
} else if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
// find the project
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
response.setProjectId(project.getUuid());
response.setProjectName(project.getName());
response.setAccountName(account.getAccountName());
if (project != null) {
response.setProjectId(project.getUuid());
response.setProjectName(project.getName());
response.setAccountName(account.getAccountName());
} else {
s_logger.debug("Unable to find project with id: " + account.getId());
}
} else {
response.setAccountName(account.getAccountName());
}