add entity-type to message when no UUID is found for a DB ID#5163
add entity-type to message when no UUID is found for a DB ID#5163nvazquez merged 5 commits intoapache:mainapache/cloudstack:mainfrom shapeblue:extraInfoOnUUIDNotFoundshapeblue/cloudstack:extraInfoOnUUIDNotFoundCopy head branch name to clipboard
Conversation
|
Packaging result: ✔️ centos7 ✔️ centos8 ✔️ debian. SL-JID 397 |
server/src/main/java/com/cloud/uuididentity/UUIDManagerImpl.java
Outdated
Show resolved
Hide resolved
| throw new InvalidParameterValueException("Unable to find UUID for id " + customId); | ||
| throw new InvalidParameterValueException(String.format("Unable to find UUID for id %s of type %s", | ||
| customId, | ||
| (entityType == null ? "<unknown type>" ? entityType.getSimpleName()))); |
There was a problem hiding this comment.
| (entityType == null ? "<unknown type>" ? entityType.getSimpleName()))); | |
| (entityType == null ? "<null>" ? entityType.getSimpleName()))); |
There was a problem hiding this comment.
I am open to alternatives, but I don't like the , how about just "unknown"?
There was a problem hiding this comment.
"unknown" sounds good.
| @@ -119,7 +119,9 @@ public <T> String getUuid(Class<T> entityType, Long customId) { | ||
| } | ||
| Identity identity = (Identity) this._entityMgr.findById(entityType, customId); |
There was a problem hiding this comment.
@DaanHoogland when entityType is null, I think, it fails here (with NPE below stack), can you please check that.
There was a problem hiding this comment.
Yhe NPE would be thrown in the call to findById() @sureshanaparti @rhtyd
@Override
public <T, K extends Serializable> T findById(Class<T> entityType, K id) {
GenericDao<? extends T, K> dao = (GenericDao<? extends T, K>)GenericDaoBase.getDao(entityType);
return dao.findById(id);
}
I'm fine with applying the extra check in this case but I think it'll be unreachable code.
There was a problem hiding this comment.
@sureshanaparti , as shown above, this NPE is going to happen out of scope of this change anyway, in these kinds of bits of code. What do you suggest to do?
There was a problem hiding this comment.
@DaanHoogland my suggestion is if entityType is null, better throw exception as below
InvalidParameterValueException("Unknown entity type")
and when identity is null (here entityType is not null), better throw exception as below
InvalidParameterValueException(String.format("Unable to find UUID for id [%s] of type [%s]",
customId, entityType.getSimpleName()));
| throw new InvalidParameterValueException("Unable to find UUID for id " + customId); | ||
| throw new InvalidParameterValueException(String.format("Unable to find UUID for id %s of type %s", | ||
| customId, | ||
| (entityType == null ? "<unknown type>" ? entityType.getSimpleName()))); |
There was a problem hiding this comment.
"unknown" sounds good.
| Identity identity = (Identity) this._entityMgr.findById(entityType, customId); | ||
| if (identity == null) { | ||
| throw new InvalidParameterValueException("Unable to find UUID for id " + customId); | ||
| throw new InvalidParameterValueException(String.format("Unable to find UUID for id %s of type %s", |
There was a problem hiding this comment.
I would suggest you to use [] as var delimiter; IMHO, it is easier to recognize what is a variable and what is fixed in the final message; e.g.:
String.format("Unable to find UUID for id [%s] of type [%s].",...
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✖️ debian. SL-JID 551 |
|
Packaging result: ✔️ el7 ✔️ el8 ✖️ debian. SL-JID 563 |
|
Packaging result: ✔️ el7 ✔️ el8 ✖️ debian. SL-JID 565 |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 567 |
|
Trillian Build Failed (tid-1294) |
|
Trillian test result (tid-1295)
|
|
Trillian test result (tid-1306)
|
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 585 |
|
@blueorangutan package |
|
@sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 587 |
|
@blueorangutan test |
|
Trillian Build Failed (tid-1316) |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 595 |
|
@blueorangutan package |
|
@sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 598 |
|
@blueorangutan test |
|
@sureshanaparti a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-1323)
|
|
@blueorangutan package |
|
@nvazquez a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 607 |
|
@blueorangutan test |
|
@nvazquez a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-1330)
|
|
Merging based on approvals and test results |
Description
This PR adds a debug facility.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?