auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private String getNextRunMessage(String field) { if (field.equals("minAllocatedMem")) { //$NON-NLS-1$ String translated = nextRunMessages.minAllocatedMem(); try { translated = nextRunMessages.getString("minAllocatedMem"); //$NON-NLS-1$ START } catch (MissingResourceException e) { END // ignore } return translated; } return field; } and if the MissingResourceException is not enough here, you can do catch (Exception) { // ignore } But I think the MissingResourceException is ok

Target:
private String getNextRunMessage(String field) { try { return nextRunMessages.getString(field); } catch (MissingResourceException e) { // ignore } return field; }
Source:
public EntityModelWidgetWithInfo(EnableableFormLabel label, Widget contentWidget, Align alignment) { this.label = label; START if (this.label == null) { END this.label = new EnableableFormLabel(); this.label.setVisible(false); } this.contentWidget = contentWidget; this.alignment = alignment; infoIcon = new InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML); initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); } I'd suggest to use an explicit if/else like: if (label != null) { this.label = label; } else { this.label = new EnableableFormLabel(); this.label.setVisible(false); }

Target:
public EntityModelWidgetWithInfo(EnableableFormLabel label, Widget contentWidget, Align alignment) { if (this.label != null) { this.label = label; } else { this.label = new EnableableFormLabel(); this.label.setVisible(false); } this.contentWidget = contentWidget; this.alignment = alignment; infoIcon = new InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML); initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); }
Source:
public int setTabIndexes(int nextTabIndex) { START nextTabIndex++; END nameEditor.setTabIndex(nextTabIndex++); cidrEditor.setTabIndex(nextTabIndex++); ipVersionEditor.setTabIndex(nextTabIndex++); gatewayEditor.setTabIndex(nextTabIndex++); return dnsServersEditor.setTabIndexes(nextTabIndex); } still needed? should be redundant after I91dbedee38d893302f1006c9ce1e58d146ce7cce

Target:
public int setTabIndexes(int nextTabIndex) { nameEditor.setTabIndex(nextTabIndex++); cidrEditor.setTabIndex(nextTabIndex++); ipVersionEditor.setTabIndex(nextTabIndex++); gatewayEditor.setTabIndex(nextTabIndex++); return dnsServersEditor.setTabIndexes(nextTabIndex); }
Source:
private int calculateValue(NetworkCluster networkCluster) { int res = 0; if (networkCluster != null) { if (networkCluster.isDefaultRoute()) { res += 16; } if (networkCluster.isManagement()) { START res += 8; END } if (networkCluster.isDisplay()) { res += 4; } if (networkCluster.isMigration()) { res += 2; } if (networkCluster.isGluster()) { res += 1; } } return res; } Please keep the management network with the highest number. So it will be displayed first.

Target:
private int calculateValue(NetworkCluster networkCluster) { int res = 0; if (networkCluster != null) { if (networkCluster.isManagement()) { res += 16; } if (networkCluster.isDefaultRoute()) { res += 8; } if (networkCluster.isDisplay()) { res += 4; } if (networkCluster.isMigration()) { res += 2; } if (networkCluster.isGluster()) { res += 1; } } return res; }
Source:
boolean isMonitoringNeeded(VDSStatus status) { switch (status) { case Up: case NonResponsive: case Error: case NonOperational: case PreparingForMaintenance: START case Initializing: END case Connecting: return true; default: return false; } } I agree, but I'm ok with leaving it that way - the patch still makes stuff better than it was without it. but: 1. if we keep it that way, it worth to note that in a comment 2. I think the formatter will remove the spaces before the 'case' keyword (so they will be right below the 'switch'), can you please check that?

Target:
boolean isMonitoringNeeded(VDSStatus status) { switch (status) { default: return false; case Up: case Error: case NonOperational: case PreparingForMaintenance: // FIXME The below statuses are probably not relevant // for monitoring but it's currently not final. case NonResponsive: case Initializing: case Connecting: return true; } }
Source:
public boolean isImageNetworkDisk(DiskImage diskImage, Version clusterVersion, Guid clusterId) { StorageType storageType = diskImage.getStorageTypes().get(0); if (storageType == StorageType.GLUSTERFS) { START if (FeatureSupported.libgfApiSupported(clusterVersion)) { return true; } return isFeatureSupportedAsAdditionalFeature(clusterId, ConfigValues.LibgfApiSupported.name()); END } return false; } That could be reduced to a single boolean expression, which is more more clear to understand: return FeatureSupported.libgfApiSupported(clusterVersion) || isFeatureSupportedAsAdditionalFeature(clusterId, ConfigValues.LibgfApiSupported.name());

Target:
public boolean isImageNetworkDisk(DiskImage diskImage, Version clusterVersion, Guid clusterId) { StorageType storageType = diskImage.getStorageTypes().get(0); if (storageType == StorageType.GLUSTERFS) { return FeatureSupported.libgfApiSupported(clusterVersion) || isFeatureSupportedAsAdditionalFeature(clusterId, ConfigValues.LibgfApiSupported.name()); } return false; }
Source:
private void onOk() { FenceProxyModel windowModel = (FenceProxyModel) getWindow(); START setWindow(null); END ListModel<FenceProxyModel> currentModels = windowModel.getCurrentProxies(); FenceProxyModel selectedModel = windowModel.getAvailableProxies().getSelectedItem(); setEntity(selectedModel.getEntity()); Collection<FenceProxyModel> items = currentModels.getItems(); currentModels.setItems(null); currentModels.setItems(items); } Hmm, OK, I can try this locally to see what's going on. In general, after you call setWindow(null) to hide the dialog (bound to model's `Window` property), you should not use the dialog's model (e.g. FenceProxyModel) anymore, since it's cleaned up. (When a model gets cleaned up, all handlers/listeners are removed and references to shared objects nullified as needed.)

Target:
private void onOk() { FenceProxyModel windowModel = (FenceProxyModel) getWindow(); ListModel<FenceProxyModel> currentModels = windowModel.getCurrentProxies(); FenceProxyModel selectedModel = windowModel.getAvailableProxies().getSelectedItem(); setEntity(selectedModel.getEntity()); Collection<FenceProxyModel> items = currentModels.getItems(); currentModels.setItems(null); currentModels.setItems(items); setWindow(null); }
Source:
public void passthroughProfileDoesNotContainFilterIdButDefaultWillBeUsed() { START passthroughProfileContainsSupportedPropertiesTest(true, false, DEFAULT_GUID, INVALID_NETWORK_FILTER_ID); END assertThat(validator.passthroughProfileContainsSupportedProperties(true), failsWith(EngineMessage.ACTION_TYPE_FAILED_PASSTHROUGH_PROFILE_CONTAINS_NOT_SUPPORTED_PROPERTIES)); } Instead of 'INVALID_NETWORK_FILTER_ID' you should pass null.

Target:
public void passthroughProfileDoesNotContainFilterIdButDefaultWillBeUsed() { passthroughProfileContainsSupportedPropertiesTest(true, false, DEFAULT_GUID, null); assertThat(validator.passthroughProfileContainsSupportedProperties(true), failsWith(EngineMessage.ACTION_TYPE_FAILED_PASSTHROUGH_PROFILE_CONTAINS_NOT_SUPPORTED_PROPERTIES)); }
Source:
public void testExecuteQueryWithNotExistingIscsiBond() { IscsiBond iscsiBond = new IscsiBond(); START iscsiBond.setId(Guid.newGuid()); END when(getQueryParameters().getId()).thenReturn(iscsiBondId); getQuery().executeQueryCommand(); IscsiBond result = getQuery().getQueryReturnValue().getReturnValue(); assertNull(result); } I think we can also remove this now after you removed line 87

Target:
public void testExecuteQueryWithNotExistingIscsiBond() { when(getQueryParameters().getId()).thenReturn(iscsiBondId); getQuery().executeQueryCommand(); IscsiBond result = getQuery().getQueryReturnValue().getReturnValue(); assertNull(result); }
Source:
START public void setIpv6BootProtocol(Ipv6BootProtocol ipv6BootProtocol) { END this.ipv6BootProtocol = ipv6BootProtocol; } Ipv4 has the following code - "bootProtocol == null) ? Ipv4BootProtocol.NONE : bootProtocol;" Why didn't you adopted the same code here?

Target:
public void setIpv6BootProtocol(Ipv6BootProtocol ipv6BootProtocol) { this.ipv6BootProtocol = (ipv6BootProtocol == null) ? Ipv6BootProtocol.NONE : ipv6BootProtocol; }
Source:
private boolean isUpdateRequired(VM.VMStatus status){ //TODO: fill this list on going. // list of statuses which required vdsm update {up, poweringdown, paused} START if (status == VM.VMStatus.Up || status == VM.VMStatus.PoweringDown || status == VM.VMStatus.Paused) { END return true; } return false; } why not switch/case?

Target:
private boolean isUpdateRequired(VM.VMStatus status) { // TODO: fill this list on going. // list of statuses which required vdsm update {up, poweringdown, paused} switch (status) { case Up: case PoweringDown: case Paused: return true; default: return false; } }
Source:
protected Pair<Boolean, StorageDomain> syncDomainLuns(StorageDomain storageDomain) { return new Pair<>( StorageHelperDirector.getInstance() .getItem(storageDomain.getStorageType()).syncDomainInfo(storageDomain, null), START storageDomain); END } perhaps have the pair as Pair<Boolean, Guid>, we don't need the entire domain object.

Target:
protected Pair<Boolean, Guid> syncDomainLuns(StorageDomain storageDomain) { return new Pair<>( StorageHelperDirector.getInstance() .getItem(storageDomain.getStorageType()).syncDomainInfo(storageDomain, null), storageDomain.getId()); }
Source:
public String getAttributeValue(String name) { for (int i = 0; i < reader.getAttributeCount(); i++) { String attrName = reader.getAttributeLocalName(i); if (attrName.equals(name)) { return reader.getAttributeValue(i); } } START return null; END } I think that the underlying XMLStream reader has a 'getAttributeValue' method. It receives the namespace and the name of the attribute. If you pass 'null' and the name of the attribute it will return the value of the attribute, which is what we need: https://docs.oracle.com/javase/8/docs/api/javax/xml/stream/XMLStreamReader.html#getAttributeValue-java.lang.String-java.lang.String-

Target:
public String getAttributeValue(String name) { return reader.getAttributeValue(null, name); }
Source:
protected boolean perform() { try { getParameters().setStartTime(new Date()); destinationHostLock = new EngineLock(hostLocking.getSetupNetworksLock(getDestinationVdsId())); START lockManager.acquireLockWait(destinationHostLock); END if (unplugPassthroughNics() && connectLunDisks(getDestinationVdsId()) && migrateVm()) { ExecutionHandler.setAsyncJob(getExecutionContext(), true); return true; } // otherwise runningFailed(); return false; } catch (Exception e) { runningFailed(); throw e; } } If I understand correctly, the purpose of the patch is to fix a specific problem - failure of migration because of 'refreshCaps' failure to take a lock. It is enough to take a waiting lock inside the ActivateDeactivateVmIntefaceCommand before calling the refresh, instead of locking the host for the whole migration period. You can pass 'lockProperties.withScope(Scope.Execution).withWait(true)' as the 'lockProperties' of the parameters you pass to 'RefreshHost' (the 'RefreshHost' should pass it the 'RefreshCaps').

Target:
protected boolean perform() { try { getParameters().setStartTime(new Date()); if (unplugPassthroughNics() && connectLunDisks(getDestinationVdsId()) && migrateVm()) { ExecutionHandler.setAsyncJob(getExecutionContext(), true); return true; } // otherwise runningFailed(); return false; } catch (Exception e) { runningFailed(); throw e; } }
Source:
public void setReturnValueFailure(VDSReturnValue returnValueFailure) { START setSucceeded(false); END final EngineFault engineFault = new EngineFault(); engineFault.setError(returnValueFailure.getVdsError().getCode()); engineFault.setMessage(returnValueFailure.getVdsError().getMessage()); getReturnValue().setFault(engineFault); } this is redundant - it is false unless explicitly set to true

Target:
public void setReturnValueFailure(VDSReturnValue returnValueFailure) { final EngineFault engineFault = new EngineFault(); engineFault.setError(returnValueFailure.getVdsError().getCode()); engineFault.setMessage(returnValueFailure.getVdsError().getMessage()); getReturnValue().setFault(engineFault); }
Source:
private void setDcCompatibilityLevelUpgradeNeeded(List<StoragePool> dataCenters) { Config.<Set<Version>> getValue(ConfigValues.SupportedClusterLevels) .stream() .max(Comparator.naturalOrder()) START .ifPresent( maxSupportedClusterLevel -> dataCenters.forEach( dataCenter -> dataCenter.setStoragePoolCompatibilityLevelUpgradeNeeded( END maxSupportedClusterLevel.compareTo(dataCenter.getCompatibilityVersion()) > 0))); } still lambda in lambda. From my point of view ~ not readable.

Target:
private void setDcCompatibilityLevelUpgradeNeeded(List<StoragePool> dataCenters) { Config.<Set<Version>> getValue(ConfigValues.SupportedClusterLevels) .stream() .max(Comparator.naturalOrder()) .ifPresent(maxSupportedClusterLevel -> setDcCompatibilityLevelUpgradeNeeded(dataCenters, maxSupportedClusterLevel)); }
Source:
protected boolean amendDiskRequested() { if (getOldDisk().getDiskStorageType() == DiskStorageType.IMAGE) { DiskImage oldDisk = (DiskImage) getOldDisk(); return START (oldDisk.getVolumeFormat() END == VolumeFormat.COW) && !Objects.equals(oldDisk.getQcowCompat().getCompatValue(), ((DiskImage) getNewDisk()).getQcowCompat().getCompatValue()); } return false; } unneeded brackets

Target:
protected boolean amendDiskRequested() { if (getOldDisk().getDiskStorageType() == DiskStorageType.IMAGE) { DiskImage oldDisk = (DiskImage) getOldDisk(); return oldDisk.getVolumeFormat() == VolumeFormat.COW && !Objects.equals(oldDisk.getQcowCompat().getCompatValue(), ((DiskImage) getNewDisk()).getQcowCompat().getCompatValue()); } return false; }
Source:
public void setUp() { Map<String, String> headers = new HashMap<>(); START headers.put("my", "value"); END setXmlResponse("clusters", 200, "<clusters/>"); setXmlResponse("clusters/123", 200, "<cluster id=\"123\"><name>test</name></cluster>"); startServer(); connection = (HttpConnection) testConnectionBuilder().header("my", "value").build(); clustersService = connection.systemService().clustersService(); clusterService = clustersService.clusterService("123"); } These ^ lines aren't needed.

Target:
public void setUp() { setXmlResponse("clusters", 200, "<clusters/>"); setXmlResponse("clusters/123", 200, "<cluster id=\"123\"><name>test</name></cluster>"); startServer(); connection = (HttpConnection) testConnectionBuilder().header("my", "value").build(); clustersService = connection.systemService().clustersService(); clusterService = clustersService.clusterService("123"); }
Source:
private void validateDiscardAfterDelete() { if (getDiscardAfterDelete().getIsAvailable() && getDiscardAfterDelete().getEntity()) { SanStorageModelBase sanStorageModel = (SanStorageModelBase) getCurrentStorageItem(); Collection<LunModel> luns = sanStorageModel.getAddedLuns(); if (luns != null && !storageDomainSupportsDiscard(luns)) { getDiscardAfterDelete().setIsValid(false); START getDiscardAfterDelete().getInvalidityReasons().add( END constants.discardIsNotSupportedByUnderlyingStorage()); return; } } getDiscardAfterDelete().setIsValid(true); } Try moving it to the previous line. I think it should solve the tool-tip issue.

Target:
private void validateDiscardAfterDelete() { if (getDiscardAfterDelete().getIsAvailable() && getDiscardAfterDelete().getEntity()) { SanStorageModelBase sanStorageModel = (SanStorageModelBase) getCurrentStorageItem(); Collection<LunModel> luns = sanStorageModel.getAddedLuns(); if (luns != null && !storageDomainSupportsDiscard(luns)) { getDiscardAfterDelete().getInvalidityReasons().add( constants.discardIsNotSupportedByUnderlyingStorage()); getDiscardAfterDelete().setIsValid(false); return; } } getDiscardAfterDelete().setIsValid(true); }
Source:
public SyncLunsParameters(Guid storagePoolId) { START super(storagePoolId); END } This is a code smell. You should have only one path to the super. Instead, call this(storagePoolId, null)

Target:
public SyncLunsParameters(Guid storagePoolId) { this(storagePoolId, null); }
Source:
public static int getCdDeviceIndex(String cdInterface) { switch (cdInterface) { case "scsi": START return 2; END case "ide": return 2; case "sata": return 2; default: return -1; } } Since it is 2, 2, 2, it could be rewritten to: case "scsi": case "ide": case "sata": return 2; default: return -1;

Target:
public static int getCdDeviceIndex(String cdInterface) { switch (cdInterface) { case "scsi": case "ide": case "sata": return 2; default: return -1; } }
Source:
private void updateVmAfterMigrationToDifferentCluster() { if (getParameters().getTargetClusterId() != null START || getVm().getClusterId().equals(getParameters().getTargetClusterId())) { END return; } ChangeVMClusterParameters params = new ChangeVMClusterParameters( getParameters().getTargetClusterId(), getVmId(), getVm().getCustomCompatibilityVersion()); setSucceeded(getBackend().runInternalAction(VdcActionType.ChangeVMCluster, params).getSucceeded()); } Shouldn't it be '== null'?

Target:
private void updateVmAfterMigrationToDifferentCluster() { if (getParameters().getTargetClusterId() == null || getVm().getClusterId().equals(getParameters().getTargetClusterId())) { return; } ChangeVMClusterParameters params = new ChangeVMClusterParameters( getParameters().getTargetClusterId(), getVmId(), getVm().getCustomCompatibilityVersion()); setSucceeded(getBackend().runInternalAction(VdcActionType.ChangeVMCluster, params).getSucceeded()); }
Source:
START public String getUuid() { END return UUID.randomUUID().toString(); } this method is useless. Can you send a patch to remove it so all the code that needs uuid will simply use UUID class?

Target:
public static String getUuid() { return UUID.randomUUID().toString(); }
Source:
private List<SubchainInfo> mockSnapshotList(List<DiskImage> snapshots, Version version) { mockCluster(version); configRule.mockConfigValue(ConfigValues.QemuimgCommitSupported, version); List<DiskImage> childSnapshots = createChildSnapshots(snapshots); when(diskImageDao.getAllSnapshotsForParents( START snapshots .stream() .map(DiskImage::getImageId) .collect(Collectors.toList()) END ) ).thenReturn(childSnapshots); return cmd.getAllDisksSnapshot(snapshots); } This replicates the logic from the production code. Can't we just create the DiskImages and the SubchainInfo in symetrically?

Target:
private List<SubchainInfo> mockSnapshotList(List<DiskImage> snapshots, Version version) { mockCluster(version); configRule.mockConfigValue(ConfigValues.QemuimgCommitSupported, version); List<DiskImage> childSnapshots = createChildSnapshots(snapshots); when(diskImageDao.getAllSnapshotsForParents( snapshots .stream() .map(DiskImage::getImageId) .collect(Collectors.toList()) ) ).thenReturn(new HashSet<>(childSnapshots)); return cmd.getAllDisksSnapshot(snapshots); }
Source:
public void removeLeftoverDevices(VmBase vmBase) { List<VmDevice> spiceChannels = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice( vmBase.getId(), VmDeviceGeneralType.CHANNEL, VmDeviceType.SPICEVMC.getName()); // remove spice channel if we are no longer using spice if (!hasGraphicsDevice(vmBase.getId(), GraphicsType.SPICE)) { removeVmDevices(spiceChannels); } START } END Please note that this doesn't handle templates, only VMs (while the original bug was opened to handle templates) - maybe it worth adding a remark in BZ saying that we won't remove spicevmc channels for templates..

Target:
public void removeLeftoverDevices(VmBase vmBase) { if (!hasGraphicsDevice(vmBase.getId(), GraphicsType.SPICE)) { // remove spice channel if we are no longer using spice List<VmDevice> spiceChannels = vmDeviceDao.getVmDeviceByVmIdTypeAndDevice( vmBase.getId(), VmDeviceGeneralType.CHANNEL, VmDeviceType.SPICEVMC.getName()); removeVmDevices(spiceChannels); } }
Source:
private void enableLoadBalancer() { if (Config.<Boolean>getValue(ConfigValues.EnableVdsLoadBalancing)) { log.info("Start scheduling to enable vds load balancer"); START executor.scheduleWithFixedDelay(() -> performLoadBalancing(), END Config.<Integer>getValue(ConfigValues.VdsLoadBalancingIntervalInMinutes), Config.<Integer>getValue(ConfigValues.VdsLoadBalancingIntervalInMinutes), TimeUnit.MINUTES); log.info("Finished scheduling to enable vds load balancer"); } } this::performLoadBalancing?

Target:
private void enableLoadBalancer() { if (Config.<Boolean>getValue(ConfigValues.EnableVdsLoadBalancing)) { log.info("Start scheduling to enable vds load balancer"); executor.scheduleWithFixedDelay(this::performLoadBalancing, Config.<Integer>getValue(ConfigValues.VdsLoadBalancingIntervalInMinutes), Config.<Integer>getValue(ConfigValues.VdsLoadBalancingIntervalInMinutes), TimeUnit.MINUTES); log.info("Finished scheduling to enable vds load balancer"); } }
Source:
private void enableHaReservationCheck() { if (Config.<Boolean>getValue(ConfigValues.EnableVdsLoadBalancing)) { log.info("Start HA Reservation check"); Integer interval = Config.<Integer> getValue(ConfigValues.VdsHaReservationIntervalInMinutes); START executor.scheduleWithFixedDelay(() -> performHaResevationCheck(), END interval, interval, TimeUnit.MINUTES); log.info("Finished HA Reservation check"); } } the same, why not use method reference?

Target:
private void enableHaReservationCheck() { if (Config.<Boolean>getValue(ConfigValues.EnableVdsLoadBalancing)) { log.info("Start HA Reservation check"); Integer interval = Config.<Integer> getValue(ConfigValues.VdsHaReservationIntervalInMinutes); executor.scheduleWithFixedDelay(this::performHaResevationCheck, interval, interval, TimeUnit.MINUTES); log.info("Finished HA Reservation check"); } }
Source:
START public void END backupCheck() { // skip backup check if previous operation is not completed yet if (lock.tryLock()) { try { log.info("Backup check started."); doBackupCheck(); log.info("Backup check completed."); } finally { lock.unlock(); } } } private?

Target:
private void backupCheck() { // skip backup check if previous operation is not completed yet if (lock.tryLock()) { try { log.info("Backup check started."); doBackupCheck(); log.info("Backup check completed."); } finally { lock.unlock(); } } }
Source:
START public void END availableUpdates() { hostDao.getAll() .stream() .filter(h -> h.getStatus().isEligibleForCheckUpdates()) .forEach(this::submitCheckUpdatesForHost); } private?

Target:
private void availableUpdates() { hostDao.getAll() .stream() .filter(h -> h.getStatus().isEligibleForCheckUpdates()) .forEach(this::submitCheckUpdatesForHost); }
Source:
START public void END cleanCompletedJob() { Date succeededJobsDeleteTime = new Date(System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(succeededJobTime, TimeUnit.MINUTES)); Date failedJobsDeleteTime = new Date(System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(failedJobTime, TimeUnit.MINUTES)); try { jobDao.deleteCompletedJobs(succeededJobsDeleteTime, failedJobsDeleteTime); } catch (RuntimeException e) { log.error("Failed to delete completed jobs: {}", e.getMessage()); log.debug("Exception", e); } } private?

Target:
private void cleanCompletedJob() { Date succeededJobsDeleteTime = new Date(System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(succeededJobTime, TimeUnit.MINUTES)); Date failedJobsDeleteTime = new Date(System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(failedJobTime, TimeUnit.MINUTES)); try { jobDao.deleteCompletedJobs(succeededJobsDeleteTime, failedJobsDeleteTime); } catch (RuntimeException e) { log.error("Failed to delete completed jobs: {}", e.getMessage()); log.debug("Exception", e); } }
Source:
void stubGetUserBySessionIdQuery() { START VdcQueryReturnValue returnValue = new VdcQueryReturnValue(); returnValue.setSucceeded(true); returnValue.setReturnValue(mockUser); END when(mockBackend.runQuery( eq(VdcQueryType.GetUserBySessionId), isA(VdcQueryParametersBase.class) )).thenReturn(returnValue); } This is probably a good idea regardless of making the VdcQueryReturnValue final. I wonder if it's worth having this small cleanup in a separate patch.

Target:
void stubGetUserBySessionIdQuery() { when(mockBackend.runQuery( eq(VdcQueryType.GetUserBySessionId), isA(VdcQueryParametersBase.class) )).thenReturn(new VdcQueryReturnValue() { { setSucceeded(true); setReturnValue(mockUser); } }); }
Source:
} catch (NoSuchAlgorithmException e) { START new RuntimeException("Unable to generate KeyPair", e); END } Is it possible to throw RuntimeException from static block?

Target:
} catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); }
Source:
START protected void END addLink(LinksTreeNode linksTree, String link) { //link segments are separated by '.' (e.g: (disk_attachements.template) String[] linkSegments = link.split("\\."); for (String segment : linkSegments) { linksTree = updateTree(linksTree, segment); } } Why protected? Do we have any subclass? Try to make everything 'private' unless something else is required. We can always make things more accessible in the future. The other way around is harder.

Target:
private void addLink(LinksTreeNode linksTree, String link) { //link segments are separated by '.' (e.g: (disk_attachements.template) String[] linkSegments = link.split("\\."); for (String segment : linkSegments) { linksTree = updateTree(linksTree, segment); } }
Source:
START private static END String getMessageOrNull(AuditLogType logType) { final String key = logType.name(); try { return resourceBundle.getString(key); } catch (Exception e) { log.error("Key '{}' is not translated in '{}'", key, getResourceBundleName()); return null; } } related?

Target:
protected static String getMessageOrNull(AuditLogType logType) { final String key = logType.name(); try { return resourceBundle.getString(key); } catch (Exception e) { log.error("Key '{}' is not translated in '{}'", key, getResourceBundleName()); return null; } }
Source:
public EngineScheduleExpression(String cronExpression) { super(); String[] cron = cronExpression.split("\\s *"); START second(cron[0]).minute(cron[1]).hour(cron[2]).dayOfMonth(cron[3]).month(cron[4]).dayOfWeek(cron[5]); END if (cron.length >= 7) { year(cron[6]); } } One method invocation per line would be more readable

Target:
public EngineScheduleExpression(String cronExpression) { String[] cron = cronExpression.split("\\s *"); second(cron[0]).minute(cron[1]).hour(cron[2]).dayOfMonth(cron[3]).month(cron[4]).dayOfWeek(cron[5]); if (cron.length >= 7) { year(cron[6]); } }
Source:
private void cleanup() { try { START log.info("Start cleanup"); END DateTime latestTimeToKeep = DateTime.getNow().addDays( Config.<Integer>getValue(ConfigValues.CommandEntityAgingThreshold) * -1); commandCoordinatorUtil.removeAllCommandsBeforeDate(latestTimeToKeep); log.info("Finished cleanup"); } catch (Throwable t) { log.error("Exception in performing command entity cleanup: {}", ExceptionUtils.getRootCauseMessage(t)); log.debug("Exception", t); } } We should move that to debug in different patch (or remove at all), I see no value for that in INFO level

Target:
private void cleanup() { try { log.debug("Start cleanup"); DateTime latestTimeToKeep = DateTime.getNow().addDays( Config.<Integer>getValue(ConfigValues.CommandEntityAgingThreshold) * -1); commandCoordinatorUtil.removeAllCommandsBeforeDate(latestTimeToKeep); log.debug("Finished cleanup"); } catch (Throwable t) { log.error("Exception in performing command entity cleanup: {}", ExceptionUtils.getRootCauseMessage(t)); log.debug("Exception", t); } }
Source:
protected void executeCommand() { VdcActionType actionToExecute = getParameters().getAction(); VdcActionParametersBase actionParameters = getParameters().getActionParameters(); START actionParameters.setEndProcedure(VdcActionParametersBase.EndProcedure.COMMAND_MANAGED); END actionParameters.setParentCommand(VdcActionType.RunAsyncAction); actionParameters.setParentParameters(getParameters()); CommandCoordinatorUtil.executeAsyncCommand( actionToExecute, actionParameters, cloneContextAndDetachFromParent()); setSucceeded(true); } Can't we avoid setting the parent command/parent parameters? it may be preferred to just delete lines 34-35.

Target:
protected void executeCommand() { CommandCoordinatorUtil.executeAsyncCommand( getParameters().getAction(), getParameters().getActionParameters(), cloneContextAndDetachFromParent()); setSucceeded(true); }
Source:
private void updateActionAvailability() { START getNewCommand().setIsExecutionAllowed(true); END boolean hasSelectedItems = getSelectedItems() != null && getSelectedItems().size() > 0; getEditCommand().setIsExecutionAllowed(hasSelectedItems && getSelectedItems().size() == 1); getRemoveCommand().setIsExecutionAllowed(hasSelectedItems); } If the `new` command is always allowed, do we need this line?

Target:
private void updateActionAvailability() { boolean hasSelectedItems = getSelectedItems() != null && getSelectedItems().size() > 0; getEditCommand().setIsExecutionAllowed(hasSelectedItems && getSelectedItems().size() == 1); getRemoveCommand().setIsExecutionAllowed(hasSelectedItems); }
Source:
private void cancel() { START setConfirmWindow(null); END } I've seen other list models doing setWindow(null) as well. Not sure if we need to do it here too, though.

Target:
private void cancel() { // no implementation }
Source:
protected void addCommands() { UICommand START command = END UICommand.createDefaultOkUiCommand("OnSave", this); //$NON-NLS-1$ getCommands().add(command); getCommands().add(UICommand.createCancelUiCommand("Cancel", this)); //$NON-NLS-1$ } Maybe inline this local variable?

Target:
protected void addCommands() { getCommands().add(UICommand.createDefaultOkUiCommand("OnSave", this)); //$NON-NLS-1$ getCommands().add(UICommand.createCancelUiCommand("Cancel", this)); //$NON-NLS-1$ }
Source:
START public boolean END isDiskExists(Guid id) { return baseDiskDao.exists(id); } This should be private

Target:
private boolean isDiskExists(Guid id) { return baseDiskDao.exists(id); }
Source:
public void logServerMessage(final VDS server, final AuditLogType logType) { START logAuditMessage(server == null ? END Guid.Empty : server.getClusterId(), server == null ? null : server.getClusterName(), null, server, logType, Collections.emptyMap()); } Done

Target:
public void logServerMessage(final VDS server, final AuditLogType logType) { logAuditMessage(server.getClusterId(), server.getClusterName(), null, server, logType, Collections.emptyMap()); }
Source:
protected boolean validateInputManagementNetwork() { if (!findInputManagementNetwork()) return false; final NetworkClusterValidatorBase networkClusterValidator = createNetworkClusterValidator(); START return validate(networkClusterValidator.networkBelongsToClusterDataCenter(getCluster(), managementNetwork)) END && validate(networkClusterValidator.managementNetworkRequired(managementNetwork)) && validate(networkClusterValidator.managementNetworkNotExternal(managementNetwork)); } Doesn't it make sense to have those validation in the update use case as well?

Target:
protected boolean validateInputManagementNetwork() { if (!findInputManagementNetwork()) { return false; } final NetworkClusterValidatorBase networkClusterValidator = createNetworkClusterValidator(); return validate(networkClusterValidator.networkBelongsToClusterDataCenter(getCluster(), managementNetwork)) && validate(networkClusterValidator.managementNetworkRequired(managementNetwork)) && validate(networkClusterValidator.managementNetworkNotExternal(managementNetwork)); }
Source:
protected void log() { START final Transaction transaction = TransactionSupport.suspend(); END try { try { auditLogDirector.log(this, getAuditLogTypeValue()); } catch (final RuntimeException ex) { log.error("Error during log command: {}. Exception {}", getClass().getName(), ex.getMessage()); log.debug("Exception", ex); } } finally { TransactionSupport.resume(transaction); } } Wouldn't it be more readable to use TransactionSupport.executeInNewTransaction() instead of the code here which does the same?

Target:
protected void log() { final Transaction transaction = TransactionSupport.suspend(); try { auditLogDirector.log(this, getAuditLogTypeValue()); } catch (final RuntimeException ex) { log.error("Error during log command: {}. Exception {}", getClass().getName(), ex.getMessage()); log.debug("Exception", ex); } finally { TransactionSupport.resume(transaction); } }
Source:
public void storageAndPoolExists() { StorageDomain sd = new StorageDomain(); Guid storagePoolId = Guid.newGuid(); sd.setStoragePoolId(storagePoolId); START when(storageDomainDao.getAllForStorageDomain(any(Guid.class))).thenReturn(Collections.singletonList(sd)); END when(storagePoolDao.get(storagePoolId)).thenReturn(new StoragePool()); assertTrue(cmd.validate()); } This is redundant in Mockito 2

Target:
public void storageAndPoolExists() { StorageDomain sd = new StorageDomain(); Guid storagePoolId = Guid.newGuid(); sd.setStoragePoolId(storagePoolId); when(storageDomainDao.getAllForStorageDomain(any())).thenReturn(Collections.singletonList(sd)); when(storagePoolDao.get(storagePoolId)).thenReturn(new StoragePool()); assertTrue(cmd.validate()); }
Source:
public void invalidStoragePool() { StorageDomain sd = new StorageDomain(); Guid storagePoolId = Guid.newGuid(); sd.setStoragePoolId(storagePoolId); START when(storageDomainDao.getAllForStorageDomain(any(Guid.class))).thenReturn(Collections.singletonList(sd)); END when(storagePoolDao.get(storagePoolId)).thenReturn(null); assertFalse(cmd.validate()); } This is redundant in Mockito 2

Target:
public void invalidStoragePool() { StorageDomain sd = new StorageDomain(); Guid storagePoolId = Guid.newGuid(); sd.setStoragePoolId(storagePoolId); when(storageDomainDao.getAllForStorageDomain(any())).thenReturn(Collections.singletonList(sd)); assertFalse(cmd.validate()); }
Source:
START public Boolean getUseForBackup() { END return useForBackup; } isUsedForBackup? And also why are you returning Boolean object when attribute is defined primitive boolean type?

Target:
public boolean getUseForBackup() { return useForBackup; }
Source:
public int setTabIndexes(int nextTabIndex) { START nextTabIndex = super.setTabIndexes(nextTabIndex); END nextTabIndex = createSubnetEditor.setTabIndexes(nextTabIndex); nextTabIndex = this.subnetWidget.setTabIndexes(nextTabIndex); return nextTabIndex; } Nit-pick: no need to call super [1] since that's effectively a no-op call, you can simply skip the line above. [1] AbstractModelBoundPopupView#setTabIndexes (If this View extended some other View that would override setTabIndexes method, super should be called in any case.)

Target:
public int setTabIndexes(int nextTabIndex) { nextTabIndex = createSubnetEditor.setTabIndexes(nextTabIndex); nextTabIndex = this.subnetWidget.setTabIndexes(nextTabIndex); return nextTabIndex; }
Source:
public void testValidationFailsDiskConnectedToRunningVm() { VM vm = new VM(); vm.setStatus(VMStatus.Up); VmDevice vmDevice = new VmDevice(); vmDevice.setPlugged(true); List<Pair<VM, VmDevice>> vms = START Collections.singletonList(new Pair(vm, END vmDevice)); doReturn(vms).when(vmDao).getVmsWithPlugInfo(diskId); ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_VM_IS_NOT_DOWN); } don't use raw types - new Pair<>(vm, vmDevice)

Target:
public void testValidationFailsDiskConnectedToRunningVm() { VM vm = new VM(); vm.setStatus(VMStatus.Up); VmDevice vmDevice = new VmDevice(); vmDevice.setPlugged(true); List<Pair<VM, VmDevice>> vms = Collections.singletonList(new Pair<>(vm, vmDevice)); doReturn(vms).when(vmDao).getVmsWithPlugInfo(diskId); ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_VM_IS_NOT_DOWN); }
Source:
private void setQcowCompatForQcowImage() { Image image = imageDao.get(getDiskImage().getImageId()); if (getDiskImage().getDiskStorageType() == DiskStorageType.IMAGE && START getDiskImage().getVolumeFormat().equals(VolumeFormat.COW)) END { image.setQcowCompat(getDiskImage().getQcowCompat()); imageDao.update(image); } } why using equals for VolumeFormat and '==' for DiskStorageType ?

Target:
private void setQcowCompatForQcowImage() { Image image = imageDao.get(getDiskImage().getImageId()); if (getDiskImage().getDiskStorageType() == DiskStorageType.IMAGE && getDiskImage().getVolumeFormat() == VolumeFormat.COW) { image.setQcowCompat(getDiskImage().getQcowCompat()); imageDao.update(image); } }
Source:
START public void endSuccessfully() { END setQcowCompatForQcowImage(); if (getParameters().getImportAsTemplate()) { Guid newTemplateId = createTemplate(); // No reason for this to happen, but checking just to make sure if (newTemplateId != null) { attachDiskToTemplate(newTemplateId); } } updateDiskStatus(ImageStatus.OK); setSucceeded(true); } What about calling super? Is it intentional we don't call it? If so - why?

Target:
public void endSuccessfully() { super.endSuccessfully(); setQcowCompatForQcowImage(); if (getParameters().getImportAsTemplate()) { Guid newTemplateId = createTemplate(); // No reason for this to happen, but checking just to make sure if (newTemplateId != null) { attachDiskToTemplate(newTemplateId); } } updateDiskStatus(ImageStatus.OK); setSucceeded(true); }
Source:
public VDSInfoReturn getVdsStats(BrokerCommandCallback callback) { JsonRpcRequest request = new RequestBuilder("Host.getStats").build(); Map<String, Object> response = new FutureMap(this.client, request, ResourceManager.getInstance().getExecutor(), callback) .withResponseKey("info"); START return new VDSInfoReturn(response); END } Why not to enable lazyEval here?

Target:
public VDSInfoReturn getVdsStats(BrokerCommandCallback callback) { JsonRpcRequest request = new RequestBuilder("Host.getStats").build(); Map<String, Object> response = new FutureMap(this.client, request, callback) .withResponseKey("info"); return new VDSInfoReturn(response, true); }
Source:
protected boolean canAddLease() { if (!getParameters().getVmStaticData().isAutoStartup()) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_LEASES_ARE_NOT_SUPPORTED_WITH_HA_OFF); } START if (!FeatureSupported.isVmLeasesSupported(getEffectiveCompatibilityVersion())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_LEASES_ARE_NOT_SUPPORTED); } END return validateLeaseStorageDomain(getParameters().getVmStaticData().getLeaseStorageDomainId()); } Maybe it should be the first validation ?

Target:
protected boolean canAddLease() { if (!FeatureSupported.isVmLeasesSupported(getEffectiveCompatibilityVersion())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_LEASES_ARE_NOT_SUPPORTED); } if (!getParameters().getVmStaticData().isAutoStartup()) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_LEASES_ARE_NOT_SUPPORTED_WITH_HA_OFF); } return validateLeaseStorageDomain(getParameters().getVmStaticData().getLeaseStorageDomainId()); }
Source:
protected boolean checkDisksNotInBackupStorage() { for (Disk disk : getVm().getDiskMap().values()) { StorageDomainStatic destDomain = storageDomainStaticDao.get(disk.getId()); START if (destDomain.isBackup() == true) { END return false; } } return true; } no need for == true

Target:
protected boolean checkDisksNotInBackupStorage() { for (Disk disk : getVm().getDiskMap().values()) { StorageDomainStatic destDomain = storageDomainStaticDao.get(disk.getId()); if (destDomain.isBackup()) { return false; } } return true; }
Source:
public Future<JsonRpcResponse> call(JsonRpcRequest req, BrokerCommandCallback callback) throws ClientConnectionException { final Call call = new Call(req, START executorService, callback); END this.tracker.registerCall(req, call); retryCall(req, call); try { this.getClient().sendMessage(jsonToByteArray(req.toJson())); } finally { retryCall(req, call); } return call; } It looks like we are using executor in this class only so let's use this field instead of passing it as part of the call object.

Target:
public Future<JsonRpcResponse> call(JsonRpcRequest req, BrokerCommandCallback callback) throws ClientConnectionException { final Call call = new Call(req, callback); this.tracker.registerCall(req, call); retryCall(req, call); try { this.getClient().sendMessage(jsonToByteArray(req.toJson())); } finally { retryCall(req, call); } return call; }
Source:
protected void updateMetadataDevices() { if (getStorageDomain().getVgMetadataDevice() == null || getStorageDomain().getFirstMetadataDevice() == null) { blockStorageDomainHelper.fillMetadataDevicesInfo(getStorageDomain().getStorageStaticData(), START getVds().getStoragePoolId()); END storageDomainStaticDao.update(getStorageDomain().getStorageStaticData()); } } I'm not sure that will work on import storage domain. The process of import is being done through one host first so calling HSMGetStorageDomainInfo should be done through this Host.

Target:
protected void updateMetadataDevices() { if (getStorageDomain().getVgMetadataDevice() == null || getStorageDomain().getFirstMetadataDevice() == null) { blockStorageDomainHelper.fillMetadataDevicesInfo(getStorageDomain().getStorageStaticData(), getVds().getId()); storageDomainStaticDao.update(getStorageDomain().getStorageStaticData()); } }
Source:
private boolean ifaceMacCannotBeAddedToMacPool(VmNetworkInterface iface) { START return !macPool.isDuplicateMacAddressesAllowed() END && !shouldReassignMac(iface) && macPool.isMacInUse(iface.getMacAddress()); } Shouldn't you verify the mac is not null to avoid NPE? 'ImportVmFromConfigurationCommand' has this check.

Target:
private boolean ifaceMacCannotBeAddedToMacPool(VmNetworkInterface iface) { return iface.getMacAddress() != null && !macPool.isDuplicateMacAddressesAllowed() && !shouldReassignMac(iface) && macPool.isMacInUse(iface.getMacAddress()); }
Source:
private void activeDetailModelChanging(HasEntity<D> newValue, boolean stopRefresh) { for (HasEntity<D> oldValue : activeDetailModels) { // Make sure we had set an entity property of details model. if (oldValue != null START && stopRefresh) { END oldValue.setEntity(null); if (oldValue instanceof SearchableListModel) { ((SearchableListModel) oldValue).stopRefresh(); } } } if (newValue != null) { newValue.setEntity(provideDetailModelEntity(getSelectedItem())); } } Wouldn't a top-level if (stopRefresh) guard condition be better, instead of checking it within the loop?

Target:
private void activeDetailModelChanging(HasEntity<D> newValue, boolean stopRefresh) { if (stopRefresh) { for (HasEntity<D> oldValue : activeDetailModels) { // Make sure we had set an entity property of details model. if (oldValue != null) { oldValue.setEntity(null); if (oldValue instanceof SearchableListModel) { ((SearchableListModel) oldValue).stopRefresh(); } } } } if (newValue != null) { newValue.setEntity(provideDetailModelEntity(getSelectedItem())); } }
Source:
public static boolean isFormatCorrect(String blob) throws IOException { final Map<String, String> map = getEncryptionMap(blob); if (map.isEmpty()) { return false; START } END return ARTIFACT.equals(map.get(ARTIFACT_KEY)) && VERSION.equals(map.get(VERSION_KEY)); } Not needed to test emptiness, it's contained in condition below

Target:
public static boolean isFormatCorrect(String blob) throws IOException { final Map<String, String> map = getEncryptionMap(blob); return ARTIFACT.equals(map.get(ARTIFACT_KEY)) && VERSION.equals(map.get(VERSION_KEY)); }
Source:
public void restoreStateFromViewItem(PatternflyListViewItem<HostInterfaceLineModel> originalViewItem) { super.restoreStateFromViewItem(originalViewItem); // Need to check because we could be coming from a non bond interface and restoring the state (expanded details) // from it into a bonded interface will not work. if (originalViewItem instanceof HostNetworkInterfaceBondedListViewItem) { HostNetworkInterfaceBondedListViewItem original = (HostNetworkInterfaceBondedListViewItem) originalViewItem; START setSlavesExpanded(original.getSlavesState()); END } } Nit-pick: typecast could be inlined here, avoiding explicit "original" variable declaration, since it's only needed here.

Target:
public void restoreStateFromViewItem(PatternflyListViewItem<HostInterfaceLineModel> originalViewItem) { super.restoreStateFromViewItem(originalViewItem); // Need to check because we could be coming from a non bond interface and restoring the state (expanded details) // from it into a bonded interface will not work. if (originalViewItem instanceof HostNetworkInterfaceBondedListViewItem) { setSlavesExpanded(((HostNetworkInterfaceBondedListViewItem) originalViewItem).getSlavesState()); } }
Source:
public void restoreStateFromViewItem(PatternflyListViewItem<HostInterfaceLineModel> originalViewItem) { if (originalViewItem instanceof HostNetworkInterfaceListViewItem) { HostNetworkInterfaceListViewItem original = (HostNetworkInterfaceListViewItem) originalViewItem; START setLogicalNetworkExpanded(original.getLogicalNetworkState()); END } } Nit-pick: like in HostNetworkInterfaceBondedListViewItem.java, the typecast could be inlined here.

Target:
public void restoreStateFromViewItem(PatternflyListViewItem<HostInterfaceLineModel> originalViewItem) { if (originalViewItem instanceof HostNetworkInterfaceListViewItem) { setLogicalNetworkExpanded(((HostNetworkInterfaceListViewItem) originalViewItem).getLogicalNetworkState()); } }
Source:
public void setInSlot(Object slot, IsWidget content) { if (slot == MainSectionPresenter.TYPE_SetHeader) { setPanelContent(headerPanel, content); } else if (slot == MainSectionPresenter.TYPE_SetMainContent) { START if (!placeholderRemoved) { END removeHostPagePlaceholder(); placeholderRemoved = true; } setPanelContent(mainContentPanel, content); } else { super.setInSlot(slot, content); } } I would remove the boolean and put this after the activateMenus() above. Since we only need to call it once.

Target:
public void setInSlot(Object slot, IsWidget content) { if (slot == MainSectionPresenter.TYPE_SetHeader) { setPanelContent(headerPanel, content); } else if (slot == MainSectionPresenter.TYPE_SetMainContent) { setPanelContent(mainContentPanel, content); } else { super.setInSlot(slot, content); } }
Source:
private void warnIfNotAllDisksPermitSnapshots() { for (Disk disk : getVm().getDiskMap().values()) { START if (disk.getDiskStorageType() == DiskStorageType.IMAGE) { } END if (!disk.isAllowSnapshot()) { auditLogDirector.log(this, AuditLogType.USER_RUN_VM_AS_STATELESS_WITH_DISKS_NOT_ALLOWING_SNAPSHOT); break; } } } huh?

Target:
private void warnIfNotAllDisksPermitSnapshots() { for (Disk disk : getVm().getDiskMap().values()) { if (!disk.isAllowSnapshot()) { auditLogDirector.log(this, AuditLogType.USER_RUN_VM_AS_STATELESS_WITH_DISKS_NOT_ALLOWING_SNAPSHOT); break; } } }
Source:
protected boolean validate() { return super.validate() && isImageExist() && checkOperationIsCorrect() && checkOperationAllowedOnDiskContentType() && isImageNotLocked() && isSourceAndDestTheSame() && validateSourceStorageDomain() && validateDestStorage() && checkTemplateInDestStorageDomain() && validateSpaceRequirements() && validateVmSnapshotStatus() && checkCanBeMoveInVm() && checkIfNeedToBeOverride() && setAndValidateDiskProfiles() && validatePassDiscardSupportedForDestinationStorageDomain() START && isDiskInBackupDomain(); END } This validation should be in LiveMigrateVmDisksCommand since in this command we only move disks that their VMs are down (checkCanBeMoveInVm should verify this). LiveMigrateVmDisksCommand is the command that is responsible to move the disks inside a running VM

Target:
protected boolean validate() { return super.validate() && isImageExist() && checkOperationIsCorrect() && checkOperationAllowedOnDiskContentType() && isImageNotLocked() && isSourceAndDestTheSame() && validateSourceStorageDomain() && validateDestStorage() && checkTemplateInDestStorageDomain() && validateSpaceRequirements() && validateVmSnapshotStatus() && checkCanBeMoveInVm() && checkIfNeedToBeOverride() && setAndValidateDiskProfiles() && validatePassDiscardSupportedForDestinationStorageDomain(); }
Source:
START protected void END logException(RuntimeException ex) { if (ex.getMessage() == null || !ex.getMessage().contains("Policy reset")) { log.error("Command '{}' execution failed: {}", this, ex.getMessage()); log.debug("Exception", ex); } } it appears that this change can be reverted.

Target:
private void logException(RuntimeException ex) { if (ex.getMessage() == null || !ex.getMessage().contains("Policy reset")) { log.error("Command '{}' execution failed: {}", this, ex.getMessage()); log.debug("Exception", ex); } }