Skip to content

Commit 4252f18

Browse files
DaanHooglandabh1sar
authored andcommitted
Apply suggestions from code review
Co-authored-by: Abhisar Sinha <63767682+abh1sar@users.noreply.github.com> Co-authored-by: dahn <daan.hoogland@gmail.com>
1 parent d93b722 commit 4252f18

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ public UserVm resetVMPassword(ResetVMPasswordCmd cmd, String password) throws Re
882882
private boolean resetVMPasswordInternal(Long vmId, String password) throws ResourceUnavailableException, InsufficientCapacityException {
883883
VMInstanceVO vmInstance = _vmDao.findById(vmId);
884884

885-
if (password == null || password.isEmpty()) {
885+
if (StringUtils.isBlank(password)) {
886886
return false;
887887
}
888888

@@ -3806,7 +3806,7 @@ public void removeInstanceFromInstanceGroup(long vmId) {
38063806
}
38073807

38083808
private boolean validPassword(String password) {
3809-
if (password == null || password.isEmpty()) {
3809+
if (StringUtils.isBlank(password)) {
38103810
return false;
38113811
}
38123812
for (int i = 0; i < password.length(); i++) {
@@ -4642,7 +4642,7 @@ private void assignInstanceToGroup(String group, long id) {
46424642
}
46434643

46444644
private long verifyAndGetDiskSize(DiskOffering diskOffering, Long diskSize) {
4645-
long size = 0L;
4645+
long size;
46464646
if (diskOffering == null) {
46474647
throw new InvalidParameterValueException("Specified disk offering cannot be found");
46484648
}
@@ -5183,7 +5183,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
51835183
sc_nic.addAnd("macAddress", SearchCriteria.Op.EQ, vmNetworkStat.getMacAddress());
51845184
NicVO nic = _nicDao.search(sc_nic, null).get(0);
51855185
List<VlanVO> vlan = _vlanDao.listVlansByNetworkId(nic.getNetworkId());
5186-
if (vlan == null || vlan.isEmpty() || vlan.get(0).getVlanType() != VlanType.DirectAttached)
5186+
if (CollectionUtils.isEmpty(vlan) || vlan.get(0).getVlanType() != VlanType.DirectAttached)
51875187
{
51885188
break; // only get network statistics for DirectAttached network (shared networks in Basic zone and Advanced zone with/without SG)
51895189
}
@@ -5363,7 +5363,7 @@ private void addUserVMCmdlineArgs(Long vmId, VirtualMachineProfile profile, Depl
53635363
if (dc.getDns2() != null) {
53645364
buf.append(" dns2=").append(dc.getDns2());
53655365
}
5366-
logger.info("cmdline details: "+ buf);
5366+
logger.info("cmdline details: {}”, buf);
53675367
}
53685368

53695369
@Override
@@ -5784,7 +5784,7 @@ private Pair<UserVmVO, Map<VirtualMachineProfile.Param, Object>> startVirtualMac
57845784
throw new InvalidParameterValueException(ApiConstants.BOOT_INTO_SETUP + " makes no sense for " + vm.getHypervisorType());
57855785
}
57865786
Object paramValue = additionalParams.get(VirtualMachineProfile.Param.BootIntoSetup);
5787-
logger.trace("It was specified whether to enter setup mode: {}", paramValue.toString());
5787+
logger.trace("It was specified whether to enter setup mode: {}", paramValue);
57885788
params = createParameterInParameterMap(params, additionalParams, VirtualMachineProfile.Param.BootIntoSetup, paramValue);
57895789
}
57905790

@@ -6086,7 +6086,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
60866086
SearchCriteria<VolumeVO> sc_volume = _volsDao.createSearchCriteria();
60876087
sc_volume.addAnd("path", SearchCriteria.Op.LIKE, vmDiskStat.getPath() + "%");
60886088
List<VolumeVO> volumes = _volsDao.search(sc_volume, null);
6089-
if ((volumes == null) || (volumes.isEmpty())) {
6089+
if (CollectionUtils.isEmpty(volumes)) {
60906090
break;
60916091
}
60926092
VolumeVO volume = volumes.get(0);
@@ -9331,7 +9331,7 @@ public void finalizeUnmanage(VirtualMachine vm) {
93319331

93329332
private void encryptAndStorePassword(UserVmVO vm, String password) {
93339333
String sshPublicKeys = vm.getDetail(VmDetailConstants.SSH_PUBLIC_KEY);
9334-
if (sshPublicKeys != null && !sshPublicKeys.isEmpty() && password != null && !password.equals("saved_password")) {
9334+
if (!StringUtils.isEmpty(sshPublicKeys) && password != null && !password.equals("saved_password")) {
93359335
if (!sshPublicKeys.startsWith("ssh-rsa")) {
93369336
logger.warn("Only RSA public keys can be used to encrypt a vm password.");
93379337
return;

0 commit comments

Comments
 (0)