-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CKS: fix NPE when remove a failed external node #12407
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
base: 4.22
Are you sure you want to change the base?
CKS: fix NPE when remove a failed external node #12407
Conversation
9750c2a to
415ebb1
Compare
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
@blueorangutan package |
|
@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
| public static boolean checkIfVmsAssociatedWithBackupOffering(List<VMInstanceVO> vms) { | ||
| for(VMInstanceVO vm : vms) { | ||
| if (Objects.nonNull(vm.getBackupOfferingId())) { | ||
| if (ObjectUtils.allNotNull(vm, vm.getBackupOfferingId())) { |
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 evaluation happen in the right order here? it seems to be the second argument will throw an NPE if applicable (i.e. vm is null) before the arguments are passed!?!
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.
yes, the values are checked in the order.
if the first value is null, it returns false without checking the second value
I think it is same to vm != null && vm.getBackupOfferingId() != null
refer to the code of allNotNull method
public static boolean allNotNull(Object... values) {
if (values == null) {
return false;
} else {
for(Object val : values) {
if (val == null) {
return false;
}
}
return true;
}
}
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.
running
@Test
public void testObjectsAreNull() {
VMInstanceVO vm = null;
ObjectUtils.allNotNull(vm, vm.getAccountId());
}
will yield
java.lang.NullPointerException: Cannot invoke "com.cloud.vm.VMInstanceVO.getAccountId()" because "vm" is null
415ebb1 to
fb18a23
Compare
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16336 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12407 +/- ##
============================================
- Coverage 17.59% 17.59% -0.01%
+ Complexity 15600 15597 -3
============================================
Files 5910 5910
Lines 529733 529733
Branches 64719 64719
============================================
- Hits 93218 93208 -10
- Misses 426023 426033 +10
Partials 10492 10492
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
This PR fixes #11581
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?