auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void initSelectedSpiceImpl() { SpiceConsoleModel spiceModel = model.getVmConsoles().getConsoleModel(SpiceConsoleModel.class); if (spiceModel == null) { return; } START spiceModel.initConsole(); spiceModel.initConsole(); END } this needs to be called twice for it to be properly done, right?

Target:
private void initSelectedSpiceImpl() { SpiceConsoleModel spiceModel = model.getVmConsoles().getConsoleModel(SpiceConsoleModel.class); if (spiceModel == null) { return; } spiceModel.initConsole(); }
Source:
private String calculateHref(Object tab) { String href = "#"; //$NON-NLS-1$ if (tab instanceof AbstractTab) { href = ((AbstractTab)tab).getTargetHistoryToken(); } START else if (tab instanceof GroupedTabData) { END href = ((GroupedTabData)tab).getHistoryToken(); } return href; } I would just make 2 calculateHrefs, one that takes Tab and one that takes GroupedTabData. Or convert the GroupedTabData into a Tab somehow. Passing in Object seems wrong.

Target:
private String calculateHref(Object tab) { String href = "#"; //$NON-NLS-1$ if (tab instanceof AbstractTab) { href = ((AbstractTab)tab).getTargetHistoryToken(); } return href; }
Source:
protected void updateNetworks(Collection<Network> networks) { VnicProfile profile = getProfile(); START if (profile != null) { END Network selected = networks.stream() .filter(net -> Objects.equals(profile.getNetworkId(), net.getId())) .findFirst().get(); getNetwork().setSelectedItem(selected); getNetwork().setIsChangeable(false); } } I would change it to 'if (profile != null && profile.getNetworkId() != null)'. It is more explicit.

Target:
protected void updateNetworks(Collection<Network> networks) { VnicProfile profile = getProfile(); if (profile != null && profile.getNetworkId() != null) { Network selected = networks.stream() .filter(net -> Objects.equals(profile.getNetworkId(), net.getId())) .findFirst().get(); getNetwork().setSelectedItem(selected); getNetwork().setIsChangeable(false); } }
Source:
public DynamicUrlContentTabView() { initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); START frame.addLoadHandler((e) -> { resizeFrame(); }); END Window.addResizeHandler((e) -> { resizeFrame(); }); } No need for ( ) on a single parameter. frame.addLoadHandler(e -> resizeFrame()); will work

Target:
public DynamicUrlContentTabView() { initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); frame.addLoadHandler(e -> { resizeFrame(); }); Window.addResizeHandler(e -> { resizeFrame(); }); }
Source:
START public boolean isVmRunningOnSpm() { return this.spmId.equals(this.runningVdsId); } END I'd lose the "this." notation. Also, shouldn't this be annotated so it's not serialized?

Target:
public boolean isVmRunningOnSpm() { return spmId.equals(this.runningVdsId); }
Source:
public void triggerNow() { if (updateTimerJob != null) { try { updateTimerJob.cancel(true); } catch (Throwable t) { START log.debug("Exception cancelling existing job: {}", ExceptionUtils.getRootCauseMessage(t)); END } } updateTimerJob = schedulerService.scheduleWithFixedDelay(this::ovfUpdate, 0, Config.<Integer> getValue(ConfigValues.OvfUpdateIntervalInMinutes), TimeUnit.MINUTES); } I'm not sure if it will be alright or not in this case to have that task running simultaneously by different threads

Target:
public void triggerNow() { if (updateTimerJob != null) { try { updateTimerJob.cancel(false); } catch (Throwable t) { log.debug("Exception cancelling existing job: {}", ExceptionUtils.getRootCauseMessage(t)); } } updateTimerJob = schedulerService.scheduleWithFixedDelay(this::ovfUpdate, 0, Config.<Integer> getValue(ConfigValues.OvfUpdateIntervalInMinutes), TimeUnit.MINUTES); }
Source:
public ClusterFeatures list() { ClusterFeatures features = new ClusterFeatures(); Set<SupportedAdditionalClusterFeature> addlFeatures = getOptionalEntity(Set.class, QueryType.GetClusterFeaturesByClusterId, new IdQueryParameters(asGuid(clusterId)), clusterId, false); if (addlFeatures != null) { for (SupportedAdditionalClusterFeature entity : addlFeatures) { if (entity.isEnabled()) { START features.getClusterFeatures().add(addLinks(ClusterFeaturesMapper.map(entity.getFeature(), END null))); } } } return features; } You can use just "map" here.

Target:
public ClusterFeatures list() { ClusterFeatures features = new ClusterFeatures(); Set<SupportedAdditionalClusterFeature> addlFeatures = getOptionalEntity(Set.class, QueryType.GetClusterFeaturesByClusterId, new IdQueryParameters(asGuid(clusterId)), clusterId, false); if (addlFeatures != null) { for (SupportedAdditionalClusterFeature entity : addlFeatures) { if (entity.isEnabled()) { features.getClusterFeatures().add(addLinks(map(entity.getFeature(), null))); } } } return features; }
Source:
private Anchor createConfigureMenuItem(String title, String id) { Anchor itemAnchor; START itemAnchor = configureLink; END Span titleSpan = new Span(); titleSpan.addStyleName(PatternflyStyles.LIST_GROUP_ITEM_VALUE); titleSpan.setText(title); itemAnchor.add(titleSpan); itemAnchor.setId(id); itemAnchor.addClickHandler(e -> { e.preventDefault(); }); return itemAnchor; } those can be the same line

Target:
private Anchor createConfigureMenuItem(String title, String id) { Anchor itemAnchor = configureLink; Span titleSpan = new Span(); titleSpan.addStyleName(PatternflyStyles.LIST_GROUP_ITEM_VALUE); titleSpan.setText(title); itemAnchor.add(titleSpan); itemAnchor.setId(id); itemAnchor.addClickHandler(e -> { e.preventDefault(); }); return itemAnchor; }
Source:
public SubTabNetworkVmView(SearchableDetailModelProvider<PairQueryable<VmNetworkInterface, VM>, NetworkListModel, NetworkVmListModel> modelProvider) { super(modelProvider); viewRadioGroup = new ViewRadioGroup<>(Arrays.asList(NetworkVmFilter.values())); viewRadioGroup.setSelectedValue(NetworkVmFilter.running); START viewRadioGroup.addChangeHandler(selected -> { END onRadioButtonChange(selected); }); initTable(); initWidget(getTableContainer()); } viewRadioGroup.addChangeHandler(selected -> onRadioButtonChange(selected));

Target:
public SubTabNetworkVmView(SearchableDetailModelProvider<PairQueryable<VmNetworkInterface, VM>, NetworkListModel, NetworkVmListModel> modelProvider) { super(modelProvider); viewRadioGroup = new ViewRadioGroup<>(Arrays.asList(NetworkVmFilter.values())); viewRadioGroup.setSelectedValue(NetworkVmFilter.running); viewRadioGroup.addChangeHandler(selected -> onRadioButtonChange(selected)); initTable(); initWidget(getTableContainer()); }
Source:
public Response remove() { Provider provider = BackendExternalProviderHelper.getProvider(this, id); ProviderParameters parameters = new ProviderParameters(provider); START parameters.setForce(isForce()); END return performAction(ActionType.RemoveProvider, parameters); } Can we add this to the ctor please?

Target:
public Response remove() { Provider provider = BackendExternalProviderHelper.getProvider(this, id); ProviderParameters parameters = new ProviderParameters(provider, isForce()); return performAction(ActionType.RemoveProvider, parameters); }
Source:
public DisksViewRadioGroup() { FlowPanel panel = new FlowPanel(); Label label = new Label(); label.setText(constants.diskType() + ":"); //$NON-NLS-1$ label.addStyleName("disk-storage-type-group-label"); //$NON-NLS-1$ START panel.add(label); END panel.add(getRadioGroupPanel()); initWidget(panel); } You can move all of this into getRadioGroupPanel, and return the FlowPanel. Or you can also do what I explained in the DiskContentRadioGroup and extend FlowPanel and simplify a bunch of this stuff.

Target:
public DisksViewRadioGroup() { Label label = new Label(); label.setText(constants.diskType() + ":"); //$NON-NLS-1$ label.addStyleName("disk-storage-type-group-label"); //$NON-NLS-1$ add(label); add(getRadioGroupPanel()); }
Source:
protected void onBind() { Event<EventArgs> entityChangedEvent = getModel().getDiskViewType().getEntityChangedEvent(); entityChangedEvent.addListener(getView().getDiskTypeChangedEventListener()); Event<EventArgs> diskContentTypeEntityChangedEvent = getModel().getDiskContentType().getEntityChangedEvent(); diskContentTypeEntityChangedEvent.addListener(getView().getDiskContentTypeChangedEventListener()); START super.onBind(); END } why not call onBind first (i.e. in line 83)? do we conflict with something?

Target:
protected void onBind() { super.onBind(); Event<EventArgs> entityChangedEvent = getModel().getDiskViewType().getEntityChangedEvent(); entityChangedEvent.addListener(getView().getDiskTypeChangedEventListener()); Event<EventArgs> diskContentTypeEntityChangedEvent = getModel().getDiskContentType().getEntityChangedEvent(); diskContentTypeEntityChangedEvent.addListener(getView().getDiskContentTypeChangedEventListener()); }
Source:
public static Image map(RepoImage entity, Image template) { Image model = template != null ? template : new Image(); model.setId(entity.getRepoImageId()); model.setName(entity.getRepoImageName()); START if (entity.getSize() != null) { END model.setSize(entity.getSize()); } model.setFileType(map(entity.getFileType(), null)); return model; } Can you please rebase your patch on top of https://gerrit.ovirt.org/#/c/80693 ? Once you do this, the null check will become redundant.

Target:
public static Image map(RepoImage entity, Image template) { Image model = template != null ? template : new Image(); model.setId(entity.getRepoImageId()); model.setName(entity.getRepoImageName()); model.setSize(entity.getSize()); model.setFileType(map(entity.getFileType(), null)); return model; }
Source:
public static ImageFileType map(org.ovirt.engine.core.common.businessentities.storage.ImageFileType imageFileType, ImageFileType template) { switch (imageFileType) { case Unknown: return ImageFileType.UNKNOWN; case ISO: return ImageFileType.ISO; case Floppy: return ImageFileType.FLOPPY; case Disk: return ImageFileType.DISK; case All: return ImageFileType.ALL; START default: return null; END } } I wonder if it doesn't make more sense to default to Unknown?

Target:
public static ImageFileType map(org.ovirt.engine.core.common.businessentities.storage.ImageFileType imageFileType, ImageFileType template) { switch (imageFileType) { case ISO: return ImageFileType.ISO; case Floppy: return ImageFileType.FLOPPY; case Disk: return ImageFileType.DISK; case All: return ImageFileType.ALL; default: return ImageFileType.UNKNOWN; } }
Source:
public OvirtBreadCrumbsView(MainModelProvider<T, M> listModelProvider, MenuDetailsProvider menuDetailsProvider) { this.menuDetailsProvider = menuDetailsProvider; START initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); END this.listModelProvider = listModelProvider; } Nit-pick: for consistency, please move this.xx = xx; declarations at the top, followed by any actual logic, like the initWidget() call.

Target:
public OvirtBreadCrumbsView(MainModelProvider<T, M> listModelProvider, MenuDetailsProvider menuDetailsProvider) { this.menuDetailsProvider = menuDetailsProvider; this.listModelProvider = listModelProvider; initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); }
Source:
private List<DiskImage> manualAggregateSnapshots() { START DiskImage diskWithSnaps = diskWithSnapshots; END diskWithSnaps.getSnapshots().addAll(snapshotsList); return Arrays.asList(diskWithSnapshots, diskWithoutSnapshots, ovfImage, cinderDisk); } Do we need this?

Target:
private List<DiskImage> manualAggregateSnapshots() { diskWithSnapshots.getSnapshots().addAll(snapshotsList); return Arrays.asList(diskWithSnapshots, diskWithoutSnapshots, ovfImage, cinderDisk); }
Source:
private void assertAllDisksAreActive(Collection<Disk> disks) { for (Disk disk : disks){ if (disk instanceof LunDisk){ continue; } DiskImage diskImage = DiskImage.class.cast(disk); assertTrue("disk should be active", START diskImage.getActive()); END } } getActive is exposed via the Disk interface, so you could lose the cast.

Target:
private void assertAllDisksAreActive(Collection<Disk> disks) { for (Disk disk : disks){ if (disk instanceof LunDisk){ continue; } DiskImage diskImage = (DiskImage) disk; assertTrue("disk should be active", diskImage.getActive()); } }
Source:
START private void initAlerts() { END hostOptionChangeAlert = new AlertWithIcon(AlertType.INFO, constants.hostOptionChangeInfo(), PatternflyConstants.PFICON_INFO); } don't need this if you don't use provided=true

Target:
private void initAlerts() { hostOptionChangeAlert = new AlertWithIcon(AlertType.INFO); }
Source:
public ColumnResizeHandler(Element headerElement, Column<T, ?> column, HasResizableColumns<T> table) { this.headerElement = headerElement; this.column = column; this.table = table; this.eventHandler = Event.addNativePreviewHandler(this); START columnAbsoluteLeft = END headerElement.getAbsoluteLeft(); // Indicate resize start table.onResizeStart(column, headerElement); } this.columnAbsoluteLeft for consistency.

Target:
public ColumnResizeHandler(Element headerElement, Column<T, ?> column, HasResizableColumns<T> table) { this.headerElement = headerElement; this.column = column; this.table = table; this.eventHandler = Event.addNativePreviewHandler(this); this.columnAbsoluteLeft = headerElement.getAbsoluteLeft(); // Indicate resize start table.onResizeStart(column, headerElement); }
Source:
public void testGetAllFromDisksIncludingSnapshotsByDiskId() { List<Disk> result = dao.getAllFromDisksIncludingSnapshotsByDiskId(FixturesTool.IMAGE_GROUP_ID, null, false); START List<Disk> sameImageIdDisks = result.stream().filter(disk -> disk.getId().equals(FixturesTool.IMAGE_GROUP_ID)).collect( Collectors.toList()); assertEquals("wrong number of returned disks", 4, sameImageIdDisks.size()); END } Why do you need the filtering here?

Target:
public void testGetAllFromDisksIncludingSnapshotsByDiskId() { List<Disk> result = dao.getAllFromDisksIncludingSnapshotsByDiskId(FixturesTool.IMAGE_GROUP_ID, null, false); assertEquals("wrong number of returned disks", 4, result.size()); }
Source:
public int compareTo(UnregisteredDiskId o) { int idComparison = diskId.compareTo(o.diskId); if (idComparison == 0) { return storageDomainId.compareTo(o.storageDomainId); } START else { END return idComparison; } } I would drop the else here.

Target:
public int compareTo(UnregisteredDiskId o) { int idComparison = diskId.compareTo(o.diskId); if (idComparison == 0) { return storageDomainId.compareTo(o.storageDomainId); } return idComparison; }
Source:
public ImageTicketInformationReturn(Map<String, Object> innerMap) { super(innerMap); START this.ticketInfo END = (Map<String, Object>) innerMap.get(TICKET_INFO); } not need for 'this'

Target:
public ImageTicketInformationReturn(Map<String, Object> innerMap) { super(innerMap); ticketInfo = (Map<String, Object>) innerMap.get(TICKET_INFO); }
Source:
private boolean validateDiskOnBackupDomain(StorageDomainValidator storageDomainValidator) { START if (!validate(storageDomainValidator.isBackupStorageDomainUpdatedWithRunningVm())) { return false; } return true; END } just return validate(storageDomainValidator.isBackupStorageDomainUpdatedWithRunningVm());

Target:
private boolean validateDiskOnBackupDomain(StorageDomainValidator storageDomainValidator) { return validate(storageDomainValidator.isBackupStorageDomainUpdatedWithRunningVm()); }
Source:
public int getMaxMaxMemorySize(Integer osId, Version compatVersion) { START String usedVersion = (compatVersion != null) ? compatVersion.getValue() : Version.getLast().getValue(); END if (osId == null) { return getMaxMaxMemoryForAllOss(usedVersion); } final ConfigValues maxMaxMemoryConfigValue = getMaxMaxMemoryConfigValue(osId); return (Integer) getConfigValuePreConverted(maxMaxMemoryConfigValue, usedVersion); } Please remove unnecessary brackets: String usedVersion = (compatVersion != null) ? compatVersion.getValue() : Version.getLast().getValue();

Target:
public int getMaxMaxMemorySize(Integer osId, Version compatVersion) { String usedVersion = compatVersion != null ? compatVersion.getValue() : Version.getLast().getValue(); if (osId == null) { return getMaxMaxMemoryForAllOss(usedVersion); } final ConfigValues maxMaxMemoryConfigValue = getMaxMaxMemoryConfigValue(osId); return (Integer) getConfigValuePreConverted(maxMaxMemoryConfigValue, usedVersion); }
Source:
public String getOvnCentralByClusterId(Guid clusterId) { List<Network> clusterNetworks = networkDao.getAllForCluster(clusterId); for (Provider provider : providerDao.getAllByTypes(ProviderType.EXTERNAL_NETWORK)) { for (Network network : clusterNetworks) { ProviderNetwork providerNetwork = network.getProvidedBy(); if ((providerNetwork != null) START && (providerNetwork.getProviderId().equals(provider.getId()))) { END return NetworkUtils.getIpAddress(provider.getUrl()); } } } return null; } Please remove unneeded parenthesis: if (providerNetwork != null && providerNetwork.getProviderId().equals(provider.getId())) {

Target:
public String getOvnCentralByClusterId(Guid clusterId) { List<Network> clusterNetworks = networkDao.getAllForCluster(clusterId); for (Provider provider : providerDao.getAllByTypes(ProviderType.EXTERNAL_NETWORK)) { for (Network network : clusterNetworks) { ProviderNetwork providerNetwork = network.getProvidedBy(); if (providerNetwork != null && (providerNetwork.getProviderId().equals(provider.getId()))) { return NetworkUtils.getIpAddress(provider.getUrl()); } } } return null; }
Source:
public String getOvnCentralByClusterId(Guid clusterId) { List<Network> clusterNetworks = networkDao.getAllForCluster(clusterId); for (Provider provider : providerDao.getAllByTypes(ProviderType.EXTERNAL_NETWORK)) { for (Network network : clusterNetworks) { ProviderNetwork providerNetwork = network.getProvidedBy(); if (providerNetwork != null START && (providerNetwork.getProviderId().equals(provider.getId()))) { END return NetworkUtils.getIpAddress(provider.getUrl()); } } } return null; } Still one unnecessary :-) if (providerNetwork != null && providerNetwork.getProviderId().equals(provider.getId())) {

Target:
public String getOvnCentralByClusterId(Guid clusterId) { List<Network> clusterNetworks = networkDao.getAllForCluster(clusterId); for (Provider provider : providerDao.getAllByTypes(ProviderType.EXTERNAL_NETWORK)) { for (Network network : clusterNetworks) { ProviderNetwork providerNetwork = network.getProvidedBy(); if (providerNetwork != null && providerNetwork.getProviderId().equals(provider.getId())) { return NetworkUtils.getIpAddress(provider.getUrl()); } } } return null; }
Source:
public CloudInitHandler(VmInit vmInit) { this.vmInit = vmInit; metaData = new HashMap<>(); userData = new HashMap<>(); files = new HashMap<>(); nextFileIndex = 0; START this.sourceProtocol = NetConfigSourceProtocol.OPENSTACK_METADATA; END } do we know since when openstack metadata is supported? I'm concerned of a scenario where customers have old templates installed with version of cloud init that doesn't support it

Target:
public CloudInitHandler(VmInit vmInit) { this(vmInit, NetConfigSourceProtocol.OPENSTACK_METADATA); }
Source:
public void testDefaultRouteWhenOutOfSyncOnOlderCluster() { cluster.setCompatibilityVersion(Version.v4_1); network.setDnsResolverConfiguration(sampleDnsResolverConfiguration); assertThat(createTestedInstance(true, sampleDnsResolverConfiguration).isNetworkInSync(), START is(false)); END } Shouldn't it be 'true'? I know this test passes, but I don't understand why. What do I miss? Didn't you change the code so if default route is not supported, then network is considered in sync regardless of any further conditions?

Target:
public void testDefaultRouteWhenOutOfSyncOnOlderCluster() { cluster.setCompatibilityVersion(Version.v4_1); network.setDnsResolverConfiguration(sampleDnsResolverConfiguration); assertThat(createTestedInstance(true, sampleDnsResolverConfiguration).isNetworkInSync(), is(true)); }
Source:
START private TryBackToAllSnapshotsOfVmParameters(Guid END vmId, Guid dstSnapshotId, boolean restoreMemory) { this(vmId, dstSnapshotId); this.restoreMemory = restoreMemory; } why? If this ctor isn't called publicly it can (should?) just be inlined, but this isn't the scope of **this** patch. Let's do it in a separate one please

Target:
public TryBackToAllSnapshotsOfVmParameters(Guid vmId, Guid dstSnapshotId, boolean restoreMemory) { this(vmId, dstSnapshotId); this.restoreMemory = restoreMemory; }
Source:
START protected BackendSystemOptionResource(String END id) { this.id = id; } Why protected?

Target:
public BackendSystemOptionResource(String id) { this.id = id; }
Source:
private String readPid() throws IOException { @SuppressWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") Path pidFile = Paths.get(PID_FILE); START return (new String(Files.readAllBytes(pidFile))).trim(); END } You are not closing files at all, please use try with resources: private String readLine(String filename) { String pid; try (BufferedReader br = new BufferedReader(new FileReader(filename))) { pid = br.readLine(); } catch (IOException ex) { log.error("Error reading file '{}': {}, filename, ex.getMessage()); log.debug("Exception", ex); pid = null; } return pid; }

Target:
private String readPid() throws IOException { Path pidFile = Paths.get(PID_FILE); return (new String(Files.readAllBytes(pidFile))).trim(); }
Source:
START static Set<Guid> END mapDisks(DiskAttachments diskAttachments) { Set<Guid> diskIds = null; if (diskAttachments.isSetDiskAttachments()) { diskIds = mapDisksToSetOfGuids(diskAttachments.getDiskAttachments().stream() .map(DiskAttachment::getDisk)); } return diskIds; } public?

Target:
public static Set<Guid> mapDisks(DiskAttachments diskAttachments) { Set<Guid> diskIds = null; if (diskAttachments.isSetDiskAttachments()) { diskIds = mapDisksToSetOfGuids(diskAttachments.getDiskAttachments().stream() .map(DiskAttachment::getDisk)); } return diskIds; }
Source:
public String render(Number number) { if (number != null) { NumberFormat format = NumberFormat.getDecimalFormat(); return format.format(number); } else { START return null; END } } A renderer should always return some meaningful text. If the number value is null, we would normally return CommonApplicationConstants.unAvailablePropertyLabel() or an empty string, depending on UI expectations. Anyway, we already have a class that covers above and can be used here: NullableNumberRenderer class RxTxTotalRenderer extends NullableNumberRenderer { public RxTxTotalRenderer() { super(NumberFormat.getDecimalFormat()); } }

Target:
public String render(Number number) { if (number != null) { NumberFormat format = NumberFormat.getDecimalFormat(); return format.format(number); } else { return ""; //$NON-NLS-1$ } }
Source:
private void initLabelsToNetworks() { for (Network network : clusterNetworks) { START if (network != null) { END labelToNetworks.computeIfAbsent(network.getLabel(), k -> new ArrayList<>()).add(network); } } } The network cannot be null in this case, the problem was the label was null. Besides this +2.

Target:
private void initLabelsToNetworks() { for (Network network : clusterNetworks) { labelToNetworks.computeIfAbsent(network.getLabel(), k -> new ArrayList<>()).add(network); } }
Source:
protected void executeCommand() { StoragePoolParametersBase parameters = new StoragePoolParametersBase(getStoragePoolId()); ActionReturnValue actionReturnValue = runInternalAction(ActionType.ProcessOvfUpdateForStoragePool, parameters, getContext()); START HashSet<Guid> END proccessedDomains = actionReturnValue.getActionReturnValue(); if (!proccessedDomains.isEmpty()) { runInternalActionWithTasksContext(ActionType.ProcessOvfUpdateForStorageDomain, createProcessOvfUpdateForDomainParams()); } setSucceeded(true); } Please use Set instead of the concrete implementation

Target:
protected void executeCommand() { StoragePoolParametersBase parameters = new StoragePoolParametersBase(getStoragePoolId()); ActionReturnValue actionReturnValue = runInternalAction(ActionType.ProcessOvfUpdateForStoragePool, parameters, getContext()); Set<Guid> proccessedDomains = actionReturnValue.getActionReturnValue(); if (!proccessedDomains.isEmpty()) { runInternalActionWithTasksContext(ActionType.ProcessOvfUpdateForStorageDomain, createProcessOvfUpdateForDomainParams()); } setSucceeded(true); }
Source:
public AuditLogType getAuditLogTypeValue() { switch (getActionState()) { case END_FAILURE: return START getSucceeded() END ? AuditLogType.UNASSIGNED: AuditLogType.USER_DEACTIVATE_STORAGE_DOMAIN_FAILED; default: return AuditLogType.UNASSIGNED; } } Hoe can getSucceeded() be true if the command ended with failure?

Target:
public AuditLogType getAuditLogTypeValue() { return AuditLogType.UNASSIGNED; }
Source:
public void addMainContentView(String label, String historyToken, String contentUrl, int priority, boolean defaultPlace) { menuPresenterWidget.addMenuItem(priority, label, historyToken); // Not interested in the actual proxy, it will register itself. dynamicUrlContentProxyFactory.create(historyToken, contentUrl); if (defaultPlace && START placeManager instanceof WebAdminPlaceManager) { END ((WebAdminPlaceManager) placeManager).setDefaultPlace(historyToken); } } UI plugin infra is WebAdmin-specific, no need for this instanceof check, it will always be true. Just typecast like you do below. Or, if you prefer, inject WebAdminPlaceManager instead of PlaceManager interface. Up to you.

Target:
public void addMainContentView(String label, String historyToken, String contentUrl, int priority, boolean defaultPlace) { menuPresenterWidget.addMenuItem(priority, label, historyToken); // Not interested in the actual proxy, it will register itself. dynamicUrlContentProxyFactory.create(historyToken, contentUrl); placeManager.setDefaultPlace(historyToken); }
Source:
private void writeAddress(VmDevice device) { if (!device.getAddress().isEmpty()) { writeAddress(StringMapUtils.string2Map(device.getAddress())); START } END } no need for this part - StringMapUtils#string2Map is supposed to return an empty map for an empty string and so the writeAddress method below won't write anything to the xml

Target:
private void writeAddress(VmDevice device) { writeAddress(StringMapUtils.string2Map(device.getAddress())); }
Source:
protected void setQcowCompatByQemuImageInfo(Guid storagePoolId, Guid newImageGroupId, Guid newImageId, Guid newStorageDomainID, DiskImage diskImage) { // If the VM is running then the volume is already prepared in the guest's host so there // is no need for prepare and teardown. VM vm = vmDao.getVmsWithPlugInfo(diskImage.getId()).stream(). START map(pair -> pair.getFirst()). END findFirst().get(); setQcowCompat(diskImage.getImage(), storagePoolId, newImageGroupId, newImageId, newStorageDomainID, vm.getRunOnVds()); } Where is the check if the disk is plugged?

Target:
protected void setQcowCompatByQemuImageInfo(Guid storagePoolId, Guid newImageGroupId, Guid newImageId, Guid newStorageDomainID, DiskImage diskImage) { // If the VM is running then the volume is already prepared in the guest's host so there // is no need for prepare and teardown. VM vm = vmDao.getVmsWithPlugInfo(diskImage.getId()).stream(). map(Pair::getFirst). findFirst().get(); setQcowCompat(diskImage.getImage(), storagePoolId, newImageGroupId, newImageId, newStorageDomainID, vm.getRunOnVds()); }
Source:
public Status(Map<String, Object> innerMap) { code = (Integer) innerMap.get(CODE); if (innerMap.get(MESSAGE) == null) { message = ""; } else if (innerMap.get(MESSAGE) instanceof Object[]) { message = Arrays.toString((Object[]) START innerMap.get(MESSAGE)); END } else { message = innerMap.get(MESSAGE).toString(); } } if we reached here, that means we've executed 'innerMap.get(MESSAGE)' three times :-) pls extract it to a local variable and replace all its occurrences.

Target:
public Status(Map<String, Object> innerMap) { code = (Integer) innerMap.get(CODE); Object obj = innerMap.get(MESSAGE); if (obj == null) { message = ""; } else if (obj instanceof Object[]) { message = Arrays.toString((Object[]) obj); } else { message = obj.toString(); } }
Source:
protected boolean buildAndCheckDestStorageDomains() { if (diskInfoDestinationMap.isEmpty() && !fillDestMap()) { return false; } else if (!validateProvidedDestinations()) { START return false; END } if (getImagesToCheckDestinationStorageDomains().size() != diskInfoDestinationMap.size()) { log.error("Can not find any default active domain for one of the disks of template with id '{}'", vmDisksSource.getId()); return failValidation(EngineMessage.ACTION_TYPE_FAILED_MISSED_STORAGES_FOR_SOME_DISKS); } return validateIsImagesOnDomains(); } we will check validateProvidedDestinations in case: diskInfoDestinationMap.isEmpty() == true and fillDestMap() == true which is something we didn't do before, but it looks safe to me how about replacing the if-else statement with: if (..) { return false; } if (...) { return false; }

Target:
protected boolean buildAndCheckDestStorageDomains() { if (diskInfoDestinationMap.isEmpty()) { if (!fillDestMap()) { return false; } } else if (!validateProvidedDestinations()) { return false; } if (getImagesToCheckDestinationStorageDomains().size() != diskInfoDestinationMap.size()) { log.error("Can not find any default active domain for one of the disks of template with id '{}'", vmDisksSource.getId()); return failValidation(EngineMessage.ACTION_TYPE_FAILED_MISSED_STORAGES_FOR_SOME_DISKS); } return validateIsImagesOnDomains(); }
Source:
public RegisterTemplateModel() { START super(); END this.externalVnicProfilesPerTargetCluster = new HashMap<>(); } redundant. 'super()' is called anyway if you don't call other ctor explicitly.

Target:
public RegisterTemplateModel() { this.externalVnicProfilesPerTargetCluster = new HashMap<>(); }
Source:
private void createVnicProfileMappingsModel() { updateExternalVnicProfilesPerTargetCluster(); vnicProfileMappingModel = new VnicProfileMappingModel( START RegisterTemplateModel.this, END externalVnicProfilesPerTargetCluster); vnicProfileMappingModel.initialize(); } s/RegisterTemplateModel.this/this

Target:
private void createVnicProfileMappingsModel() { updateExternalVnicProfilesPerTargetCluster(); vnicProfileMappingModel = new VnicProfileMappingModel( this, externalVnicProfilesPerTargetCluster); vnicProfileMappingModel.initialize(); }
Source:
public VmLeaseParameters(Guid storagePoolId, Guid storageDomainId, Guid vmId) { this.storagePoolId = storagePoolId; this.storageDomainId = storageDomainId; this.vmId = vmId; START this.vmName = null; END } Will probably look better to call the new ctr here, and move the initializations to it. i.e.: public VmLeaseParameters(Guid storagePoolId, Guid storageDomainId, Guid vmId) { this(storagePoolId, storageDomainId,vmId, null); } public VmLeaseParameters(Guid storagePoolId, Guid storageDomainId, Guid vmId, String vmName) { this.storagePoolId = storagePoolId; this.storageDomainId = storageDomainId; this.vmId = vmId; this.vmName = vmName; }

Target:
public VmLeaseParameters(Guid storagePoolId, Guid storageDomainId, Guid vmId) { this.storagePoolId = storagePoolId; this.storageDomainId = storageDomainId; this.vmId = vmId; }
Source:
protected void executeCommand() { int missingDiskCount = getMissingDiskCount(); if (missingDiskCount <= 0) { setOvfUpdateStep(OvfUpdateStep.OVF_UPLOAD); START updateOvfStoreContent(); END setSucceeded(failedOvfDisks.isEmpty()); } else { setOvfUpdateStep(OvfUpdateStep.OVF_STORES_CREATION); setSucceeded(createOvfStoreDisks(getMissingDiskCount())); } } I think that the process here is confusing, failedOvfDisks seems to be out of context. Perhaps a better solution would be to have updateOvfStoreContent return boolean value, which will indicate whether the update succeeded or not, same as being done with createOvfStoreDisks

Target:
protected void executeCommand() { int missingDiskCount = getMissingDiskCount(); if (missingDiskCount <= 0) { setOvfUpdateStep(OvfUpdateStep.OVF_UPLOAD); setSucceeded(updateOvfStoreContent()); } else { setOvfUpdateStep(OvfUpdateStep.OVF_STORES_CREATION); setSucceeded(createOvfStoreDisks(getMissingDiskCount())); } }
Source:
START public EntityModel<Integer> getMacsCount() { END return macsCount; } Any particular reason we can't change this to EntityModel<Long> so we don't have to cast the long to an int below?

Target:
public EntityModel<Long> getMacsCount() { return macsCount; }
Source:
private void internalEndSuccessfully() { log.info("Ending command '{}' successfully.", getClass().getName()); boolean clearCompensation = true; START try { END endSuccessfully(); } catch (Exception e) { clearCompensation = false; } finally { if (getCommandCompensationPhase() == CommandCompensationPhase.END_COMMAND) { if (clearCompensation) { getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand(); } else { compensate(); } } } } It appears that we can incorporate this logic better into CommandBase.endActionInTransactionScope() The finally block of that method is: if (TransactionSupport.current() == null) { try { getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand(); } catch (RuntimeException e) { logExceptionAndCompensate(e); } } else { try { if (!exceptionOccurred && TransactionSupport.current().getStatus() == Status.STATUS_ACTIVE) { getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand(); } else { compensate(); } } catch (SystemException e) { logExceptionAndCompensate(e); } }

Target:
private void internalEndSuccessfully() { log.info("Ending command '{}' successfully.", getClass().getName()); endSuccessfully(); }
Source:
public void testExecuteQueryNotSupported() { setup(ExpectedError.NOT_SUPPORTED); getQuery().executeQueryCommand(); Map<String, LldpInfo> returnValue = getQuery().getQueryReturnValue().getReturnValue(); START assertTrue(returnValue == null); END } Please use assertEquals

Target:
public void testExecuteQueryNotSupported() { setup(ExpectedError.NOT_SUPPORTED); getQuery().executeQueryCommand(); Map<String, LldpInfo> returnValue = getQuery().getQueryReturnValue().getReturnValue(); assertEquals(returnValue, null); }
Source:
public HostPoller(TimeBoundPollVDSCommandParameters parameters) { START Objects.requireNonNull(parameters); this.parameters = parameters; END } Why this is splitted in two lines, why not: this.parameters = Objects.requireNonNull(parameters)

Target:
public HostPoller(TimeBoundPollVDSCommandParameters parameters) { this.parameters = Objects.requireNonNull(parameters); }
Source:
public void setGuestCpuType(String value) { START if (!Objects.equals(createdByUser, value)) { END guestCpuType = value; onPropertyChanged(new PropertyChangedEventArgs("GuestCpuType")); //$NON-NLS-1$ } } Should this comparison be !Objects.equals(guestCpuType, value) ?

Target:
public void setGuestCpuType(String value) { if (!Objects.equals(guestCpuType, value)) { guestCpuType = value; onPropertyChanged(new PropertyChangedEventArgs("GuestCpuType")); //$NON-NLS-1$ } }
Source:
private void dataCenter_SelectedItemChanged() { if (getCurrentStorageItem() instanceof SanStorageModelBase) { SanStorageModelBase sanStorageModel = (SanStorageModelBase) getCurrentStorageItem(); sanStorageModel.updateRemovableLuns(getDataCenter().getSelectedItem().getCompatibilityVersion()); START sanStorageModel.getRequireTableRefresh().setEntity(null); END sanStorageModel.getRequireTableRefresh().setEntity(true); } updateItemsAvailability(); behavior.updateDataCenterAlert(); } try removing these lines (371/372), it'd work without

Target:
private void dataCenter_SelectedItemChanged() { if (getCurrentStorageItem() instanceof SanStorageModelBase) { SanStorageModelBase sanStorageModel = (SanStorageModelBase) getCurrentStorageItem(); sanStorageModel.updateRemovableLuns(getDataCenter().getSelectedItem().getCompatibilityVersion()); } updateItemsAvailability(); behavior.updateDataCenterAlert(); }
Source:
public static String mapToJsonUnchecked(Map<String, Object> input) { try { return mapToJson(input); } catch (IOException e) { throw new RuntimeException(String.format("Object \"%s\" cannot be serialized to JSON.", START e)); END } } I think you'd like to print the content of 'input' here and pass the 'e' (exception) as a second argument of the RuntimeExeption c'tor call.

Target:
public static String mapToJsonUnchecked(Map<String, Object> input) { try { return mapToJson(input); } catch (IOException e) { throw new RuntimeException(String.format("Object \"%s\" cannot be serialized to JSON.", input), e); } }
Source:
private List<NetworkCluster> createNetworkAttachments() { List<NetworkCluster> networkAttachments = new ArrayList<>(); START getClustersToAttach().stream().forEach(networkClusterModel END -> { NetworkCluster networkCluster = new NetworkCluster(); networkCluster.setClusterId(networkClusterModel.getEntity().getId()); networkCluster.setRequired(networkClusterModel.isRequired()); networkAttachments.add(networkCluster); }); return networkAttachments; } forEach() is available for Arrays, please remove .stream()

Target:
private List<NetworkCluster> createNetworkAttachments() { List<NetworkCluster> networkAttachments = new ArrayList<>(); getClustersToAttach().forEach(networkClusterModel -> { NetworkCluster networkCluster = new NetworkCluster(); // Network id is added in the backend networkCluster.setClusterId(networkClusterModel.getEntity().getId()); networkCluster.setRequired(networkClusterModel.isRequired()); networkAttachments.add(networkCluster); }); return networkAttachments; }
Source:
public void scheduleJobsForHosts() { START vdsManagersDict.values().stream().forEach(VdsManager::scheduleJobs); END } can be omitted

Target:
public void scheduleJobsForHosts() { vdsManagersDict.values().forEach(VdsManager::scheduleJobs); }
Source:
public PreviewSnapshotModel(VM vm, Guid userSelectedSnapshotId) { this(); START this.vm = END vm; setVmId(vm.getId()); this.userSelectedSnapshotId = userSelectedSnapshotId; } This field is written here but never read, can be removed (Findbugs)

Target:
public PreviewSnapshotModel(VM vm, Guid userSelectedSnapshotId) { this(); setVmId(vm.getId()); }
Source:
public void validateInvalidDestinationDomain() { StorageDomain srcStorageDomain = initStorageDomain(srcStorageId); START srcStorageDomain.setStatus(StorageDomainStatus.Active); END StorageDomain dstStorageDomain = initStorageDomain(dstStorageId); dstStorageDomain.setStorageDomainType(StorageDomainType.ISO); initDiskImage(diskImageGroupId, diskImageId); initVm(VMStatus.Up, Guid.newGuid(), diskImageGroupId); ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_ILLEGAL); } I think that this one can be removed as well :)

Target:
public void validateInvalidDestinationDomain() { StorageDomain srcStorageDomain = initStorageDomain(srcStorageId); StorageDomain dstStorageDomain = initStorageDomain(dstStorageId); dstStorageDomain.setStorageDomainType(StorageDomainType.ISO); initDiskImage(diskImageGroupId, diskImageId); initVm(VMStatus.Up, Guid.newGuid(), diskImageGroupId); ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_TYPE_ILLEGAL); }
Source:
private Vms getVmsFilteredAndSorted() { int max = ParametersHelper.getIntegerParameter(httpHeaders, uriInfo, "max", -1, -1); GetFilteredAndSortedParameters params = new GetFilteredAndSortedParameters(max); String searchConstraint = QueryHelper.getConstraint(httpHeaders, uriInfo, "", modelType); Integer pageNum = QueryHelper.parsePageNum(searchConstraint); START params.setPageNum(pageNum==null ? 1 : pageNum); END return mapCollection(getBackendCollection(QueryType.GetAllVmsFilteredAndSorted, params)); } Why not use specific constructor instead of invoking setter later on existing object? GetFilteredAndSortedParameters params = new GetFilteredAndSortedParameters(max, QueryHelper.parsePageNum( QueryHelper.getConstraint(httpHeaders, uriInfo, "", modelType);));

Target:
private Vms getVmsFilteredAndSorted() { int max = ParametersHelper.getIntegerParameter(httpHeaders, uriInfo, "max", -1, -1); String searchConstraint = QueryHelper.getConstraint(httpHeaders, uriInfo, "", modelType); Integer pageNum = QueryHelper.parsePageNum(searchConstraint); GetFilteredAndSortedParameters params = new GetFilteredAndSortedParameters(max, pageNum==null ? 1 : pageNum); return mapCollection(getBackendCollection(QueryType.GetAllVmsFilteredAndSorted, params)); }
Source:
public static long greatestCommonDivisor(long a, long b) { while (b != 0) { START a = b; END b = a % b; } return a; } Maybe its just me, but this calculation looks wrong, since we are assign a = b, then b = a % b will always be 0, since a = b. Shouldn't it be: long c = b; b = a % b; a = c;

Target:
public static long greatestCommonDivisor(long a, long b) { while (b != 0) { long c = b; b = a % b; a = c; } return a; }
Source:
START protected boolean validate() { END final boolean result = validateImpl(); if (!result && !isInternalExecution() && !getParameters().isRerun()) { logValidationFailed(); } return result; } What do you think about making this method final? Just to be sure that descendants will override the correct method (validateImpl()) instead of validate().

Target:
protected final boolean validate() { final boolean result = validateImpl(); if (!result && !isInternalExecution() && !getParameters().isRerun()) { logValidationFailed(); } return result; }
Source:
public void onResponse(Map<String, Object> response) { try { VDSReturnValue caps = (VDSReturnValue) response.get("result"); START handleRefreshCapabilitiesResponse(vds, END caps); } catch (Throwable t) { onFailure(t); } } there is one change in this patch in the order of execution: Previously, the logged failure in case of thrown exception, would have been the error triggered by `handleRefreshCapabilitiesResponse(vds, caps);` however, with this patch, if there will be another exception from the finally block, that exception will be the one to be logged and we'd might loose the info of the origin exception. Can we make sure that the thrown exception will be logged ?

Target:
public void onResponse(Map<String, Object> response) { VDSReturnValue caps = (VDSReturnValue) response.get("result"); handleRefreshCapabilitiesResponse(vds, caps, false); }
Source:
public void testExecuteQueryCommand() { GetDiskImageByDiskAndImageIdsParameters params = getQueryParameters(); when(params.getDiskId()).thenReturn(diskId); when(params.getImageId()).thenReturn(imageId); when(diskImageDao.getDiskImageByDiskAndImageIds(diskId, imageId)).thenReturn(diskImage); GetDiskImageByDiskAndImageIdsQuery<GetDiskImageByDiskAndImageIdsParameters> query = getQuery(); query.executeQueryCommand(); DiskImage returnDiskImage = query.getQueryReturnValue().getReturnValue(); START assertTrue(returnDiskImage.equals(diskImage)); END } Don't reinvent the wheel, use assertEquals instead.

Target:
public void testExecuteQueryCommand() { GetDiskImageByDiskAndImageIdsParameters params = getQueryParameters(); when(params.getDiskId()).thenReturn(diskId); when(params.getImageId()).thenReturn(imageId); when(diskImageDao.getDiskImageByDiskAndImageIds(diskId, imageId)).thenReturn(diskImage); GetDiskImageByDiskAndImageIdsQuery<GetDiskImageByDiskAndImageIdsParameters> query = getQuery(); query.executeQueryCommand(); DiskImage returnDiskImage = query.getQueryReturnValue().getReturnValue(); assertEquals(returnDiskImage, diskImage); }
Source:
public DiskImage getDiskImageByDiskAndImageIds(Guid diskId, Guid imageId) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() START .addValue("disk_id", diskId) .addValue("image_id", imageId); END return getCallsHandler().executeRead("GetDiskImageByDiskAndImageIds", DiskImageRowMapper.instance, parameterSource); } You should also pass user_id and is_filtered - see example in getAncestor

Target:
public DiskImage getDiskImageByDiskAndImageIds(Guid diskId, Guid imageId) { return getDiskImageByDiskAndImageIds(diskId, imageId, null, false); }
Source:
private Guid findAvailableStorageDomain( Map<Guid, Long> targetDomainsSize, long diskSize, List<Guid> storageIds) { Guid dest = storageIds.stream() START .min(Comparator.comparingLong(targetDomainsSize::get)) END .orElse(storageIds.get(0)); long destSize = targetDomainsSize.get(dest); targetDomainsSize.put(dest, destSize - diskSize); return dest; } shouldn't it be 'max'?

Target:
private Guid findAvailableStorageDomain( Map<Guid, Long> targetDomainsSize, long diskSize, List<Guid> storageIds) { Guid dest = storageIds.stream() .max(Comparator.comparingLong(targetDomainsSize::get)) .orElse(storageIds.get(0)); long destSize = targetDomainsSize.get(dest); targetDomainsSize.put(dest, destSize - diskSize); return dest; }
Source:
public MenuPresenterWidget(EventBus eventBus, MenuPresenterWidget.ViewDef view, Provider<ConfigurePopupPresenterWidget> configurePopupProvider) { super(eventBus, view); this.configurePopupProvider = configurePopupProvider; START for (int i = 0; i < PrimaryMenuContainerType.values().length; i++) { END menuContainers.add(PrimaryMenuContainerType.values()[i].getId()); } // Add null for events which is not a container, but we need to keep the indexes in sync. menuContainers.add(null); } Personally I prefer for (PrimaryMenuContainerType type : PrimaryMenuContainerType.values()) { menuContainers.add(type.getId()); } but I'm OK with existing loop, not a big deal.

Target:
public MenuPresenterWidget(EventBus eventBus, MenuPresenterWidget.ViewDef view, Provider<ConfigurePopupPresenterWidget> configurePopupProvider) { super(eventBus, view); this.configurePopupProvider = configurePopupProvider; for (PrimaryMenuContainerType type: PrimaryMenuContainerType.values()) { menuContainers.add(type.getId()); } // Add null for events which is not a container, but we need to keep the indexes in sync. menuContainers.add(null); }
Source:
private Collection<Snapshot> getSnapshotsToBeExportedWithMemory() { if (getParameters().getCopyCollapse()) { Snapshot activeSnapshot = snapshotDao.get(getVmId(), SnapshotType.ACTIVE); return activeSnapshot.containsMemory() ? Collections.singleton(activeSnapshot) : Collections.emptyList(); } else { return START snapshotDao.getAll(getVmId()).stream().filter(s -> s.containsMemory()).collect(Collectors.toList()); END } } Style: Snapshot::containsMemory

Target:
private Collection<Snapshot> getSnapshotsToBeExportedWithMemory() { if (getParameters().getCopyCollapse()) { Snapshot activeSnapshot = snapshotDao.get(getVmId(), SnapshotType.ACTIVE); return activeSnapshot.containsMemory() ? Collections.singleton(activeSnapshot) : Collections.emptyList(); } else { return snapshotDao.getAll(getVmId()).stream().filter(Snapshot::containsMemory).collect(Collectors.toList()); } }
Source:
protected void executeCommand() { registerRollbackHandler((TransactionRollbackListener)() -> START TransactionSupport.executeInNewTransaction( END (TransactionMethod<Void>) () -> { macPoolPerCluster.createPool(oldMacPool); return null; } )); macPoolDao.update(getMacPoolEntity()); macPoolPerCluster.modifyPool(getMacPoolEntity()); setSucceeded(true); getReturnValue().setActionReturnValue(getMacPoolId()); } This is required in AddMacPoolCommand and RemoveMacPoolCommand, too.

Target:
protected void executeCommand() { registerRollbackHandler((TransactionRollbackListener)() -> macPoolPerCluster.modifyPool(oldMacPool)); macPoolDao.update(getMacPoolEntity()); macPoolPerCluster.modifyPool(getMacPoolEntity()); setSucceeded(true); getReturnValue().setActionReturnValue(getMacPoolId()); }
Source:
public String getUsernameWithProfile() { String user = String.format("%s@%s", java.util.Objects.toString(username, ""), START java.util.Objects.toString(profile, "")); END return "@".equals(user) ? "N/A" : user; } Any reason using full class reference instead of importing it and using just a class name afterwards?

Target:
public String getUsernameWithProfile() { String user = String.format("%s@%s", Objects.toString(username, ""), Objects.toString(profile, "")); return "@".equals(user) ? "N/A" : user; }
Source:
public VmDevice() { START alias = alias == null ? "" : alias; END } Why do we need to check for null here?

Target:
public VmDevice() { alias = ""; }
Source:
public Network() { vmNetwork = true; description = ""; START comment = ""; END } Shouldn't we initialize also name here?

Target:
public Network() { vmNetwork = true; name = ""; description = ""; comment = ""; }
Source:
public VdsStatic() { serverSslEnabled = false; vdsStrength = 100; vdsSpmPriority = HOST_DEFAULT_SPM_PRIORITY; sshPort = DEFAULT_SSH_PORT; sshUsername = DEFAULT_SSH_USERNAME; name = ""; comment = START comment == null ? "" : comment; END vdsType = VDSType.VDS; autoRecoverable = true; disablePowerManagementPolicy = false; pmKdumpDetection = true; hostProviderId = null; } Is this intended?

Target:
public VdsStatic() { serverSslEnabled = false; vdsStrength = 100; vdsSpmPriority = HOST_DEFAULT_SPM_PRIORITY; sshPort = DEFAULT_SSH_PORT; sshUsername = DEFAULT_SSH_USERNAME; name = ""; comment = ""; vdsType = VDSType.VDS; autoRecoverable = true; disablePowerManagementPolicy = false; pmKdumpDetection = true; hostProviderId = null; }