Source:
<code>protected void removeClustersCrossingThreshold(List<Long> clusterListForVmAllocation, ExcludeList avoid, VirtualMachineProfile vmProfile, DeploymentPlan plan) { VirtualMachine vm = vmProfile.getVirtualMachine(); Map<String, String> details = vmDetailsDao.listDetailsKeyPairs(vm.getId()); Boolean isThresholdEnabled = ClusterThresholdEnabled.value(); <START> if (!(isThresholdEnabled || (details != null && details.containsKey(DEPLOY_VM)))) { <END> return; } List<Short> capacityList = getCapacitiesForCheckingThreshold(); List<Long> clustersCrossingThreshold = new ArrayList<Long>(); ServiceOffering offering = vmProfile.getServiceOffering(); int cpu_requested = offering.getCpu() * offering.getSpeed(); long ram_requested = offering.getRamSize() * 1024L * 1024L; for (short capacity : capacityList) { if (clusterListForVmAllocation == null || clusterListForVmAllocation.size() == 0) { return; } if (capacity == Capacity.CAPACITY_TYPE_CPU) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterCPUCapacityDisableThreshold.key(), cpu_requested); } else if (capacity == Capacity.CAPACITY_TYPE_MEMORY) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterMemoryCapacityDisableThreshold.key(), ram_requested); } if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0) { avoid.addClusterList(clustersCrossingThreshold); clusterListForVmAllocation.removeAll(clustersCrossingThreshold); s_logger.debug("Cannot allocate cluster list " + clustersCrossingThreshold.toString() + " for vm creation since their allocated percentage" + " crosses the disable capacity threshold defined at each cluster/ at global value for capacity Type : " + capacity + ", skipping these clusters"); } } }</code><technical_language>details null. Therefore, remove check here. Also, making conditional mode readable? !isThresholdEnabled && ! details.containsKey(DEPLOY_VM) instead of !(isThresholdEnabled || (details != null && details.containsKey(DEPLOY_VM)))</technical_language>

Target:
protected void removeClustersCrossingThreshold(List<Long> clusterListForVmAllocation, ExcludeList avoid, VirtualMachineProfile vmProfile, DeploymentPlan plan) { VirtualMachine vm = vmProfile.getVirtualMachine(); Map<String, String> details = vmDetailsDao.listDetailsKeyPairs(vm.getId()); Boolean isThresholdEnabled = ClusterThresholdEnabled.value(); if (!isThresholdEnabled && !details.containsKey(DEPLOY_VM)) { return; } List<Short> capacityList = getCapacitiesForCheckingThreshold(); List<Long> clustersCrossingThreshold = new ArrayList<Long>(); ServiceOffering offering = vmProfile.getServiceOffering(); int cpu_requested = offering.getCpu() * offering.getSpeed(); long ram_requested = offering.getRamSize() * 1024L * 1024L; for (short capacity : capacityList) { if (clusterListForVmAllocation == null || clusterListForVmAllocation.size() == 0) { return; } if (capacity == Capacity.CAPACITY_TYPE_CPU) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterCPUCapacityDisableThreshold.key(), cpu_requested); } else if (capacity == Capacity.CAPACITY_TYPE_MEMORY) { clustersCrossingThreshold = capacityDao.listClustersCrossingThreshold(capacity, plan.getDataCenterId(), ClusterMemoryCapacityDisableThreshold.key(), ram_requested); } if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0) { avoid.addClusterList(clustersCrossingThreshold); clusterListForVmAllocation.removeAll(clustersCrossingThreshold); s_logger.debug("Cannot allocate cluster list " + clustersCrossingThreshold.toString() + " for vm creation since their allocated percentage" + " crosses the disable capacity threshold defined at each cluster/ at global value for capacity Type : " + capacity + ", skipping these clusters"); } } }