Skip to content

Commit fae86a4

Browse files
author
Daman Arora
committed
Refactor image store validation to use CollectionUtils
1 parent 18f1ce1 commit fae86a4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/version/KubernetesVersionManagerImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.cloudstack.context.CallContext;
3636
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
3737
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
38+
import org.apache.commons.collections.CollectionUtils;
3839
import org.apache.commons.lang3.StringUtils;
3940

4041
import com.cloud.api.query.dao.TemplateJoinDao;
@@ -326,7 +327,7 @@ private void validateImageStoreForZone(Long zoneId, boolean directDownload) {
326327
}
327328
if (zoneId != null) {
328329
List<ImageStoreVO> imageStores = imageStoreDao.listStoresByZoneId(zoneId);
329-
if (imageStores == null || imageStores.isEmpty()) {
330+
if (CollectionUtils.isEmpty(imageStores)) {
330331
DataCenterVO zone = dataCenterDao.findById(zoneId);
331332
String zoneName = zone != null ? zone.getName() : String.valueOf(zoneId);
332333
throw new InvalidParameterValueException(String.format("Unable to register Kubernetes version ISO. No image store available in zone: %s", zoneName));
@@ -336,7 +337,7 @@ private void validateImageStoreForZone(Long zoneId, boolean directDownload) {
336337
List<String> zonesWithoutStorage = new ArrayList<>();
337338
for (DataCenterVO zone : zones) {
338339
List<ImageStoreVO> imageStores = imageStoreDao.listStoresByZoneId(zone.getId());
339-
if (imageStores == null || imageStores.isEmpty()) {
340+
if (CollectionUtils.isEmpty(imageStores)) {
340341
zonesWithoutStorage.add(zone.getName());
341342
}
342343
}

0 commit comments

Comments
 (0)