Skip to content

Commit fb3a2ec

Browse files
Fix NPE if global setting implicit.host.tags is set to null (#8066)
1 parent 8350ce5 commit fb3a2ec

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

server/src/main/java/com/cloud/deploy/FirstFitPlanner.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public class FirstFitPlanner extends AdapterBase implements DeploymentClusterPla
124124

125125
protected String allocationAlgorithm = "random";
126126
protected String globalDeploymentPlanner = "FirstFitPlanner";
127-
protected String[] implicitHostTags;
127+
protected String[] implicitHostTags = new String[0];
128128

129129
@Override
130130
public List<Long> orderClusters(VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException {
@@ -214,11 +214,11 @@ private void reorderClustersBasedOnImplicitTags(List<Long> clusterList, int requ
214214
Long uniqueTags;
215215
for (Long clusterId : clusterList) {
216216
uniqueTags = (long) 0;
217-
List<Long> hostList = capacityDao.listHostsWithEnoughCapacity(requiredCpu, requiredRam, clusterId, Host.Type.Routing.toString());
218-
if (!hostList.isEmpty() && implicitHostTags.length > 0) {
219-
uniqueTags = new Long(hostTagsDao.getDistinctImplicitHostTags(hostList, implicitHostTags).size());
220-
uniqueTags = uniqueTags + getHostsByCapability(hostList, Host.HOST_UEFI_ENABLE);
221-
}
217+
List<Long> hostList = capacityDao.listHostsWithEnoughCapacity(requiredCpu, requiredRam, clusterId, Host.Type.Routing.toString());
218+
if (!hostList.isEmpty() && implicitHostTags.length > 0) {
219+
uniqueTags = new Long(hostTagsDao.getDistinctImplicitHostTags(hostList, implicitHostTags).size());
220+
uniqueTags = uniqueTags + getHostsByCapability(hostList, Host.HOST_UEFI_ENABLE);
221+
}
222222
UniqueTagsInClusterMap.put(clusterId, uniqueTags);
223223
}
224224
Collections.sort(clusterList, new Comparator<Long>() {

0 commit comments

Comments
 (0)