auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void setDefaultInterface() { Guid vmId = getVmId(); if START (!Guid.isNullOrEmpty(vmId)) END { getDiskInterface().setSelectedItem(getDisk().getDiskVmElementForVm(vmId).getDiskInterface()); } else { getDiskInterface().setSelectedItem(DiskInterface.VirtIO); } } Let's have the if in the positive branch

Target:
public void setDefaultInterface() { Guid vmId = getVmId(); if (Guid.isNullOrEmpty(vmId)) { getDiskInterface().setSelectedItem(DiskInterface.VirtIO); } else { getDiskInterface().setSelectedItem(getDisk().getDiskVmElementForVm(vmId).getDiskInterface()); } }
Source:
private boolean isClusterLevelChange() { Version newVersion = getParameters().getClusterLevelChangeToVersion(); return newVersion != null && getVm().isRunningOrPaused() && START (getVm().getCustomCompatibilityVersion() == null || !newVersion.equals(getVm().getCompatibilityVersion())); END } shouldn't the last part be (getVm().getCustomCompatibilityVersion() == null && !newVersion.equals(getVm().getCompatibilityVersion())) ?

Target:
private boolean isClusterLevelChange() { Version newVersion = getParameters().getClusterLevelChangeToVersion(); /* boolean isCustomCombatibilityNotUsed = getVm().getCustomCompatibilityVersion() == null; boolean areClusterAndVmVersionsDifferent*/ return newVersion != null && getVm().isRunningOrPaused() && (getVm().getCustomCompatibilityVersion() == null || !newVersion.equals(getVm().getCustomCompatibilityVersion())); }
Source:
private String getMethodName(String httpMethod) { if (httpMethod.equals("POST")) { return "add"; } if (httpMethod.equals("PUT")) { return "update"; } if (httpMethod.equals("GET")) { return "get"; } if (httpMethod.equals("DELETE")) { return "remove"; START } END return ""; //shouldn't reach here. } Consider using a "switch" statement.

Target:
private String getMethodName(String httpMethod) { switch (httpMethod) { case "POST": return "add"; case "PUT": return "update"; case "GET": return "get"; case "DELETE": return "remove"; default: return ""; //shouldn't reach here. } }
Source:
public String getPrettyName() { START return prettyName == null ? "" : prettyName; END } We don't need that here, null is OK if pretty name was not specified.

Target:
public String getPrettyName() { return prettyName; }
Source:
public VMNamesListReturnForXmlRpc(Map<String, Object> innerMap) { status = new StatusForXmlRpc((Map<String, Object>) innerMap.get(STATUS)); Object[] vmNames = (Object[]) innerMap.get(VM_NAMES); if (vmNames != null) { vmNamesList = START Arrays.asList(vmNames).stream().map(Objects::toString).collect(Collectors.toList()); END } } can use Arrays.stream(vmNames) instead of creating a list as intermediate step

Target:
public VMNamesListReturnForXmlRpc(Map<String, Object> innerMap) { status = new StatusForXmlRpc((Map<String, Object>) innerMap.get(STATUS)); Object[] vmNames = (Object[]) innerMap.get(VM_NAMES); if (vmNames != null) { vmNamesList = Arrays.stream(vmNames).map(Objects::toString).collect(Collectors.toList()); } }
Source:
public String getUrl() { return START this.url; END } if you're gonna rebase this patch, please consider dropping those `this.` prefixes from getters.

Target:
public String getUrl() { return url; }
Source:
public void testVmElementDiskPluggedStatus() { DiskVmElement dvePlugged = dao.get(new VmDeviceId(PLUGGED_DISK_ID, FixturesTool.VM_RHEL5_POOL_57)); assertTrue(dvePlugged.isPlugged()); START DiskVmElement dveUnlugged = dao.get(new VmDeviceId(UNPLUGGED_DISK_ID, FixturesTool.VM_RHEL5_POOL_57)); assertFalse(dveUnlugged.isPlugged()); END } I'd have this in a different test. I'd also try to fetch the DiskVmElement of a floating disk and assert it returns null.

Target:
public void testVmElementDiskPluggedStatus() { DiskVmElement dvePlugged = dao.get(new VmDeviceId(PLUGGED_DISK_ID, FixturesTool.VM_RHEL5_POOL_57)); assertTrue(dvePlugged.isPlugged()); }
Source:
private List<StorageServerConnections> getConnections() { List<StorageServerConnections> connectionsList = new ArrayList<>(); for (int i = 0; i START == NUMBER_OF_EXISTING_CONNECTIONS; END i++) { StorageServerConnections conn = new StorageServerConnections(); conn.setId(Guid.newGuid().toString()); connectionsList.add(conn); } return connectionsList; } This will create 0 connections. Didn't you mean < ?

Target:
private List<StorageServerConnections> getConnections() { List<StorageServerConnections> connectionsList = new ArrayList<>(); for (int i = 0; i <= NUMBER_OF_EXISTING_CONNECTIONS; i++) { StorageServerConnections conn = new StorageServerConnections(); conn.setId(Guid.newGuid().toString()); connectionsList.add(conn); } return connectionsList; }
Source:
private List<StorageServerConnections> getConnections() { List<StorageServerConnections> connectionsList = new ArrayList<>(); for (int i = 0; i START <= NUMBER_OF_EXISTING_CONNECTIONS; END i++) { StorageServerConnections conn = new StorageServerConnections(); conn.setId(Guid.newGuid().toString()); connectionsList.add(conn); } return connectionsList; } This will create 4 connections and not 3. You either init the index with 1 or use '<'

Target:
private List<StorageServerConnections> getConnections() { List<StorageServerConnections> connectionsList = new ArrayList<>(); for (int i = 0; i < NUMBER_OF_EXISTING_CONNECTIONS; i++) { StorageServerConnections conn = new StorageServerConnections(); conn.setId(Guid.newGuid().toString()); connectionsList.add(conn); } return connectionsList; }
Source:
private void lockImageInDb() { final DiskImage diskImage = getDiskImage(); TransactionSupport.executeInNewTransaction(() -> { getCompensationContext().snapshotEntityStatus(diskImage.getImage()); getCompensationContext().stateChanged(); diskImage.setImageStatus(ImageStatus.LOCKED); ImagesHandler.updateImageStatus(diskImage.getImageId(), ImageStatus.LOCKED); return null; START }); END } This command is currently transactional (should it be transactional?), I guess it should be set to non transactional with compensation, so: 1. the stateChanged need to be called after the actual change 2. need to add the NonTransactive annotation 3. need to add empty constructor

Target:
private void lockImageInDb() { final DiskImage diskImage = getDiskImage(); TransactionSupport.executeInNewTransaction(() -> { getCompensationContext().snapshotEntityStatus(diskImage.getImage()); diskImage.setImageStatus(ImageStatus.LOCKED); ImagesHandler.updateImageStatus(diskImage.getImageId(), ImageStatus.LOCKED); getCompensationContext().stateChanged(); return null; }); }
Source:
private Map<String, Pair<String, String>> getSharedLocksForTemplateDisk() { START initVmTemplateId(); END return Collections.singletonMap(getVmTemplateId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.TEMPLATE, EngineMessage.VM_TEMPLATE_IS_LOCKED)); } it is a bit unusual to init things in the getSharedLocks flow.. how about moving it to 'init' method? (need to check the VmEntityType there..)

Target:
private Map<String, Pair<String, String>> getSharedLocksForTemplateDisk() { return Collections.singletonMap(getVmTemplateId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.TEMPLATE, EngineMessage.VM_TEMPLATE_IS_LOCKED)); }
Source:
public boolean isAlive() { return this == START HostJobStatus.running END || this == HostJobStatus.pending; } Don't qualify with HostJobStatus: return this == running || this == pending

Target:
public boolean isAlive() { return this == running || this == pending; }
Source:
private boolean canRemoveVmPool(Guid vmPoolId) { START return getVmPoolDao().getVmPoolsMapByVmPoolId(vmPoolId).size() == 0; END } while on it, how about changing to isEmpty?

Target:
private boolean canRemoveVmPool(Guid vmPoolId) { return getVmPoolDao().getVmPoolsMapByVmPoolId(vmPoolId).isEmpty(); }
Source:
public void activateClearance(StorageDomain storageDomain){ START storageDomain.setDomainStatus(StorageDomain.DomainStatus.ACTIVE); END updateStorageDomain(storageDomain); } Possible NPE. In line 340 we could return null which would blow up here.

Target:
private void activateClearance(StorageDomain storageDomain){ storageDomain.setDomainStatus(StorageDomain.DomainStatus.ACTIVE); updateStorageDomain(storageDomain); }
Source:
public MacPool getMacPoolForDataCenter(Guid dataCenterId, CommandContext commandContext) { final MacPool macPool; try { macPool = getMacPoolById(getMacPoolId(dataCenterId), commandContext); } catch (Exception e) { START throw new IllegalStateException( String.format("An exception was thrown while retrieving the mac-pool for DC='%s'", dataCenterId), END e); } return macPool; } Done

Target:
public MacPool getMacPoolForDataCenter(Guid dataCenterId, CommandContext commandContext) { try { return getMacPoolById(getMacPoolId(dataCenterId), commandContext); } catch (RuntimeException e) { throw new IllegalStateException( String.format("An exception was thrown while retrieving the mac-pool for DC='%s'", dataCenterId), e); } }
Source:
START private static IllegalStateException END prepareNotFoundException(Guid macPoolId) { final String msg = String.format(INEXISTENT_POOL_EXCEPTION_MESSAGE, macPoolId); return new IllegalStateException(msg); } private static? What is this good for? Don't use static at all (except for utility methods like in Math class) or static factories etc.

Target:
private IllegalStateException prepareNotFoundException(Guid macPoolId) { final String msg = String.format(INEXISTENT_POOL_EXCEPTION_MESSAGE, macPoolId); return new IllegalStateException(msg); }
Source:
boolean validatePluginAction(String pluginName, boolean allowWhileLoading) { Plugin plugin = getPlugin(pluginName); if (plugin == null) { return false; } boolean isInitializingOrInUse = plugin.isInState(PluginState.INITIALIZING) || plugin.isInState(PluginState.IN_USE); boolean isLoading = plugin.isInState(PluginState.LOADING); START return allowWhileLoading ? (isLoading || isInitializingOrInUse) : isInitializingOrInUse; END } how about return isInitializingOrInUse || (allowWhileLoading && isLoading); ?

Target:
boolean validatePluginAction(String pluginName, boolean allowWhileLoading) { Plugin plugin = getPlugin(pluginName); if (plugin == null) { return false; } boolean isInitializingOrInUse = plugin.isInState(PluginState.INITIALIZING) || plugin.isInState(PluginState.IN_USE); boolean isLoading = plugin.isInState(PluginState.LOADING); return isInitializingOrInUse || (allowWhileLoading && isLoading); }
Source:
public void testActionParameters() { hostService.setupNetworks() .modifiedBonds( hostNic() .name("bond0") .bonding( bonding() .options( option() .name("mode") .type("4") START .build() END ) .slaves( hostNic() .name("eth1") .build(), hostNic() .name("eth2") .build() ) .build() ) .build() ).send(); } If I remember correctly this call to "build" isn't required, as the "options" method accepts an object and also a builder. If it is a builder it will call the "build" method internally. Same for the other calls to "build".

Target:
public void testActionParameters() { hostService.setupNetworks() .modifiedBonds( hostNic() .name("bond0") .bonding( bonding() .options( option() .name("mode") .type("4") ) .slaves( hostNic() .name("eth1"), hostNic() .name("eth2") ) ) ).send(); }
Source:
public CommandCallback getCallback() { if (getParameters().isUseCinderCommandCallback()) { return new ConcurrentChildCommandsExecutionCallback(); } START return new SerialChildCommandsExecutionCallback(); END } return getParameters().isUseCinderCommandCallback() ? new ConcurrentChildCommandsExecutionCallback() : new SerialChildCommandsExecutionCallback();

Target:
public CommandCallback getCallback() { return getParameters().isUseCinderCommandCallback() ? new ConcurrentChildCommandsExecutionCallback() : new SerialChildCommandsExecutionCallback(); }
Source:
public void onBrowserEvent(Context context, Element parent, GlusterVolumeEntity volume, SafeHtml tooltipContent, NativeEvent event, ValueUpdater<GlusterVolumeEntity> valueUpdater) { VolumeStatus status = GlusterVolumeUtils.getVolumeStatus(volume); if (BrowserEvents.CLICK.equals(event.getType()) && onClickCommand != null && (status == VolumeStatus.ALL_BRICKS_DOWN || status == VolumeStatus.SOME_BRICKS_DOWN)) { onClickCommand.execute(); } else { START super.onBrowserEvent(context, parent, volume, tooltipContent, event, valueUpdater); END } } I think it would be better to always call super.onBrowserEvent, the click might do something in the super class as well.

Target:
public void onBrowserEvent(Context context, Element parent, GlusterVolumeEntity volume, SafeHtml tooltipContent, NativeEvent event, ValueUpdater<GlusterVolumeEntity> valueUpdater) { super.onBrowserEvent(context, parent, volume, tooltipContent, event, valueUpdater); VolumeStatus status = GlusterVolumeUtils.getVolumeStatus(volume); if (BrowserEvents.CLICK.equals(event.getType()) && onClickCommand != null && (status == VolumeStatus.ALL_BRICKS_DOWN || status == VolumeStatus.SOME_BRICKS_DOWN)) { onClickCommand.execute(); } }
Source:
private void checkImageTarget() { // TODO: // 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. if (getVm().getOrigin() == OriginType.KVM && getActionState() == CommandActionState.EXECUTE) { StorageDomain domain = storageDomainDao.get(getStorageDomainId()); for (DiskImage image : getVm().getImages()) { if (domain.getStorageType().isBlockDomain()) { image.setActualSizeInBytes(image.getSize()); START } END } } } how about making it a bit more declarative: if (domain.getStorageType().isBlockDomain()) { getVm().getImages().forEach(image -> image.setActualSizeInBytes(image.getSize())); }

Target:
private void checkImageTarget() { // TODO: // 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. if (getVm().getOrigin() == OriginType.KVM && getActionState() == CommandActionState.EXECUTE) { StorageDomain domain = storageDomainDao.get(getStorageDomainId()); if (domain.getStorageType().isBlockDomain()) { getVm().getImages().forEach(image -> image.setActualSizeInBytes(image.getSize())); } } }
Source:
private void freeLockForValidationPassedCommands() { for (CommandBase<?> command : getCommands()) { if (command.getReturnValue().isValid()) { command.freeLock(); } } START } END why not with stream API? will be cleaner

Target:
private void freeLockForValidationPassedCommands() { getCommands().stream().filter(command->command.getReturnValue().isValid()).forEach(command->command.freeLock()); }
Source:
private boolean isSparsifyCommandAvailable() { ArrayList<Disk> disks = getSelectedItems() != null ? Linq.<Disk> cast(getSelectedItems()) : new ArrayList<Disk>(); for (Disk disk : disks) { if (isDiskLocked(disk) START || END (!isVmDown() && disk.getPlugged())) { return false; } } return true; } just one space

Target:
private boolean isSparsifyCommandAvailable() { List<Disk> disks = getSelectedItems() != null ? Linq.<Disk> cast(getSelectedItems()) : new ArrayList<Disk>(); for (Disk disk : disks) { if (isDiskLocked(disk) || (!isVmDown() && disk.getPlugged())) { return false; } } return true; }
Source:
public void setResourcesDir(File newResourcesDir) { START this.resourcesDir END = newResourcesDir; } The purpose of naming it "new..." is to avoid the "this...", can you remove it?

Target:
public void setResourcesDir(File newResourcesDir) { resourcesDir = newResourcesDir; }
Source:
public void testCannotUpdateOSNotSupportVirtioScsi() { prepareVmToPassValidate(); group.setCompatibilityVersion(Version.v4_0); when(command.isVirtioScsiEnabledForVm(any(Guid.class))).thenReturn(true); when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class))).thenReturn( START new ArrayList<>(Collections.singletonList("VirtIO"))); END ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_DOES_NOT_SUPPORT_VIRTIO_SCSI); } you can drop the new ArrayList<>(...) surroundings. It's sufficient to return just the singletonList.

Target:
public void testCannotUpdateOSNotSupportVirtioScsi() { prepareVmToPassValidate(); group.setCompatibilityVersion(Version.v4_0); when(command.isVirtioScsiEnabledForVm(any(Guid.class))).thenReturn(true); when(osRepository.getDiskInterfaces(any(Integer.class), any(Version.class))).thenReturn( Collections.singletonList("VirtIO")); ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_DOES_NOT_SUPPORT_VIRTIO_SCSI); }
Source:
protected void setUpLogExpectations(boolean debug) throws START Exception{ END Field field = BaseBackendResource.class.getDeclaredField("log"); Logger logger = mock(Logger.class); when(logger.isDebugEnabled()).thenReturn(debug); setFinalStatic(field, logger); } Please add a space before the curly bracket

Target:
protected void setUpLogExpectations(boolean debug) throws Exception { Field field = BaseBackendResource.class.getDeclaredField("log"); Logger logger = mock(Logger.class); when(logger.isDebugEnabled()).thenReturn(debug); setFinalStatic(field, logger); }
Source:
public void cleanup() { START networkProviderWidget.cleanup(); fenceAgentsEditor.cleanup(); proxySourceEditor.cleanup(); END driver.cleanup(); } shouldn't these fields be covered by the autogenerated driver.cleanup() method? (Since they are fields and implement HasCleanup interface)

Target:
public void cleanup() { driver.cleanup(); }
Source:
public void cleanup() { START labelsWidget.cleanup(); END driver.cleanup(); } same question here: shouldn't labelsWidget.cleanup() be included in the generated driver.cleanup()?

Target:
public void cleanup() { driver.cleanup(); }
Source:
public void cleanup() { driver.cleanup(); START vmDiskPopupWidget.cleanup(); END } same question here

Target:
public void cleanup() { driver.cleanup(); }
Source:
START public DataCenter END reInitializeDataCenter(String dcId) throws RuntimeException { log.info("about to reinitialize dc"); DataCenter dataCenter = new DataCenter(); dataCenter.setId(dcId); updateDataCenter(dataCenter); return dataCenter; } why public? Are we planning to use it outside of this class?

Target:
private DataCenter reInitializeDataCenter(String dcId) throws RuntimeException { log.info("about to reinitialize dc"); DataCenter dataCenter = new DataCenter(); dataCenter.setId(dcId); updateDataCenter(dataCenter); return dataCenter; }
Source:
START public StorageDomain END recoverStorageDomain(String sdUUID) { log.info("about to recover SD {}", sdUUID); StorageDomain storageDomain = new StorageDomain(); storageDomain.setId(sdUUID); updateStorageDomain(storageDomain); return storageDomain; } why public? Are we planning to use it outside of this class?

Target:
private StorageDomain recoverStorageDomain(String sdUUID) { log.info("about to recover SD {}", sdUUID); StorageDomain storageDomain = new StorageDomain(); storageDomain.setId(sdUUID); updateStorageDomain(storageDomain); return storageDomain; }
Source:
START public void syncSearch(VdcQueryType vdcQueryType, VdcQueryParametersBase vdcQueryParametersBase) { END AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(this); _asyncQuery.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object ReturnValue) { setItems((Collection<T>) ((VdcQueryReturnValue) ReturnValue).getReturnValue()); } }; vdcQueryParametersBase.setRefresh(getIsQueryFirstTime()); Frontend.getInstance().runQuery(vdcQueryType, vdcQueryParametersBase, _asyncQuery); setIsQueryFirstTime(false); } Why isn't this protected like in the master patch?

Target:
protected void syncSearch(VdcQueryType vdcQueryType, VdcQueryParametersBase vdcQueryParametersBase) { AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(this); _asyncQuery.asyncCallback = new INewAsyncCallback() { @Override public void onSuccess(Object model, Object ReturnValue) { setItems((Collection<T>) ((VdcQueryReturnValue) ReturnValue).getReturnValue()); } }; vdcQueryParametersBase.setRefresh(getIsQueryFirstTime()); Frontend.getInstance().runQuery(vdcQueryType, vdcQueryParametersBase, _asyncQuery); setIsQueryFirstTime(false); }
Source:
public String get(String macPoolId, String macPoolName) { if (macPoolId != null) { return macPoolId; } if (macPoolName != null) { MacPool macPoolByName = callerResource.getEntity(MacPool.class, VdcQueryType.GetMacPoolByName, new NameQueryParameters(macPoolName), START null, END true); if (macPoolByName != null) { return macPoolByName.getId().toString(); } } return null; } I guess this should be requestedMacPoolName rather then null, as it's used for a failure reporting.

Target:
public String get(String macPoolId, String macPoolName) { if (macPoolId != null) { return macPoolId; } if (macPoolName != null) { MacPool macPoolByName = callerResource.getEntity(MacPool.class, VdcQueryType.GetMacPoolByName, new NameQueryParameters(macPoolName), macPoolName, true); if (macPoolByName != null) { return macPoolByName.getId().toString(); } } return null; }
Source:
START public ValidationResult END isOsSupportedForVirtIoScsi(VM vm) { if (!VmValidationUtils.isDiskInterfaceSupportedByOs( vm.getOs(), vm.getCompatibilityVersion(), DiskInterface.VirtIO_SCSI)) { return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GUEST_OS_VERSION_IS_NOT_SUPPORTED); } return ValidationResult.VALID; } Can be private.

Target:
private ValidationResult isOsSupportedForVirtIoScsi(VM vm) { if (!VmValidationUtils.isDiskInterfaceSupportedByOs( vm.getOs(), vm.getCompatibilityVersion(), DiskInterface.VirtIO_SCSI)) { return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_GUEST_OS_VERSION_IS_NOT_SUPPORTED); } return ValidationResult.VALID; }
Source:
public void updateVirtioScsiController(VmBase vm, Boolean isVirtioScsiEnabled) { if (isVirtioScsiEnabled == null) { return; //we don't want to update the device } if (isVirtioScsiEnabled) { START if (!hasVirtioScsiController(vm.getId())) { END addVirtioScsiController(vm); } } else { removeVirtioScsiControllers(vm.getId()); } } yes, I agree, before this method is called, you need to remove the controllers first.

Target:
public void updateVirtioScsiController(VmBase vm, Boolean isVirtioScsiEnabled) { if (isVirtioScsiEnabled == null) { return; //we don't want to update the device } removeVirtioScsiControllers(vm.getId()); if (isVirtioScsiEnabled) { addVirtioScsiController(vm); } }
Source:
public SysprepVmTemplateParameters(Guid vmTemplateId) { START this.vmTemplateId = vmTemplateId; END } VmTemplateParameters also contains the id, can pass that to it and drop it from this class

Target:
public SysprepVmTemplateParameters(Guid vmTemplateId) { super(vmTemplateId); }
Source:
private MethodExpression removePrefix(MethodExpression expression) { return expression.getMethod().getWords().get(0).equals(MANDATORY) || START expression.getMethod().getWords().get(0).equals(OPTIONAL) ? END (MethodExpression)expression.getParameters().get(0) : expression; } Same than before, consider making "OPTINAL" a "Name".

Target:
private MethodExpression removePrefix(MethodExpression expression) { return expression.getMethod().equals(MANDATORY) || expression.getMethod().equals(OPTIONAL) ? (MethodExpression)expression.getParameters().get(0) : expression; }
Source:
public static START String or(Object... END params) { return ""; } Why "String" and not "Object"?

Target:
public static Object or(Object... params) { return ""; }
Source:
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof DnsResolverConfiguration)) { return false; } DnsResolverConfiguration that = (DnsResolverConfiguration) o; START return Objects.equals(getNameServers(), that.getNameServers()); END } Why the 'id' is not part of the equals?

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof DnsResolverConfiguration)) { return false; } DnsResolverConfiguration that = (DnsResolverConfiguration) o; return Objects.equals(getId(), that.getId()) && Objects.equals(getNameServers(), that.getNameServers()); }
Source:
public NameServer flush() { START return new NameServer(this.nameServerEntity.getEntity()); END } Please remove the "this".

Target:
public NameServer flush() { return new NameServer(nameServerEntity.getEntity()); }
Source:
public DnsConfigurationWidget() { setDnsConfigurationEditor = new EntityModelCheckBoxEditor(Align.RIGHT); initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); WidgetIdHandler.idHandler.generateAndSetIds(this); driver.initialize(this); START setDnsConfigurationEditor.setLabel(constants.setDnsConfigurationLabel()); END } Please use prefered declarative approach - attribute in *.ui.xml

Target:
public DnsConfigurationWidget() { setDnsConfigurationEditor = new EntityModelCheckBoxEditor(Align.RIGHT); initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); WidgetIdHandler.idHandler.generateAndSetIds(this); driver.initialize(this); }
Source:
private static AddDiskParameters createParameters() { DiskImage image = new DiskImage(); DiskVmElement dve = new DiskVmElement(null, vmId); dve.setDiskInterface(DiskInterface.IDE); START dve.setUsingScsiReservation(true); END return new AddDiskParameters(dve, image); } Why? You already set the value in each of the three tests that you changed here. I think that this line should be removed.

Target:
private static AddDiskParameters createParameters() { DiskImage image = new DiskImage(); DiskVmElement dve = new DiskVmElement(null, vmId); dve.setDiskInterface(DiskInterface.IDE); return new AddDiskParameters(dve, image); }
Source:
public void testIscsiLunCanBeAdded() { LunDisk disk = createISCSILunDisk(); command.getParameters().setDiskInfo(disk); START DiskVmElement dve = new DiskVmElement(); END command.getParameters().getDiskVmElement().setUsingScsiReservation(false); assertTrue("checkIfLunDiskCanBeAdded() failed for valid iscsi lun", command.checkIfLunDiskCanBeAdded(spyDiskValidator(disk))); } Looks redundant - please remove.

Target:
public void testIscsiLunCanBeAdded() { LunDisk disk = createISCSILunDisk(); command.getParameters().setDiskInfo(disk); command.getParameters().getDiskVmElement().setUsingScsiReservation(false); assertTrue("checkIfLunDiskCanBeAdded() failed for valid iscsi lun", command.checkIfLunDiskCanBeAdded(spyDiskValidator(disk))); }
Source:
START private DiskVmElement createDiskVmElementUsingScsiReserevation() { END DiskVmElement dve = new DiskVmElement(); dve.setUsingScsiReservation(true); return dve; } Should be static

Target:
private static DiskVmElement createDiskVmElementUsingScsiReserevation() { DiskVmElement dve = new DiskVmElement(); dve.setUsingScsiReservation(true); return dve; }
Source:
public void canDisableVirtioScsiFail() { Disk disk = new DiskImage(); DiskVmElement dve = new DiskVmElement(disk.getId(), vm.getId()); dve.setDiskInterface(DiskInterface.VirtIO_SCSI); disk.setDiskVmElements(Collections.singletonList(dve)); START when(DbFacade.getInstance().getVmNetworkInterfaceDao()).thenReturn(vmNetworkInterfaceDao); END assertThat(validator.canDisableVirtioScsi(Collections.singletonList(disk)), failsWith(EngineMessage.CANNOT_DISABLE_VIRTIO_SCSI_PLUGGED_DISKS)); } huh?

Target:
public void canDisableVirtioScsiFail() { Disk disk = new DiskImage(); DiskVmElement dve = new DiskVmElement(disk.getId(), vm.getId()); dve.setDiskInterface(DiskInterface.VirtIO_SCSI); disk.setDiskVmElements(Collections.singletonList(dve)); assertThat(validator.canDisableVirtioScsi(Collections.singletonList(disk)), failsWith(EngineMessage.CANNOT_DISABLE_VIRTIO_SCSI_PLUGGED_DISKS)); }
Source:
public CommandCallback getCallback() { START if (isDataOperationsByHSM()){ END return new ConcurrentChildCommandsExecutionCallback(); } return null; } you can inline that- return isDataOperationsByHSM() ? new .. : null;

Target:
public CommandCallback getCallback() { return isDataOperationsByHSM() ? new ConcurrentChildCommandsExecutionCallback() : null; }
Source:
public void endTaskStep(Guid stepId, JobExecutionStatus exitStatus) { try { if (stepId != null) { Step step = jobRepository.getStep(stepId); if (step != null) { START step.setProgress(100); END step.markStepEnded(exitStatus); jobRepository.updateStep(step); } } } catch (Exception e) { log.error("Failed to terminate step '{}' with status '{}': {}", stepId, exitStatus, e.getMessage()); log.debug("Exception", e); } } pls avoid magic numbers

Target:
public void endTaskStep(Guid stepId, JobExecutionStatus exitStatus) { try { if (stepId != null) { Step step = jobRepository.getStep(stepId); if (step != null) { step.markStepEnded(exitStatus); jobRepository.updateStep(step); } } } catch (Exception e) { log.error("Failed to terminate step '{}' with status '{}': {}", stepId, exitStatus, e.getMessage()); log.debug("Exception", e); } }
Source:
public List<GlusterVolumeEntity> getVolumesSupportedAsStorageDomain() { List<GlusterVolumeEntity> volumes = getCallsHandler().executeReadList("GetGlusterVolumesSupportedAsStorageDomain", volumeRowMapper, getCustomMapSqlParameterSource() START .addValue("replica_count", 3)); END fetchRelatedEntities(volumes); return volumes; } Won't it be better to pass the replica count as a parameter in getVolumesSupportedAsStorageDomain, or just remove it from the stored procedure instead

Target:
public List<GlusterVolumeEntity> getVolumesSupportedAsStorageDomain() { List<GlusterVolumeEntity> volumes = getCallsHandler().executeReadList("GetGlusterVolumesSupportedAsStorageDomain", volumeRowMapper, null); fetchRelatedEntities(volumes); return volumes; }
Source:
START public ChangeVmClusterValidator(VmCommand END parentCommand, Guid targetClusterId, Version vmCustomCompatibilityVersion) { this.parentCommand = parentCommand; this.targetClusterId = targetClusterId; this.vmCompatibilityVersion = vmCustomCompatibilityVersion; } It's better to make the constructor private or protected.

Target:
private ChangeVmClusterValidator(VmCommand parentCommand, Guid targetClusterId, Version vmCustomCompatibilityVersion) { this.parentCommand = parentCommand; this.targetClusterId = targetClusterId; this.vmCompatibilityVersion = vmCustomCompatibilityVersion; }
Source:
private QemuVolumeFormat(String value) { START value = END value; } this.value = value;

Target:
private QemuVolumeFormat(String value) { this.value = value; }
Source:
public CommandCallback getCallback() { if (getVm().isQualifiedForLiveSnapshotMerge() || getParameters().isUseCinderCommandCallback() || START FeatureSupported.isQemuimgCommitSupported(getStoragePool().getCompatibilityVersion())) { END return new ConcurrentChildCommandsExecutionCallback(); } return null; } please export this check a method, it's long and repeating itself few times.

Target:
public CommandCallback getCallback() { if (getVm().isQualifiedForLiveSnapshotMerge() || getParameters().isUseCinderCommandCallback() || isQemuimgCommitSupported()) { return new ConcurrentChildCommandsExecutionCallback(); } return null; }
Source:
public CommandCallback getCallback() { START if (FeatureSupported.isQemuingCommitSupported(getStoragePool().getCompatibilityVersion())) { END return new ConcurrentChildCommandsExecutionCallback(); } if (getVm().isQualifiedForLiveSnapshotMerge() || getParameters().isUseCinderCommandCallback()) { return new ConcurrentChildCommandsExecutionCallback(); } return null; } why not merging the condition with line 505?

Target:
public CommandCallback getCallback() { if (getVm().isQualifiedForLiveSnapshotMerge() || getParameters().isUseCinderCommandCallback() || FeatureSupported.isQemuingCommitSupported(getStoragePool().getCompatibilityVersion())) { return new ConcurrentChildCommandsExecutionCallback(); } return null; }
Source:
private VdcActionType getSnapshotActionType() { if (getVm().isQualifiedForLiveSnapshotMerge()) { return VdcActionType.RemoveSnapshotSingleDiskLive; } START if (FeatureSupported.isQemuimgCommitSupported(getStoragePool().getCompatibilityVersion())) { END return VdcActionType.ColdMergeSnapshotSingleDisk; } return VdcActionType.RemoveSnapshotSingleDisk; } please use the added method isQemuimgCommitSupported() here as well

Target:
private VdcActionType getSnapshotActionType() { if (getVm().isQualifiedForLiveSnapshotMerge()) { return VdcActionType.RemoveSnapshotSingleDiskLive; } if (isQemuimgCommitSupported()) { return VdcActionType.ColdMergeSnapshotSingleDisk; } return VdcActionType.RemoveSnapshotSingleDisk; }
Source:
public void releaseMacsOnCommit(List<String> macs) { CompensationContext compensationContext = this.commandContext.getCompensationContext(); ReleaseMacsCompensationListener compensationListener = this.compensationListener; log.debug("Registering macs: to be released in case of successful execution", START Arrays.toString(macs.toArray())); END compensationListener.macsToReleaseOnCommit.addAll(macs); log.debug("Registering compensation listener {}" + compensationListener); compensationContext.addListener(compensationListener); } why not to rely on AbstractCollection..toString?

Target:
public void releaseMacsOnCommit(List<String> macs) { CompensationContext compensationContext = this.commandContext.getCompensationContext(); ReleaseMacsCompensationListener compensationListener = this.compensationListener; log.debug("Registering macs: to be released in case of successful execution", macs); compensationListener.macsToReleaseOnCommit.addAll(macs); log.debug("Registering compensation listener {}" + compensationListener); compensationContext.addListener(compensationListener); }
Source:
public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> listPermissionSubjects = new ArrayList<>(); START if (!isImageProvided()) { END listPermissionSubjects.add(new PermissionSubject(getParameters().getStorageDomainId(), VdcObjectType.Storage, ActionGroup.CREATE_DISK)); } else { // DISK_OPERATOR role is granted and persisted for the user who created the disk. // Therefor, returning a CREATE_DISK permission subject on the target disk will enforce that the only user // who can do I/O to this disk is its creator. listPermissionSubjects.add(new PermissionSubject(getParameters().getImageId(), VdcObjectType.Disk, ActionGroup.CREATE_DISK)); } return listPermissionSubjects; } would you mind inverting the condition to simplify it and skip the negation ? if (isImageProvided()) { ... } else { ... }

Target:
public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> listPermissionSubjects = new ArrayList<>(); if (isImageProvided()) { // DISK_OPERATOR role is granted and persisted for the user who created the disk. // Therefor, returning a CREATE_DISK permission subject on the target disk will enforce that the only user // who can do I/O to this disk is its creator. listPermissionSubjects.add(new PermissionSubject(getParameters().getImageId(), VdcObjectType.Disk, ActionGroup.CREATE_DISK)); } else { listPermissionSubjects.add(new PermissionSubject(getParameters().getStorageDomainId(), VdcObjectType.Storage, ActionGroup.CREATE_DISK)); } return listPermissionSubjects; }
Source:
private void unlockImageInDb() { DiskImage diskImage = getDiskImage(); START diskImage.setImageStatus(ImageStatus.OK); END ImagesHandler.updateImageStatus(diskImage.getImageId(), ImageStatus.OK); } Not needed, the next statement handles it in the DB, do we really care if we have the status changed in the instance?

Target:
private void unlockImageInDb() { DiskImage diskImage = getDiskImage(); ImagesHandler.updateImageStatus(diskImage.getImageId(), ImageStatus.OK); }
Source:
START public boolean equals(Object o) { END if (o instanceof PermissionSubject) { PermissionSubject other = (PermissionSubject) o; return Objects.equals(other.objectId, objectId) && Objects.equals(other.ObjectType, ObjectType) && Objects.equals(other.actionGroup, actionGroup); } return false; } This one is missing: if (this == obj) { return true; }

Target:
public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof PermissionSubject) { PermissionSubject other = (PermissionSubject) o; return Objects.equals(other.objectId, objectId) && Objects.equals(other.ObjectType, ObjectType) && Objects.equals(other.actionGroup, actionGroup); } return false; }
Source:
public ColdMergeCommandParameters(Guid storagePoolId, SubchainInfo subchainInfo) { START super(); END setStoragePoolId(storagePoolId); this.subchainInfo = subchainInfo; } needed?

Target:
public ColdMergeCommandParameters(Guid storagePoolId, SubchainInfo subchainInfo) { setStoragePoolId(storagePoolId); this.subchainInfo = subchainInfo; }
Source:
public GlusterStorageDomainDRSyncJob() { super(); START backend = Injector.get(BackendInternal.class); storageDomainDao = Injector.get(StorageDomainDao.class); geoRepDao = Injector.get(GlusterGeoRepDao.class); END } instead using the Injector here, pls use the @Inject annotation, and when you intend to use GlusterStorageDomainDRSyncJob, declare it using @Inject or using Injector.get(GlusterStorageDomainDRSyncJob.class);

Target:
public GlusterStorageDomainDRSyncJob() { super(); // backend = Injector.get(BackendInternal.class); // storageDomainDao = Injector.get(StorageDomainDao.class); // geoRepDao = Injector.get(GlusterGeoRepDao.class); }
Source:
public ValidationResult isMacAssignableValidator() { START Boolean END allowDupMacs = macPool.isDuplicateMacAddressesAllowed(); boolean illegalDuplicateMacUsage = !allowDupMacs && macPool.isMacInUse(macAddress); EngineMessage failMessage = EngineMessage.NETWORK_MAC_ADDRESS_IN_USE; return ValidationResult .failWith(failMessage, ReplacementUtils.getVariableAssignmentString(failMessage, macAddress)) .when(illegalDuplicateMacUsage); } (feel free to ignore this) This is outside the scope of the patch, so please feel free to ignore this, but maybe we could change: Boolean -> boolean

Target:
public ValidationResult isMacAssignableValidator() { boolean allowDupMacs = macPool.isDuplicateMacAddressesAllowed(); boolean illegalDuplicateMacUsage = !allowDupMacs && macPool.isMacInUse(macAddress); EngineMessage failMessage = EngineMessage.NETWORK_MAC_ADDRESS_IN_USE; return ValidationResult .failWith(failMessage, ReplacementUtils.getVariableAssignmentString(failMessage, macAddress)) .when(illegalDuplicateMacUsage); }
Source:
START private void failValidationCannotPlugPassthroughVnicNoSuitableVf() { END failValidation(EngineMessage.CANNOT_PLUG_PASSTHROUGH_VNIC_NO_SUITABLE_VF, String.format("$vnicName %1$s", getInterfaceName())); } why not to prefet it to return the value of the inner method ? so line 134-135 would look like: return failValidationCannotPlugPassthroughVnicNoSuitableVf (...); ?

Target:
private boolean failValidationCannotPlugPassthroughVnicNoSuitableVf() { return failValidation(EngineMessage.CANNOT_PLUG_PASSTHROUGH_VNIC_NO_SUITABLE_VF, String.format("$vnicName %1$s", getInterfaceName())); }
Source:
private String acquireVF() { try { hostDeviceManager.acquireHostDevicesLock(getVdsId()); String vfToUse = findFreeVf(); START networkDeviceHelper.setVmIdOnVfs(getVdsId(), getVmId(), Collections.singleton(vfToUse)); END return vfToUse; } finally { hostDeviceManager.releaseHostDevicesLock(getVdsId()); } } vfToUse might be null. This should not cause any problems, as setVmIdOnVfs seems to handle it correctly, but it might be safer to check against it (as was the case in the original code).

Target:
private String acquireVF() { try { hostDeviceManager.acquireHostDevicesLock(getVdsId()); return findFreeVf(); } finally { hostDeviceManager.releaseHostDevicesLock(getVdsId()); } }
Source:
START public HostValidator(VDS host) { END this.host = host; } Perhaps make it private so no one will be able to initialize it outside the class? It makes sense cause regular initialization will not do much without injecting the members

Target:
protected HostValidator(VDS host) { this.host = host; }
Source:
private void updateActionAvailability() { ArrayList<StorageDomainDR> domainDRs = getSelectedItems() != null ? Linq.<StorageDomainDR> cast(getSelectedItems()) : new ArrayList<StorageDomainDR>(); START getNewCommand().setIsExecutionAllowed(true); END getEditCommand().setIsExecutionAllowed(domainDRs.size() == 1); } Is new allowed always. I think by default all commands are allowed. If so then we can remove it.

Target:
private void updateActionAvailability() { ArrayList<StorageDomainDR> domainDRs = getSelectedItems() != null ? Linq.<StorageDomainDR> cast(getSelectedItems()) : new ArrayList<StorageDomainDR>(); getEditCommand().setIsExecutionAllowed(domainDRs.size() == 1); }
Source:
public void addVideoDevices(VmBase vmBase, int numberOfVideoDevices) { if (vmBase.getDefaultDisplayType() != DisplayType.none START && vmBase.getDefaultDisplayType().getDefaultVmDeviceType() != null) { END for (int i = 0; i < numberOfVideoDevices; i++) { addManagedDevice( new VmDeviceId(Guid.newGuid(), vmBase.getId()), VmDeviceGeneralType.VIDEO, vmBase.getDefaultDisplayType().getDefaultVmDeviceType(), getVideoDeviceSpecParams(vmBase), true, false); } } } why do we need this part?

Target:
public void addVideoDevices(VmBase vmBase, int numberOfVideoDevices) { if (vmBase.getDefaultDisplayType() != DisplayType.none) { for (int i = 0; i < numberOfVideoDevices; i++) { addManagedDevice( new VmDeviceId(Guid.newGuid(), vmBase.getId()), VmDeviceGeneralType.VIDEO, vmBase.getDefaultDisplayType().getDefaultVmDeviceType(), getVideoDeviceSpecParams(vmBase), true, false); } } }
Source:
public void buildVmVideoCards() { boolean videoCardOverridden = vm.isRunOnce() && vm.getDefaultDisplayType() != null; boolean isHeadlessMode = vm.getDefaultDisplayType() == DisplayType.none; if (videoCardOverridden) { START if(isHeadlessMode) END { return; } buildVmVideoDeviceOverridden(); } else { buildVmVideoDevicesFromDb(); } } missing space

Target:
public void buildVmVideoCards() { boolean videoCardOverridden = vm.isRunOnce() && vm.getDefaultDisplayType() != null; if (videoCardOverridden) { if (vm.getDefaultDisplayType() == DisplayType.none) { return; } buildVmVideoDeviceOverridden(); } else { buildVmVideoDevicesFromDb(); } }
Source:
public static void setTooltipOnElement(String tooltip, Element element) { START if (tooltip!= null) { END element.setTitle(tooltip); } } Don't we want to handle null tooltip as well? if (tooltip != null) { element.setTitle(tooltip); } else { element.setTitle(""); }

Target:
public static void setTooltipOnElement(String tooltip, Element element) { if (tooltip!= null) { element.setTitle(tooltip); } else { element.setTitle(""); //$NON-NLS-1$ } }
Source:
private void endSuccessfullySynchronous() { if (reloadVmTemplateFromDB() != null) { endDefaultOperations(); } START sealVmTemplate(); END setSucceeded(true); } but no tasks --> no disks, so no need to seal it, right?

Target:
private void endSuccessfullySynchronous() { if (reloadVmTemplateFromDB() != null) { endDefaultOperations(); } setSucceeded(true); }
Source:
private static List<TagObject> activeTagList(TagModel model) { List<TagObject> result = new ArrayList<>(); if (model.getSelection()) { result.add(from(model, false)); } for(TagModel child: model.getChildren()) { List<TagObject> activeChildTags = activeTagList(child); START if (!activeChildTags.isEmpty()) { END result.addAll(activeChildTags); } } return result; } Why is this check necessary?

Target:
private static List<TagObject> activeTagList(TagModel model) { List<TagObject> result = new ArrayList<>(); if (model.getSelection()) { result.add(from(model, false)); } for (TagModel child : model.getChildren()) { result.addAll(activeTagList(child)); } return result; }
Source:
private void setAllListModelsUnavailable() { for (ListModel m : getItems()) { // Don't mark plugin models as unavailable, the plug-ins themselves will hide/show the tabs. if (!(m instanceof PluginModel)) { START m.setIsAvailable(false); END } } } Another way to do this would be to override setIsAvailable in PluginModel to be no-op. (This would allow us to get rid of the instanceof check here.)

Target:
private void setAllListModelsUnavailable() { for (ListModel m : getItems()) { m.setIsAvailable(false); } }
Source:
protected void executeVmCommand() { resourceManager.getVmManager(getVmId()).getStatistics().setMigrationProgressPercent(0); try { setSucceeded(initVdss() && perform()); } catch (Exception e) { setSucceeded(false); } START END if (!getSucceeded()) { cleanupPassthroughVnics(getDestinationVdsId()); } } please wait until it's done there. I don't believe we can remove this trycatch.

Target:
protected void executeVmCommand() { getVmManager().getStatistics().setMigrationProgressPercent(0); try { setSucceeded(initVdss() && perform()); } catch (Exception e) { setSucceeded(false); } if (!getSucceeded()) { cleanupPassthroughVnics(getDestinationVdsId()); } }
Source:
protected boolean validate() { return isNoLeasesOnStorageDomain() && canDetachStorageDomainWithVmsAndDisks(getStorageDomain()) && canDetachDomain(getParameters().getDestroyingPool(), START getParameters().getRemoveLast()); END } please move the check to be after canDetachDomain() which validates that the domain exists. We'll need to move also canDetachStorageDomainWithVmsAndDisks() in a separate patch.

Target:
protected boolean validate() { return canDetachStorageDomainWithVmsAndDisks(getStorageDomain()) && canDetachDomain(getParameters().getDestroyingPool(), getParameters().getRemoveLast()) && isNoLeasesOnStorageDomain(); }
Source:
public int compare(Nameable nameable1, Nameable nameable2) { final String name1 = nameable1.getName(); final String name2 = nameable2.getName(); final NumericSuffixNormalizer START numericSuffixNormalizer = END new NumericSuffixNormalizer(); final List<String> normalizedNames = numericSuffixNormalizer.normalize(name1, name2); return ObjectUtils.compare(normalizedNames.get(0), normalizedNames.get(1)); } extract to field; we do not need N creations of this when lets say sorting collection.

Target:
public int compare(Nameable nameable1, Nameable nameable2) { final String name1 = nameable1.getName(); final String name2 = nameable2.getName(); final List<String> normalizedNames = numericSuffixNormalizer.normalize(name1, name2); return ObjectUtils.compare(normalizedNames.get(0), normalizedNames.get(1)); }
Source:
protected void initEffectiveCompatibilityVersion() { Version effectiveCompatibilityVersion = VmPropertiesUtils.getInstance().getSupportedClusterLevels().contains(getParameters().getVmStaticData().getCustomCompatibilityVersion()) ? CompatibilityVersionUtils.getEffective(getParameters().getVmStaticData(), this::getCluster) : CompatibilityVersionUtils.getEffective(this::getCluster); // The effective Compatibility Version will be taken from Cluster START setEffectiveCompatibilityVersion(effectiveCompatibilityVersion); END } I don't think that's not the right place for this. I see two options: 1. to validate the custom-compatibility version in CompatibilityVersionUtils#getEffective instead. 2. not to validate it at this point, set what could be an incorrect value, and rely on the validation in te 'validate' method. I would go with #2 - there's no point in validating something just to put another value (which is also incorrect - if I asked for a VM with CCV 5.7, I expect to get this compatibility or an error if that's invalid).

Target:
protected void initEffectiveCompatibilityVersion() { setEffectiveCompatibilityVersion( CompatibilityVersionUtils.getEffective(getParameters().getVmStaticData(), this::getCluster)); }
Source:
protected boolean validateLeaseStorageDomain(Guid leaseStorageDomainId) { StorageDomain domain = storageDomainDao.getForStoragePool(leaseStorageDomainId, getStoragePoolId()); StorageDomainValidator validator = new StorageDomainValidator(domain); if (!validate(validator.isDomainExistAndActive()) || !validate(validator.isDataDomain())) { return false; } START return true; END } consider change to return validate(validator.isDomainExistAndActive()) && validate(validator.isDataDomain())

Target:
protected boolean validateLeaseStorageDomain(Guid leaseStorageDomainId) { StorageDomain domain = storageDomainDao.getForStoragePool(leaseStorageDomainId, getStoragePoolId()); StorageDomainValidator validator = new StorageDomainValidator(domain); return (validate(validator.isDomainExistAndActive()) && validate(validator.isDataDomain())); }
Source:
START public List<GraphicsDevice> END getPrevDevices() { return prevDevices; } protected?

Target:
protected List<GraphicsDevice> getPrevDevices() { return prevDevices; }