[CLOUDSTACK-10156] Fix Coverity new problems CID(1349987, 1349986, 1347248)#2332
Conversation
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| Long accountId = _accountService.getActiveAccountByName(accountName, domainId).getAccountId(); |
There was a problem hiding this comment.
This can be kept to know who made the API call
There was a problem hiding this comment.
Ah, so that is what this is for.
I will create a log then.
|
LGTM |
| if (accountId == null) { | ||
| return CallContext.current().getCallingAccount().getId(); | ||
| } | ||
| s_logger.debug(String.format("Account [id=%d, name=%s, domain=%d] is executing method: %s ", accountId, accountName, domainId, getClass().getSimpleName())); |
There was a problem hiding this comment.
Logging is not necessary here. The user/account making the API call is already logged, along with API name+args.
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1280 |
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-1680)
|
|
Tests lgtm, fixed redundant logging. @rafaelweingartner can you check and add a jira ID, then we can merge it. Thanks. |
| @@ -120,8 +119,8 @@ public String getCommandName() { | |||
| @Override | |||
| public long getEntityOwnerId() { | |||
| Long accountId = _accountService.getActiveAccountByName(accountName, domainId).getAccountId(); | |||
There was a problem hiding this comment.
@rhtyd this will never be null. The method getAccountId returns a primitive long. Therefore, this check that you added is not needed. That is why when you asked to preserve the call _accountService.getActiveAccountByName(accountName, domainId).getAccountId(); I wrote a code that was logging the value. Otherwise it would be a call that did not make sense.
If you take a look at the first commit and compare it with HEAD, you are going to see the following code in HEAD:
if (accountId == null) {
return CallContext.current().getCallingAccount().getId();
}
return Account.ACCOUNT_ID_SYSTEM;
accountId is never null, that is why I removed that block, and left only the return Account.ACCOUNT_ID_SYSTEM; code. If you think that we have to return the value of accountService.getActiveAccountByName(accountName, domainId).getAccountId(); we can simply return it as it is a primitive long and will never be null
There was a problem hiding this comment.
Sure, let's return long value of accountId.
There was a problem hiding this comment.
Great. I will change this then
|
@rhtyd sure I can create a Jira ticket. I have some remarks in the code you are introducing. I will create the Jira while we check that point there. |
6a2ebfb to
cb60ee5
Compare
cb60ee5 to
2c6fdf0
Compare
|
@rhtyd done! |
|
@rafaelweingartner I've fixed a minor spacing/styling issue. LGTM merging. |
|
Thanks @rhtyd ! |
No description provided.