-
Notifications
You must be signed in to change notification settings - Fork 1.3k
add entity-type to message when no UUID is found for a DB ID #5163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| (entityType == null ? "<unknown type>" ? entityType.getSimpleName()))); | |
| (entityType == null ? "<null>" ? entityType.getSimpleName()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am open to alternatives, but I don't like the , how about just "unknown"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"unknown" sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
| if (customId == null) { | ||
| return null; | ||
| } | ||
| Identity identity = (Identity) this._entityMgr.findById(entityType, customId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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()));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good @sureshanaparti
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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].",...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
GabrielBrascher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM
|
@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?