auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public VmDevice addSoundDevice(VmBase vmBase, Supplier<Cluster> clusterSupplier) { ChipsetType chipset = EmulatedMachineUtils.getEffectiveChipset(vmBase, clusterSupplier); Version compatibilityVersion = vmBase instanceof VmTemplate ? START CompatibilityVersionUtils.getEffective((VmBase) null, clusterSupplier) END : clusterUtils.getCompatibilityVersion(vmBase); return addSoundDevice(vmBase.getId(), vmBase.getOsId(), compatibilityVersion, chipset); } why not to use the custom compatibility level of the template, if it is set?

Target:
public VmDevice addSoundDevice(VmBase vmBase, Supplier<Cluster> clusterSupplier) { ChipsetType chipset = EmulatedMachineUtils.getEffectiveChipset(vmBase, clusterSupplier); Version compatibilityVersion = CompatibilityVersionUtils.getEffective(vmBase, clusterSupplier); return addSoundDevice(vmBase.getId(), vmBase.getOsId(), compatibilityVersion, chipset); }
Source:
private boolean shouldAbortOnClientInactivityTimeout(ImageTransfer entity, long ts, Integer idleTimeFromTicket) { int START inactivityTimeout = END entity.getClientInactivityTimeout() != null ? entity.getClientInactivityTimeout() : getTransferImageClientInactivityTimeoutInSeconds(); // For new daemon (1.3.0), we check timeout according to 'idle_time' in ticket; // otherwise, fallback to check according to entity's 'lastUpdated'. boolean timeoutExceeded = idleTimeFromTicket != null ? idleTimeFromTicket > inactivityTimeout : ts > (entity.getLastUpdated().getTime() / 1000) + inactivityTimeout; return inactivityTimeout > 0 && timeoutExceeded && !entity.getActive(); } Looks like it can be taken directly from the entity.

Target:
private boolean shouldAbortOnClientInactivityTimeout(ImageTransfer entity, long ts, Integer idleTimeFromTicket) { int inactivityTimeout = entity.getClientInactivityTimeout(); // For new daemon (1.3.0), we check timeout according to 'idle_time' in ticket; // otherwise, fallback to check according to entity's 'lastUpdated'. boolean timeoutExceeded = idleTimeFromTicket != null ? idleTimeFromTicket > inactivityTimeout : ts > (entity.getLastUpdated().getTime() / 1000) + inactivityTimeout; return inactivityTimeout > 0 && timeoutExceeded && !entity.getActive(); }
Source:
protected void executeVmCommand() { Guid createdSnapshotId = updateActiveSnapshotId(); setActionReturnValue(createdSnapshotId); getParameters().setCreatedSnapshotId(createdSnapshotId); MemoryImageBuilder memoryImageBuilder = getMemoryImageBuilder(); freezeVm(); ActionReturnValue actionReturnValue = createSnapshotsForDisks(); if (actionReturnValue.getSucceeded()) { memoryImageBuilder.build(); addSnapshotToDB(createdSnapshotId, memoryImageBuilder); fastForwardDisksToActiveSnapshot(); setSucceeded(true); } START else { setSucceeded(false); } END } redundant, right?

Target:
protected void executeVmCommand() { Guid createdSnapshotId = updateActiveSnapshotId(); setActionReturnValue(createdSnapshotId); getParameters().setCreatedSnapshotId(createdSnapshotId); MemoryImageBuilder memoryImageBuilder = getMemoryImageBuilder(); freezeVm(); ActionReturnValue actionReturnValue = createSnapshotsForDisks(); if (actionReturnValue.getSucceeded()) { memoryImageBuilder.build(); addSnapshotToDB(createdSnapshotId, memoryImageBuilder); fastForwardDisksToActiveSnapshot(); setSucceeded(true); } }
Source:
private static void toStringBuilder(Iterable iterable, StringBuilder builder) { Iterator<Object> iterator = iterable.iterator(); START if (!iterator.hasNext()) { builder.append("[]"); return; } END builder.append("["); while (iterator.hasNext()) { toStringBuilder(iterator.next(), builder); if (iterator.hasNext()) { builder.append(", "); } } builder.append("]"); } You don't need this special case

Target:
private static void toStringBuilder(Iterable iterable, StringBuilder builder) { builder.append("["); Iterator<Object> iterator = iterable.iterator(); while (iterator.hasNext()) { toStringBuilder(iterator.next(), builder); if (iterator.hasNext()) { builder.append(", "); } } builder.append("]"); }
Source:
protected void executeVmCommand() { RemoveMemoryVolumesParameters parameters = new RemoveMemoryVolumesParameters(snapshot, getVmId()); runInternalAction(ActionType.RemoveMemoryVolumes, parameters); START snapshot.setMemoryDiskId(null); snapshot.setMetadataDiskId(null); snapshotDao.update(snapshot); END setSucceeded(true); } didn't you plan to clear the entity first?

Target:
protected void executeVmCommand() { snapshot.setMemoryDiskId(null); snapshot.setMetadataDiskId(null); snapshotDao.update(snapshot); RemoveMemoryVolumesParameters parameters = new RemoveMemoryVolumesParameters(snapshot, getVmId()); runInternalAction(ActionType.RemoveMemoryVolumes, parameters); setSucceeded(true); }
Source:
private boolean supportsDeferredPrallocation() { return FeatureSupported.isDeferringFileVolumePreallocationSupported( getStoragePool().getCompatibilityVersion()) && START getType() == VolumeType.Preallocated && getStorageDomain().getStorageType().isFileDomain(); END } Reverse the order, isFileDomain first then Preallocated then FeatureSupported

Target:
private boolean supportsDeferredPrallocation() { return getStorageDomain().getStorageType().isFileDomain() && getType() == VolumeType.Preallocated && FeatureSupported.isDeferringFileVolumePreallocationSupported( getStoragePool().getCompatibilityVersion()); }
Source:
private boolean isConsoleCommandsExecutionAllowed() { if (getSelectedItem() == null) { return false; } // return true, if at least one console is available START return getSelectedItems() END .stream() .map(consolesFactory::getVmConsolesForVm) .anyMatch(VmConsoles::canConnectToConsole); } are you sure the getSelectedItems() will never return null here? I would not be so sure :) Or did you mean the if() above should check for getSelectedItems() instead?

Target:
private boolean isConsoleCommandsExecutionAllowed() { if (getSelectedItems() == null) { return false; } // return true, if at least one console is available return getSelectedItems() .stream() .map(consolesFactory::getVmConsolesForVm) .anyMatch(VmConsoles::canConnectToConsole); }
Source:
private boolean shouldAbortOnClientInactivityTimeout(ImageTransfer entity, long ts, Integer idleTimeFromTicket) { int inactivityTimeout = getTransferImageClientInactivityTimeoutInSeconds(); // For new daemon (1.3.0), we check timeout according to 'idle_time' in ticket; // otherwise, fallback to check according to entity's 'lastUpdated'. boolean timeoutExceeded = idleTimeFromTicket != null ? idleTimeFromTicket > inactivityTimeout : ts > (entity.getLastUpdated().getTime() / 1000) + inactivityTimeout; return inactivityTimeout > 0 && timeoutExceeded && entity.getPhase().canBePaused() && START !entity.getActive(); END } Previously we didn't have it. Why do we need it now?

Target:
private boolean shouldAbortOnClientInactivityTimeout(ImageTransfer entity, long ts, Integer idleTimeFromTicket) { int inactivityTimeout = getTransferImageClientInactivityTimeoutInSeconds(); // For new daemon (1.3.0), we check timeout according to 'idle_time' in ticket; // otherwise, fallback to check according to entity's 'lastUpdated'. boolean timeoutExceeded = idleTimeFromTicket != null ? idleTimeFromTicket > inactivityTimeout : ts > (entity.getLastUpdated().getTime() / 1000) + inactivityTimeout; return inactivityTimeout > 0 && timeoutExceeded && !entity.getActive(); }
Source:
private void addPluginActionButtons(List<ActionButtonDefinition<?>> pluginActionButtonList) { if (hasActionPanelPresenterWidget()) { for(ActionButtonDefinition<?> buttonDef: pluginActionButtonList) { getActionPanelPresenterWidget().addActionButton((ActionButtonDefinition) buttonDef, START (int) buttonDef.getPriority()); END } } } This effectively limits action button priority to integers, is this what we really want?

Target:
private void addPluginActionButtons(List<ActionButtonDefinition<?>> pluginActionButtonList) { if (hasActionPanelPresenterWidget()) { for(ActionButtonDefinition<?> buttonDef: pluginActionButtonList) { getActionPanelPresenterWidget().addActionButton((ActionButtonDefinition) buttonDef); } } }
Source:
private void mapPhysicalNetworkParameters(com.woorea.openstack.quantum.model.Network externalNetwork, Network network) { String providerNetworkType = externalNetwork.getProviderNetworkType(); START network.getProvidedBy().setExternalVlanId(providerNetworkType != null && providerNetworkType.equals(VLAN_NETWORK) END ? externalNetwork.getProviderSegmentationId() : null); network.getProvidedBy().setCustomPhysicalNetworkName(externalNetwork.getProviderPhysicalNetwork()); } VLAN_NETWORK.equals(externalNetwork.getProviderNetworkType())

Target:
private void mapPhysicalNetworkParameters(com.woorea.openstack.quantum.model.Network externalNetwork, Network network) { String providerNetworkType = externalNetwork.getProviderNetworkType(); network.getProvidedBy().setExternalVlanId(VLAN_NETWORK.equals(providerNetworkType) ? externalNetwork.getProviderSegmentationId() : null); network.getProvidedBy().setCustomPhysicalNetworkName(externalNetwork.getProviderPhysicalNetwork()); }
Source:
protected VM getVmFromConfiguration() { QueryReturnValue queryReturnValue = runInternalQuery( QueryType.GetVmConfigurationBySnapshot, new IdQueryParameters(getParameters().getSnapshotId())); START return queryReturnValue.getSucceeded() ? queryReturnValue.getReturnValue() : null; END } coverity will probably be mad because of a possible NPE when we return null here

Target:
private VM getVmFromConfiguration() { QueryReturnValue queryReturnValue = runInternalQuery( QueryType.GetVmConfigurationBySnapshot, new IdQueryParameters(getParameters().getSnapshotId())); return queryReturnValue.getSucceeded() ? queryReturnValue.getReturnValue() : null; }
Source:
private Guid getSnapshotId(Snapshots snapshots) { return START (snapshots.getSnapshots() != null && END !snapshots.getSnapshots().isEmpty()) ? asGuid(snapshots.getSnapshots().get(0).getId()) : Guid.Empty; } if snapshots.getSnapshots() == null then we'll fail with NPE in validateSnapshotExistence, no?

Target:
private Guid getSnapshotId(Snapshots snapshots) { return asGuid(snapshots.getSnapshots().get(0).getId()); }
Source:
public void startingVmCompleted(Guid vmId, String cause) { START if (log.isDebugEnabled() && startingVms.contains(vmId)) { END log.debug("Startup of VM completed ({})", vmId, cause); } startingVms.remove(vmId); } since we're going to remove the vm anyway, this can be replaced with: if (startingVms.remove(vmId) && log.isDebugEnabled()) right?

Target:
public void startingVmCompleted(Guid vmId, String cause) { if (startingVms.remove(vmId)) { log.debug("Startup of VM completed ({})", vmId, cause); } }
Source:
private boolean isUserSearchUsingTags() { return getSearchObjectStr() != null START && getSearchObjectStr().equals(SearchObjects.VDC_USER_OBJ_NAME) END && origText.contains("vm"); } If we revert the operands in the condition, we can remove not null check: return SearchObjects.VDC_USER_OBJ_NAME.equals(getSearchObjectStr()) && origText.contains("vm");

Target:
private boolean isUserSearchUsingTags() { return SearchObjects.VDC_USER_OBJ_NAME.equals(getSearchObjectStr()) && origText.contains("vm"); }
Source:
START protected boolean isAnyVmRunOnVdsInDb(Guid vdsId) { if (!Config.<Boolean>getValue(ConfigValues.MaintenanceVdsIgnoreExternalVms)) { return vmDynamicDao.isAnyVmRunOnVds(vdsId); } return !vmStaticDao.getAllRunningForVds(vdsId) .stream() .filter(vm -> !OriginType.EXTERNAL.equals(vm.getOrigin())) .collect(Collectors.toList()) .isEmpty(); } END but there's no reason to change this method now, no?

Target:
protected boolean isAnyVmRunOnVdsInDb(Guid vdsId) { return vmDynamicDao.isAnyVmRunOnVds(vdsId); }
Source:
public void vmTypeChanged(VmType vmType) { // provisioning thin -> false // provisioning clone -> true if (getModel().getProvisioning().getIsAvailable()) { getModel().getProvisioning().setEntity(vmType == VmType.Server || vmType == VmType.HighPerformance); } if (getModel().getIoThreadsEnabled().getIsAvailable()) { getModel().getIoThreadsEnabled().setEntity(vmType == VmType.Server || vmType == VmType.HighPerformance); START } END super.vmTypeChanged(vmType); } why not in VmModelBaseBehavior#vmTypeChanged?

Target:
public void vmTypeChanged(VmType vmType) { // provisioning thin -> false // provisioning clone -> true if (getModel().getProvisioning().getIsAvailable()) { getModel().getProvisioning().setEntity(vmType == VmType.Server || vmType == VmType.HighPerformance); } super.vmTypeChanged(vmType); }
Source:
protected boolean validateBackupDomainNotFirstInPool() { START if (getStoragePool() != null) { if (getStoragePool().getStatus() == StoragePoolStatus.Uninitialized && getStorageDomain().isBackup()) END { return failValidation(EngineMessage.ACTION_TYPE_FAILED_FIRST_DOMAIN_CANNOT_BE_BACKUP); } } return true; } Please use here one if condition: if (getStoragePool() != null && getStoragePool().getStatus() == StoragePoolStatus.Uninitialized && getStorageDomain().isBackup())

Target:
protected boolean validateBackupDomainNotFirstInPool() { if (getStoragePool() != null && getStoragePool().getStatus() == StoragePoolStatus.Uninitialized && getStorageDomain().isBackup()) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_FIRST_DOMAIN_CANNOT_BE_BACKUP); } return true; }
Source:
protected boolean validate() { if (!super.validate() || !checkStorageDomain()) { return false; } // Only after validating the existence of the storage domain in DB, we set the field lastTimeUsedAsMaster in the // storage domain which is about to be updated. oldDomain = storageDomainStaticDao.get(getStorageDomain().getId()); getStorageDomain().setLastTimeUsedAsMaster(oldDomain.getLastTimeUsedAsMaster()); START return validateMasterDomainCannotBeBackup() && validateStoragePropertiesUpdate(); END } I think that a proper place would be to put this after line 63 as part of validateStoragePropertiesUpdate. We can keep the validate method clean that way

Target:
protected boolean validate() { if (!super.validate() || !checkStorageDomain()) { return false; } // Only after validating the existence of the storage domain in DB, we set the field lastTimeUsedAsMaster in the // storage domain which is about to be updated. oldDomain = storageDomainStaticDao.get(getStorageDomain().getId()); getStorageDomain().setLastTimeUsedAsMaster(oldDomain.getLastTimeUsedAsMaster()); return validateStoragePropertiesUpdate(); }
Source:
public static BootProtocol map(Ipv6BootProtocol entity) { if (entity == null) { return null; } switch (entity) { START case POLY_DHCP_AUTOCONF: END case AUTOCONF: return BootProtocol.AUTOCONF; case DHCP: return BootProtocol.DHCP; case NONE: return BootProtocol.NONE; case STATIC_IP: return BootProtocol.STATIC; default: return null; } } Why don't you add POLY_DHCP_AUTOCONF to BootProtocol?

Target:
public static BootProtocol map(Ipv6BootProtocol entity) { if (entity == null) { return null; } switch (entity) { case AUTOCONF: return BootProtocol.AUTOCONF; case DHCP: return BootProtocol.DHCP; case NONE: return BootProtocol.NONE; case STATIC_IP: return BootProtocol.STATIC; default: return null; } }
Source:
private static boolean chipsetMatchesEmulatedMachine(ChipsetType chipsetType, String emulatedMachine) { if (chipsetType == ChipsetType.I440FX) { return true; } START return chipsetType == ChipsetType.fromMachineType(emulatedMachine); END } that can be shorten to a single line: return chipsetType == ChipsetType.I440FX || chipsetType == ChipsetType.fromMachineType(emulatedMachine); but not a big deal from my side.

Target:
private static boolean chipsetMatchesEmulatedMachine(ChipsetType chipsetType, String emulatedMachine) { return chipsetType == ChipsetType.I440FX || chipsetType == ChipsetType.fromMachineType(emulatedMachine); }
Source:
private void checkVdsMemoryThresholdPercentage(Cluster cluster, VdsStatistics stat) { START Integer maxUsedPercentageThreshold = END cluster.getLogMaxMemoryUsedThreshold(); if (stat.getUsageMemPercent() > maxUsedPercentageThreshold) { logMemoryAuditLog(vds, stat, AuditLogType.VDS_HIGH_MEM_USE, maxUsedPercentageThreshold); } } please merge lines

Target:
private void checkVdsMemoryThresholdPercentage(Cluster cluster, VdsStatistics stat) { Integer maxUsedPercentageThreshold = cluster.getLogMaxMemoryUsedThreshold(); if (stat.getUsageMemPercent() > maxUsedPercentageThreshold) { logMemoryAuditLog(vds, cluster, stat, AuditLogType.VDS_HIGH_MEM_USE, maxUsedPercentageThreshold); } }
Source:
VmDeviceUtils(VmStaticDao vmStaticDao, VmDeviceDao vmDeviceDao, ClusterDao clusterDao, VmTemplateDao vmTemplateDao, VmHandler vmHandler, MacPoolPerCluster macPoolPerCluster, RngDeviceUtils rngDeviceUtils, VideoDeviceSettings videoDeviceSettings, OsRepository osRepository) { this.vmStaticDao = vmStaticDao; this.vmDeviceDao = vmDeviceDao; this.clusterDao = clusterDao; this.vmTemplateDao = vmTemplateDao; this.vmHandler = vmHandler; this.macPoolPerCluster = macPoolPerCluster; this.rngDeviceUtils = rngDeviceUtils; this.videoDeviceSettings = videoDeviceSettings; this.osRepository = osRepository; START this.compensationContext = null; END } redundant?

Target:
VmDeviceUtils(VmStaticDao vmStaticDao, VmDeviceDao vmDeviceDao, ClusterDao clusterDao, VmTemplateDao vmTemplateDao, VmHandler vmHandler, MacPoolPerCluster macPoolPerCluster, RngDeviceUtils rngDeviceUtils, VideoDeviceSettings videoDeviceSettings, OsRepository osRepository) { this.vmStaticDao = vmStaticDao; this.vmDeviceDao = vmDeviceDao; this.clusterDao = clusterDao; this.vmTemplateDao = vmTemplateDao; this.vmHandler = vmHandler; this.macPoolPerCluster = macPoolPerCluster; this.rngDeviceUtils = rngDeviceUtils; this.videoDeviceSettings = videoDeviceSettings; this.osRepository = osRepository; }
Source:
protected BaseDisk generateNewEntity() { BaseDisk d = new BaseDisk(); d.setId(Guid.newGuid()); d.setWipeAfterDelete(true); d.setPropagateErrors(PropagateErrors.Off); d.setDiskAlias("DiskName"); d.setSgio(ScsiGenericIO.FILTERED); START d.setDiskDescription(""); END return d; } Not needed, part of constructor

Target:
protected BaseDisk generateNewEntity() { BaseDisk d = new BaseDisk(); d.setId(Guid.newGuid()); d.setWipeAfterDelete(true); d.setPropagateErrors(PropagateErrors.Off); d.setDiskAlias("DiskName"); d.setSgio(ScsiGenericIO.FILTERED); return d; }
Source:
protected boolean validateImages() { START List<DiskImage> imagesToValidate = getDiskImagesToValidate(); List<DiskImage> allDiskImagesInSrcAndDstToValidate = getAllDiskImagesInSrcAndDstToValidate(); DiskImagesValidator diskImagesValidator = new DiskImagesValidator(imagesToValidate); DiskImagesValidator allDiskImagesInChainValidator = new DiskImagesValidator(allDiskImagesInSrcAndDstToValidate); END return validateImagesNotLocked(diskImagesValidator) && (getVm().isQualifiedForLiveSnapshotMerge() || validate(allDiskImagesInChainValidator.diskImagesNotIllegal())) && (!getVm().isQualifiedForLiveSnapshotMerge() || validateSnapshotDisksArePlugged()); } Please replace line #481 with line #482

Target:
protected boolean validateImages() { List<DiskImage> imagesToValidate = getDiskImagesToValidate(); DiskImagesValidator diskImagesValidator = new DiskImagesValidator(imagesToValidate); List<DiskImage> allDiskImagesInSrcAndDstToValidate = getAllDiskImagesInSrcAndDstToValidate(); DiskImagesValidator allDiskImagesInChainValidator = new DiskImagesValidator(allDiskImagesInSrcAndDstToValidate); return validateImagesNotLocked(diskImagesValidator) && (getVm().isQualifiedForLiveSnapshotMerge() || validate(allDiskImagesInChainValidator.diskImagesNotIllegal())) && (!getVm().isQualifiedForLiveSnapshotMerge() || validateSnapshotDisksArePlugged()); }
Source:
public ArrayList<DiskInterface> getDiskInterfaceList() { return new ArrayList<>( Arrays.asList( START DiskInterface.IDE, DiskInterface.VirtIO, DiskInterface.VirtIO_SCSI, DiskInterface.SPAPR_VSCSI, DiskInterface.SATA END )); } any reason not to just replace it with DiskInterface.values()?

Target:
public ArrayList<DiskInterface> getDiskInterfaceList() { return new ArrayList<>(Arrays.asList(DiskInterface.values())); }
Source:
START public void addComboActionButton(ActionButtonDefinition<T> buttonDef, List<ActionButtonDefinition<T>> subActions) { END ActionButton newButton = getView().addDropdownComboActionButton(buttonDef, subActions, this); actionButtonDefinitions.add(buttonDef); for (ActionButtonDefinition ab : subActions) { actionButtonDefinitions.add(ab); } initButton(buttonDef, newButton); } aren't you changing the behavior of the existing method? I feel like I'm missing something

Target:
public void addComboActionButton(ActionButtonDefinition<T> buttonDef, List<ActionButtonDefinition<T>> subActions) { ActionButton newButton = getView().addDropdownComboActionButton(buttonDef, subActions, this); actionButtonDefinitions.add(buttonDef); initButton(buttonDef, newButton); }
Source:
private void updateOverCommitPercent() { if (getAvailableDiskSize() == null || getAvailableDiskSize() == 0) { setStorageDomainOverCommitPercent(0); } else { START setStorageDomainOverCommitPercent((int)((getCommittedDiskSize() END - getActualImagesSize()) * 100 / getAvailableDiskSize())); } } casting to int here is redundant now..

Target:
private void updateOverCommitPercent() { if (getAvailableDiskSize() == null || getAvailableDiskSize() == 0) { setStorageDomainOverCommitPercent(0); } else { setStorageDomainOverCommitPercent(((getCommittedDiskSize() - getActualImagesSize()) * 100 / getAvailableDiskSize())); } }
Source:
public START long getStorageDomainOverCommitPercent() END { return storageDomainOverCommitPercent; } should be left as int

Target:
public int getStorageDomainOverCommitPercent() { return storageDomainOverCommitPercent; }
Source:
public String getMessage(NetworkItemModel<?> op1, NetworkItemModel<?> op2) { START return appendDetachNetworkSuggestion(getVerb(getNotInSyncNetwork(op2)), op2); END } appendDetachNetworkSuggestion takes the problematic network from 'CulpritNetwork'. Seems that now it won't work since 'getNotInSyncNetwork' return a nework with no 'CulpritNetwork'. I don't have a running env but anyway seems that the old code has a bug, it will print the same network at both parts of the message, isn't it?

Target:
public String getMessage(NetworkItemModel<?> op1, NetworkItemModel<?> op2) { return appendDetachNetworkSuggestion(getVerb(op1), op2); }
Source:
protected void executeQueryCommand() { Map<Guid, DiskImage> imagesAncestors = new HashMap<>(); for (Guid id : getParameters().getIds()) { DiskImage ancestor = diskImageDao.getAncestor(id, getUserID(), getParameters().isFiltered()); START imagesAncestors.put(id, ancestor); END } getQueryReturnValue().setReturnValue(imagesAncestors); } Maybe we need to check that the ancestor is not null before adding to map?

Target:
protected void executeQueryCommand() { Map<Guid, DiskImage> imagesAncestors = new HashMap<>(); for (Guid id : getParameters().getIds()) { DiskImage ancestor = diskImageDao.getAncestor(id, getUserID(), getParameters().isFiltered()); if (ancestor != null) { imagesAncestors.put(id, ancestor); } } getQueryReturnValue().setReturnValue(imagesAncestors); }
Source:
public boolean shouldUseNativeIO(VM vm, DiskImage diskImage, VmDevice device) { StorageType storageType = diskImage.getStorageTypes().get(0); String diskType = getDiskType(vm, diskImage, device); boolean isNativeIO = !"file".equals(diskType) || (storageType == StorageType.GLUSTERFS && FeatureSupported.useNativeIOForGluster(vm.getCompatibilityVersion())); // marked as transient disk and uses cache when snapshotId is not null if ("file".equals(diskType) && device.getSnapshotId() != null) { isNativeIO = false; } START return isNativeIO; END } Seems like we're duplicating code a little here by checking "file".equals(...) multiple times in consecutive lines, and there may be other cases. What about an additional method (public boolean isSnapshot(...)), or simply: boolean isSnapshot = device.getSnapshotId() != null; return isSnapshot ? false : !"file".equals(diskType) || (storageType == StorageType.GLUSTERFS && ...) Otherwise, we're now keeping track of

Target:
public boolean shouldUseNativeIO(VM vm, DiskImage diskImage, VmDevice device) { StorageType storageType = diskImage.getStorageTypes().get(0); String diskType = getDiskType(vm, diskImage, device); boolean isNativeIO = !"file".equals(diskType) || (storageType == StorageType.GLUSTERFS && FeatureSupported.useNativeIOForGluster(vm.getCompatibilityVersion())); // marked as transient disk (file type) and uses cache when snapshotId is not null if (device.getSnapshotId() != null) { isNativeIO = false; } return isNativeIO; }
Source:
public void testNewStorageTypes() { START assertEquals(9, StorageType.values().length, END "A storage type was added/removed. Update this test, and the isFileDomain/isBlockDomain " + "method accordingly"); } please change to 10

Target:
public void testNewStorageTypes() { assertEquals(10, StorageType.values().length, "A storage type was added/removed. Update this test, and the isFileDomain/isBlockDomain " + "method accordingly"); }
Source:
START protected AddCinderStorageDomainCommand(Guid END commandId) { super(commandId); } public

Target:
public AddCinderStorageDomainCommand(Guid commandId) { super(commandId); }
Source:
public boolean equals(Object o) { START if (this == o) END return true; if (!(o instanceof AddCinderStorageDomainParameters)) return false; AddCinderStorageDomainParameters that = (AddCinderStorageDomainParameters) o; return Objects.equals(driverName, that.driverName) && Objects.equals(driverOptions, that.driverOptions); } please add {}. It fails the checkstyle validation

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof AddCinderStorageDomainParameters)) { return false; } AddCinderStorageDomainParameters that = (AddCinderStorageDomainParameters) o; return Objects.equals(driverName, that.driverName) && Objects.equals(driverOptions, that.driverOptions); }
Source:
private String getStorageDomainNameById(String storageDomainId) { START for (StorageDomain storageDomainItem : storageDomainDao.getAll()) { END if (storageDomainItem != null && storageDomainItem.getStorageStaticData() != null) { if (storageDomainItem.getStorageStaticData().getStorage().equals(storageDomainId)) { return storageDomainItem.getStorageStaticData().getName(); } } } return ""; } Since we already have the storage domain ID, can't we just use storageDomainDao.get(storageDomainId) and see if it exists?

Target:
private String getStorageDomainNameById(String storageDomainId) { if ( storageDomainId == null || storageDomainId.equals("")) return ""; for (StorageDomain storageDomainItem : storageDomainDao.getAll()) { if (storageDomainItem != null && storageDomainItem.getStorageStaticData() != null) { if (storageDomainItem.getStorageStaticData().getStorage().equals(storageDomainId)) { return storageDomainItem.getStorageStaticData().getName(); } } } return ""; }
Source:
public void addNotEmptyIdConnection() { StorageServerConnections newPosixConnection = createPosixConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data1", StorageType.POSIXFS, "nfs", "timeo=30"); newPosixConnection.setId(Guid.newGuid().toString()); parameters.setStorageServerConnection(newPosixConnection); parameters.setVdsId(Guid.Empty); START doReturn("").when(command).isConnWithSameDetailsExists(newPosixConnection, END null); ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY); } still an empty string

Target:
public void addNotEmptyIdConnection() { StorageServerConnections newPosixConnection = createPosixConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data1", StorageType.POSIXFS, "nfs", "timeo=30"); newPosixConnection.setId(Guid.newGuid().toString()); parameters.setStorageServerConnection(newPosixConnection); parameters.setVdsId(Guid.Empty); doReturn(newPosixConnection.getId()).when(command).isConnWithSameDetailsExists(newPosixConnection, null); ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY); }
Source:
public boolean isCinderDomain() { return this == CINDER START || this == MANAGED_BLOCK_STORAGE; END } why do we want to correlate cinder and managed block storage?

Target:
public boolean isCinderDomain() { return this == CINDER; }
Source:
public boolean equals(Object o) { START if (this == o) END return true; if (!(o instanceof StorageOffloadDisk)) return false; if (!super.equals(o)) return false; StorageOffloadDisk that = (StorageOffloadDisk) o; return Objects.equals(volumeMetadata, that.volumeMetadata); } please add {}. It fails the checkstyle validation

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof StorageOffloadDisk)) { return false; } if (!super.equals(o)) { return false; } StorageOffloadDisk that = (StorageOffloadDisk) o; return Objects.equals(volumeMetadata, that.volumeMetadata); }
Source:
protected void handleSpecificCommandActions() { START return; END } Not needed, please leave the method empty

Target:
protected void handleSpecificCommandActions() { }
Source:
public static START final AbstractTextColumn<Disk> END getLogicalNameColumn(String sortBy) { AbstractTextColumn<Disk> column = new AbstractTextColumn<Disk>() { @Override public String getValue(Disk object) { if (object.getDiskVmElements().size() == 1) { return object.getDiskVmElements().iterator().next().getLogicalName(); } return null; } }; return makeSortable(column, sortBy); } Maybe we can skip the final here

Target:
public static AbstractTextColumn<Disk> getLogicalNameColumn(String sortBy) { AbstractTextColumn<Disk> column = new AbstractTextColumn<Disk>() { @Override public String getValue(Disk object) { if (object.getDiskVmElements().size() == 1) { return object.getDiskVmElements().iterator().next().getLogicalName(); } return null; } }; return makeSortable(column, sortBy); }
Source:
private boolean isAdAggregatorIdValid(Bond bond, HostInterfaceLineModel lineModel) { String bondAdAggregatorId = Objects.toString(bond.getAdAggregatorId(), START ""); END for (HostInterface nic : lineModel.getInterfaces()) { String nicAggregatorId = Objects.toString(nic.getInterface().getAdAggregatorId(), ""); if (!bondAdAggregatorId.equals(nicAggregatorId)) { return false; } } return true; } I do not understand why the empty string, instead of "null" or null, is required here, but never mind.

Target:
private boolean isAdAggregatorIdValid(Bond bond, HostInterfaceLineModel lineModel) { String bondAdAggregatorId = Objects.toString(bond.getAdAggregatorId()); if (bondAdAggregatorId==null) { return false; } for (HostInterface nic : lineModel.getInterfaces()) { String nicAggregatorId = Objects.toString(nic.getInterface().getAdAggregatorId()); if (!bondAdAggregatorId.equals(nicAggregatorId)) { return false; } } return true; }
Source:
public Cluster() { migrateOnError = MigrateOnErrorOptions.YES; name = ""; virtService = true; optimizationType = OptimizationType.NONE; additionalRngSources = new HashSet<>(); fencingPolicy = new FencingPolicy(); addtionalFeaturesSupported = new HashSet<>(); ksmMergeAcrossNumaNodes = true; migrationBandwidthLimitType = MigrationBandwidthLimitType.DEFAULT; requiredSwitchTypeForCluster = SwitchType.LEGACY; logMaxMemoryUsedThresholdType = LogMaxMemoryUsedThresholdType.PERCENTAGE; description = ""; comment = ""; cpuName = ""; vncEncryptionEnabled = true; maintenanceReasonRequired = true; START optionalReasonRequired = true; END } Can't we remove above variable completely?

Target:
public Cluster() { migrateOnError = MigrateOnErrorOptions.YES; name = ""; virtService = true; optimizationType = OptimizationType.NONE; additionalRngSources = new HashSet<>(); fencingPolicy = new FencingPolicy(); addtionalFeaturesSupported = new HashSet<>(); ksmMergeAcrossNumaNodes = true; migrationBandwidthLimitType = MigrationBandwidthLimitType.DEFAULT; requiredSwitchTypeForCluster = SwitchType.LEGACY; logMaxMemoryUsedThresholdType = LogMaxMemoryUsedThresholdType.PERCENTAGE; description = ""; comment = ""; cpuName = ""; vncEncryptionEnabled = true; }
Source:
public static BackupPhase map(org.ovirt.engine.core.common.businessentities.VmBackupPhase action) { switch (action) { case START Initializing: END return BackupPhase.INITIALIZING; case Starting: return BackupPhase.STARTING; case Ready: return BackupPhase.READY; case Finalizing: return BackupPhase.FINALIZING; default: return null; } } please make this upper case

Target:
public static BackupPhase map(org.ovirt.engine.core.common.businessentities.VmBackupPhase action) { switch (action) { case INITIALIZING: return BackupPhase.INITIALIZING; case STARTING: return BackupPhase.STARTING; case READY: return BackupPhase.READY; case FINALIZING: return BackupPhase.FINALIZING; default: return null; } }
Source:
public ClusterValidator( ClusterDao clusterDao, StoragePoolDao dataCenterDao, Cluster cluster, CpuFlagsManagerHandler cpuFlagsManagerHandler) { this(clusterDao, dataCenterDao, cluster, cpuFlagsManagerHandler, START null, END null, null, null, null, null); } can we inject the dao's into this class, this does not look nice, so many nulls

Target:
public ClusterValidator( ClusterDao clusterDao, StoragePoolDao dataCenterDao, Cluster cluster, CpuFlagsManagerHandler cpuFlagsManagerHandler) { this.cluster = cluster; this.clusterDao = clusterDao; this.dataCenterDao = dataCenterDao; this.cpuFlagsManagerHandler = cpuFlagsManagerHandler; }
Source:
private ValidationResult validateWithHostSetupNetworksValidator(VDS host) { NetworkAttachment START networkAttachment = END selectNetworkAttachmentForValidatation(); HostSetupNetworksValidator validator = new HostSetupNetworksValidator(host, getParameters(), getExistingNics(), getExistingAttachments(), networkAttachment, getNetworkBusinessEntityMap(), networkClusterDao, networkDao, vdsDao, findActiveVmsUsingNetwork, hostSetupNetworksValidatorHelper, networkExclusivenessValidatorResolver, networkAttachmentIpConfigurationValidator, unmanagedNetworkValidator, backend); return validator.validate(); } the variable is not required

Target:
private ValidationResult validateWithHostSetupNetworksValidator(VDS host) { HostSetupNetworksValidator validator = new HostSetupNetworksValidator(host, getParameters(), getExistingNics(), getExistingAttachments(), selectNetworkAttachmentForValidatation(), getNetworkBusinessEntityMap(), networkClusterDao, networkDao, vdsDao, findActiveVmsUsingNetwork, hostSetupNetworksValidatorHelper, networkExclusivenessValidatorResolver, networkAttachmentIpConfigurationValidator, unmanagedNetworkValidator, backend); return validator.validate(); }
Source:
START public static END boolean areSameId(NetworkAttachment a, NetworkAttachment b) { return a != null && b != null && a.getId() != null && a.getId().equals(b.getId()); } private

Target:
static boolean areSameId(NetworkAttachment a, NetworkAttachment b) { return a != null && b != null && a.getId() != null && a.getId().equals(b.getId()); }
Source:
START static boolean areSameId(NetworkAttachment a, NetworkAttachment b) { END return a != null && b != null && a.getId() != null && a.getId().equals(b.getId()); } Why not private?

Target:
private static boolean areSameId(NetworkAttachment a, NetworkAttachment b) { return a != null && b != null && a.getId() != null && a.getId().equals(b.getId()); }
Source:
public BackendClusterNetworkResource(String id, BackendClusterNetworksResource parent) { super(id, parent, ActionType.DetachNetworkToCluster); clusterId = START ((BackendClusterNetworksResource)parent).clusterId; END } Why is this cast needed? I see it's casting to same type.

Target:
public BackendClusterNetworkResource(String id, BackendClusterNetworksResource parent) { super(id, parent, ActionType.DetachNetworkToCluster); clusterId = (parent).clusterId; }
Source:
private START static String END prependZeroes(String twoBytes) { StringBuilder builder = new StringBuilder(); int zeroLen = 4 - twoBytes.length(); for (int i = 0; i < zeroLen; i++) { builder.append(ZERO_STRING); } builder.append(twoBytes); return builder.toString(); } why static?

Target:
private String prependZeroes(String twoBytes) { StringBuilder builder = new StringBuilder(); int zeroLen = 4 - twoBytes.length(); for (int i = 0; i < zeroLen; i++) { builder.append(ZERO_STRING); } builder.append(twoBytes); return builder.toString(); }
Source:
private void adjustKVMDataForBlockSD() { // This is a workaround until bz 1332019 will be merged // since KVM is currently the only source for which we use Libvirt streaming API. // Libvirt currently reports the actual disk size and the virtual one, // when using preallocated qcow2 on block domain the size that the Libvirt stream emits // can be larger then the actual size. // Separately, setting the Volume Type to Preallocated avoids Sparseness when the // Destination is a Block SD if (getVm().getOrigin() == OriginType.KVM && getActionState() == CommandActionState.EXECUTE && getStorageDomain() != null && getStorageDomain().getStorageType().isBlockDomain()) { getVm().getImages().forEach(image -> image.setActualSizeInBytes(image.getSize())); START getVm().getImages().forEach(image -> image.setVolumeType(VolumeType.Preallocated)); END } } since it's the same forEach, why don't you call both function at the same time?

Target:
private void adjustKVMDataForBlockSD() { // This is a workaround until bz 1332019 will be merged // since KVM is currently the only source for which we use Libvirt streaming API. // Libvirt currently reports the actual disk size and the virtual one, // when using preallocated qcow2 on block domain the size that the Libvirt stream emits // can be larger then the actual size. // Separately, setting the Volume Type to Preallocated avoids Sparseness when the // Destination is a Block SD if (getVm().getOrigin() == OriginType.KVM && getActionState() == CommandActionState.EXECUTE && getStorageDomain() != null && getStorageDomain().getStorageType().isBlockDomain()) { getVm().getImages().forEach(image -> { image.setActualSizeInBytes(image.getSize()); image.setVolumeType(VolumeType.Preallocated); }); } }
Source:
protected boolean checkIfCpusSameManufacture(Cluster group) { START if (!cpuFlagsManagerHandler.checkIfCpusExist(group.getCpuName(), END getParameters().getCluster().getCompatibilityVersion())) { return true; } return cpuFlagsManagerHandler.checkIfCpusSameManufacture(group.getCpuName(), getCluster().getCpuName(), getCluster().getCompatibilityVersion()); } shouldn't it check the getCluster().getCpuName() too?

Target:
protected boolean checkIfCpusSameManufacture(Cluster group) { if (!cpuFlagsManagerHandler.checkIfCpusExist(group.getCpuName(), getParameters().getCluster().getCompatibilityVersion()) || !cpuFlagsManagerHandler.checkIfCpusExist(getCluster().getCpuName(), getParameters().getCluster().getCompatibilityVersion())) { return true; } return cpuFlagsManagerHandler.checkIfCpusSameManufacture(group.getCpuName(), getCluster().getCpuName(), getCluster().getCompatibilityVersion()); }
Source:
protected void updateOSValue(final Integer selectedOsId) { Cluster cluster = getModel().getSelectedCluster(); START if (cluster != null) { END List<Integer> vmOsValues = AsyncDataProvider.getInstance().getOsIds(cluster.getArchitecture()); if (selectedOsId == null || !vmOsValues.contains(selectedOsId)) { updateOSValues(); return; } getModel().getOSType().setSelectedItem(selectedOsId); } } Please, change this statement to the early return form. That's the standard we use throughout the code. That's the only objection I have currently. If you fix it now, I'll be able to merge the code before branching 4.3.

Target:
protected void updateOSValue(final Integer selectedOsId) { Cluster cluster = getModel().getSelectedCluster(); if (cluster == null) { return; } List<Integer> vmOsValues = AsyncDataProvider.getInstance().getOsIds(cluster.getArchitecture()); if (selectedOsId == null || !vmOsValues.contains(selectedOsId)) { updateOSValues(); return; } getModel().getOSType().setSelectedItem(selectedOsId); }
Source:
private void addMaintenanceFailedReason(List<String> failedMessages) { Guid rootCommandGuid = commandsRepository.getCommandEntity(getCommandId()).getRootCommandId(); CommandBase<T> rootCommand = commandCoordinatorUtil.retrieveCommand(rootCommandGuid); String messageToDisplay = failedMessages.get(0); rootCommand.addCustomValue("Message", messageToDisplay); START auditLogDirector.log(rootCommand, AuditLogType.VDS_MAINTENANCE_FAILED_REASON, messageToDisplay); END } Why not do something similar to MigrateVmCommand private void addMaintenanceFailedReason() { addCustomValue("Message",backend.getErrorsTranslator().translateErrorText(getReturnValue().getValidationMessages())); auditLogDirector.log(this,AuditLogType.VDS_MAINTENANCE_FAILED_REASON); }

Target:
private void addMaintenanceFailedReason(List<String> failedMessages) { Guid rootCommandGuid = commandsRepository.getCommandEntity(getCommandId()).getRootCommandId(); CommandBase<T> rootCommand = commandCoordinatorUtil.retrieveCommand(rootCommandGuid); String messageToDisplay = failedMessages.get(0); addCustomValue("Message", messageToDisplay); auditLogDirector.log(this, AuditLogType.VDS_MAINTENANCE_FAILED_REASON, messageToDisplay); // rootCommand.addCustomValue("Message", messageToDisplay); // auditLogDirector.log(rootCommand, AuditLogType.VDS_MAINTENANCE_FAILED_REASON, messageToDisplay); }
Source:
public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> hostSubjects = vdsIds.stream() .map(vdsId -> new PermissionSubject(vdsId, VdcObjectType.VDS, getActionType().getActionGroup())) .collect(Collectors.toList()); START hostSubjects.add(new PermissionSubject(getClusterId(), VdcObjectType.Cluster, ActionGroup.CONFIGURE_HOST_NETWORK)); END return hostSubjects; } Is this backward compatible?

Target:
public List<PermissionSubject> getPermissionCheckSubjects() { return vdsIds.stream() .map(vdsId -> new PermissionSubject(vdsId, VdcObjectType.VDS, getActionType().getActionGroup())) .collect(Collectors.toList()); }
Source:
private boolean isConsoleEnabled() { boolean isConsoleEnabled; if (getParameters().isConsoleEnabled() != null) { START isConsoleEnabled = END getParameters().isConsoleEnabled(); } else { isConsoleEnabled = getVmDeviceUtils().hasConsoleDevice(getVmId()); } return isConsoleEnabled; } You can simply return here, the variable is not needed.

Target:
private boolean isConsoleEnabled() { if (getParameters().isConsoleEnabled() != null) { return getParameters().isConsoleEnabled(); } else { return getVmDeviceUtils().hasConsoleDevice(getVmId()); } }
Source:
protected void executeQueryCommand() { VM vm = getVm(); if (vm == null) { return; } START VM nextRunVm = vmHandler.getNextRunVmConfiguration(getParameters().getId(), getUserID(), getParameters().isFiltered()); END if (nextRunVm != null) { vm.setCustomCompatibilityVersion(nextRunVm.getCustomCompatibilityVersion()); } updateVMDetails(vm); getQueryReturnValue().setReturnValue(vm); } customCompatibilityVersion is the only thing we use here from the whole NEXT_RUN configuration. Now VmHandler#getNextRunVmConfiguration() will load disks, network interfaces etc. Maybe pass an additional parameter that will flag not to load all this information?

Target:
protected void executeQueryCommand() { VM vm = getVm(); if (vm == null) { return; } VM nextRunVm = vmHandler.getNextRunVmConfiguration(getParameters().getId(), getUserID(), getParameters().isFiltered(), false); if (nextRunVm != null) { vm.setCustomCompatibilityVersion(nextRunVm.getCustomCompatibilityVersion()); } updateVMDetails(vm); getQueryReturnValue().setReturnValue(vm); }
Source:
public PersistentHostSetupNetworksParameters(Guid hostId) { START super(hostId); END } Do you consider this(hostId, 1, 1); nicer here?

Target:
public PersistentHostSetupNetworksParameters(Guid hostId) { this(hostId, 1, 1); }
Source:
public void testGetAllOfTypeWithUnrepresentedType() { START List<VDS> result = dao.getAllOfType(VDSType.forValue(-1)); END assertIncorrectGetResult(result); } Sorry, null would be better: List<VDS> result = dao.getAllOfType(null);

Target:
public void testGetAllOfTypeWithUnrepresentedType() { List<VDS> result = dao.getAllOfType(null); assertIncorrectGetResult(result); }
Source:
public AuditLogType getAuditLogTypeValue() { START if (EXECUTE.equals(getActionState()) && END getSucceeded()){ return outOfSyncHostsExist() ? CLUSTER_SYNC_ALL_NETWORKS_STARTED : CLUSTER_SYNC_NOTHING_TO_DO; } else if (EXECUTE.equals(getActionState()) && !getSucceeded()) { return CLUSTER_SYNC_ALL_NETWORKS_START_ERROR; } else if (END_SUCCESS.equals(getActionState())) { return CLUSTER_SYNC_ALL_NETWORKS_FINISHED; } return CLUSTER_SYNC_ALL_NETWORKS_FAILED; } I think now it is more easy to read if we would use the common code structure like: switch (getActionState()) { case EXECUTE: return getSucceeded() ? ...

Target:
public AuditLogType getAuditLogTypeValue() { switch (getActionState()) { case EXECUTE: if (!getSucceeded()){ return CLUSTER_SYNC_ALL_NETWORKS_START_ERROR; } else if (!outOfSyncHostsExist()){ return CLUSTER_SYNC_NOTHING_TO_DO; } else { return CLUSTER_SYNC_ALL_NETWORKS_STARTED; } case END_SUCCESS: return CLUSTER_SYNC_ALL_NETWORKS_FINISHED; } return CLUSTER_SYNC_ALL_NETWORKS_FAILED; }
Source:
private void setParentOverflow(Element e, Style.Overflow visible) { if (e != null && START e != asWidget().getElement()) { END e.getParentElement().getStyle().setOverflow(visible); setParentOverflow(e.getParentElement(), visible); } } Is it safe to do such a reference comparison instead of i.e., "equals" or using their IDs?

Target:
private void setParentOverflow(Element e, Style.Overflow visible) { if (e != null && !e.equals(asWidget().getElement())) { e.getParentElement().getStyle().setOverflow(visible); setParentOverflow(e.getParentElement(), visible); } }
Source:
private boolean architecturesMatch() { return START getCluster().getArchitecture() != ArchitectureType.undefined && getCluster().getArchitecture() == getMaxServerCpu().getArchitecture(); END } Previously, this condition was: getCluster().getArchitecture() == ArchitectureType.undefined || getCluster().getArchitecture() == getMaxServerCpu().getArchitecture()

Target:
private boolean architecturesMatch() { return getCluster().getArchitecture() == ArchitectureType.undefined || getCluster().getArchitecture() == getMaxServerCpu().getArchitecture(); }
Source:
public START synchronized Map<Guid, END AsyncTaskStatus> pollTasks(Set<Guid> taskIds) { if (taskIds == null) { return Collections.emptyMap(); } return taskIds.stream().collect(Collectors.toMap(Function.identity(), this::getTaskStatus)); } is this needed?

Target:
public Map<Guid, AsyncTaskStatus> pollTasks(Set<Guid> taskIds) { if (taskIds == null) { return Collections.emptyMap(); } return taskIds.stream().collect(Collectors.toMap(Function.identity(), this::getTaskStatus)); }
Source:
public VmTemplate getVmTemplate() { if (vmTemplateFromConfiguration == null) { START initUnregisteredTemplate(); END } return vmTemplateFromConfiguration; } This is called in the init method. Why is it needed again here?

Target:
public VmTemplate getVmTemplate() { return vmTemplateFromConfiguration; }
Source:
START public boolean END isUnregisteredTemplate() { Template unregisteredTemplate; try { unregisteredTemplate = performGet(QueryType.GetUnregisteredVmTemplate, new GetUnregisteredEntityQueryParameters(parent.storageDomainId, guid)); } catch (WebApplicationException e) { if (e.getResponse().getStatus() == Response.Status.NOT_FOUND.getStatusCode()) { return false; } throw e; } return unregisteredTemplate != null; } probably private

Target:
private boolean isUnregisteredTemplate() { Template unregisteredTemplate; try { unregisteredTemplate = performGet(QueryType.GetUnregisteredVmTemplate, new GetUnregisteredEntityQueryParameters(parent.storageDomainId, guid)); } catch (WebApplicationException e) { if (e.getResponse().getStatus() == Response.Status.NOT_FOUND.getStatusCode()) { return false; } throw e; } return unregisteredTemplate != null; }