auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected boolean validate() { return super.validate() && isImageExist() && checkOperationIsCorrect() && checkOperationAllowedOnDiskContentType() && isImageNotLocked() && isSourceAndDestTheSame() && validateSourceStorageDomain() && validateDestStorage() && checkTemplateInDestStorageDomain() && validateSpaceRequirements() && validateVmSnapshotStatus() && checkCanBeMoveInVm() && checkIfNeedToBeOverride() && setAndValidateDiskProfiles() && validatePassDiscardSupportedForDestinationStorageDomain() && isDiskInBackupDomain(); }

Target:
This validation should be in LiveMigrateVmDisksCommand since in this command we only move disks that their VMs are down (checkCanBeMoveInVm should verify this). LiveMigrateVmDisksCommand is the command that is responsible to move the disks inside a running VM
Source:
protected void logException(RuntimeException ex) { if (ex.getMessage() == null || !ex.getMessage().contains("Policy reset")) { log.error("Command '{}' execution failed: {}", this, ex.getMessage()); log.debug("Exception", ex); } }

Target:
it appears that this change can be reverted.
Source:
private void initSelectedSpiceImpl() { SpiceConsoleModel spiceModel = model.getVmConsoles().getConsoleModel(SpiceConsoleModel.class); if (spiceModel == null) { return; } spiceModel.initConsole(); spiceModel.initConsole(); }

Target:
this needs to be called twice for it to be properly done, right?
Source:
private String calculateHref(Object tab) { String href = "#"; //$NON-NLS-1$ if (tab instanceof AbstractTab) { href = ((AbstractTab)tab).getTargetHistoryToken(); } else if (tab instanceof GroupedTabData) { href = ((GroupedTabData)tab).getHistoryToken(); } return href; }

Target:
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.
Source:
protected void updateNetworks(Collection<Network> networks) { VnicProfile profile = getProfile(); if (profile != null) { Network selected = networks.stream() .filter(net -> Objects.equals(profile.getNetworkId(), net.getId())) .findFirst().get(); getNetwork().setSelectedItem(selected); getNetwork().setIsChangeable(false); } }

Target:
I would change it to 'if (profile != null && profile.getNetworkId() != null)'. It is more explicit.
Source:
public DynamicUrlContentTabView() { initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); frame.addLoadHandler((e) -> { resizeFrame(); }); Window.addResizeHandler((e) -> { resizeFrame(); }); }

Target:
No need for ( ) on a single parameter. frame.addLoadHandler(e -> resizeFrame()); will work
Source:
public boolean isVmRunningOnSpm() { return this.spmId.equals(this.runningVdsId); }

Target:
I'd lose the "this." notation. Also, shouldn't this be annotated so it's not serialized?
Source:
public void triggerNow() { if (updateTimerJob != null) { try { updateTimerJob.cancel(true); } 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); }

Target:
I'm not sure if it will be alright or not in this case to have that task running simultaneously by different threads
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()) { features.getClusterFeatures().add(addLinks(ClusterFeaturesMapper.map(entity.getFeature(), null))); } } } return features; }

Target:
You can use just "map" here.
Source:
private Anchor createConfigureMenuItem(String title, String id) { Anchor itemAnchor; 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; }

Target:
those can be the same line
Source:
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()); }

Target:
viewRadioGroup.addChangeHandler(selected -> onRadioButtonChange(selected));
Source:
public Response remove() { Provider provider = BackendExternalProviderHelper.getProvider(this, id); ProviderParameters parameters = new ProviderParameters(provider); parameters.setForce(isForce()); return performAction(ActionType.RemoveProvider, parameters); }

Target:
Can we add this to the ctor please?
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$ panel.add(label); panel.add(getRadioGroupPanel()); initWidget(panel); }

Target:
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.
Source:
protected void onBind() { Event<EventArgs> entityChangedEvent = getModel().getDiskViewType().getEntityChangedEvent(); entityChangedEvent.addListener(getView().getDiskTypeChangedEventListener()); Event<EventArgs> diskContentTypeEntityChangedEvent = getModel().getDiskContentType().getEntityChangedEvent(); diskContentTypeEntityChangedEvent.addListener(getView().getDiskContentTypeChangedEventListener()); super.onBind(); }

Target:
why not call onBind first (i.e. in line 83)? do we conflict with something?
Source:
public static Image map(RepoImage entity, Image template) { Image model = template != null ? template : new Image(); model.setId(entity.getRepoImageId()); model.setName(entity.getRepoImageName()); if (entity.getSize() != null) { model.setSize(entity.getSize()); } model.setFileType(map(entity.getFileType(), null)); return model; }

Target:
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.
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; default: return null; } }

Target:
I wonder if it doesn't make more sense to default to Unknown?
Source:
public OvirtBreadCrumbsView(MainModelProvider<T, M> listModelProvider, MenuDetailsProvider menuDetailsProvider) { this.menuDetailsProvider = menuDetailsProvider; initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); this.listModelProvider = listModelProvider; }

Target:
Nit-pick: for consistency, please move this.xx = xx; declarations at the top, followed by any actual logic, like the initWidget() call.
Source:
private List<DiskImage> manualAggregateSnapshots() { DiskImage diskWithSnaps = diskWithSnapshots; diskWithSnaps.getSnapshots().addAll(snapshotsList); return Arrays.asList(diskWithSnapshots, diskWithoutSnapshots, ovfImage, cinderDisk); }

Target:
Do we need this?
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", diskImage.getActive()); } }

Target:
getActive is exposed via the Disk interface, so you could lose the cast.
Source:
private void initAlerts() { hostOptionChangeAlert = new AlertWithIcon(AlertType.INFO, constants.hostOptionChangeInfo(), PatternflyConstants.PFICON_INFO); }

Target:
don't need this if you don't use provided=true
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); columnAbsoluteLeft = headerElement.getAbsoluteLeft(); // Indicate resize start table.onResizeStart(column, headerElement); }

Target:
this.columnAbsoluteLeft for consistency.
Source:
public void testGetAllFromDisksIncludingSnapshotsByDiskId() { List<Disk> result = dao.getAllFromDisksIncludingSnapshotsByDiskId(FixturesTool.IMAGE_GROUP_ID, null, false); 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()); }

Target:
Why do you need the filtering here?
Source:
public int compareTo(UnregisteredDiskId o) { int idComparison = diskId.compareTo(o.diskId); if (idComparison == 0) { return storageDomainId.compareTo(o.storageDomainId); } else { return idComparison; } }

Target:
I would drop the else here.
Source:
public ImageTicketInformationReturn(Map<String, Object> innerMap) { super(innerMap); this.ticketInfo = (Map<String, Object>) innerMap.get(TICKET_INFO); }

Target:
not need for 'this'
Source:
private boolean validateDiskOnBackupDomain(StorageDomainValidator storageDomainValidator) { if (!validate(storageDomainValidator.isBackupStorageDomainUpdatedWithRunningVm())) { return false; } return true; }

Target:
just return validate(storageDomainValidator.isBackupStorageDomainUpdatedWithRunningVm());
Source:
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); }

Target:
Please remove unnecessary brackets: String usedVersion = (compatVersion != null) ? compatVersion.getValue() : Version.getLast().getValue();
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) && (providerNetwork.getProviderId().equals(provider.getId()))) { return NetworkUtils.getIpAddress(provider.getUrl()); } } } return null; }

Target:
Please remove unneeded parenthesis: if (providerNetwork != null && providerNetwork.getProviderId().equals(provider.getId())) {
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 && (providerNetwork.getProviderId().equals(provider.getId()))) { return NetworkUtils.getIpAddress(provider.getUrl()); } } } return null; }

Target:
Still one unnecessary :-) if (providerNetwork != null && providerNetwork.getProviderId().equals(provider.getId())) {
Source:
public CloudInitHandler(VmInit vmInit) { this.vmInit = vmInit; metaData = new HashMap<>(); userData = new HashMap<>(); files = new HashMap<>(); nextFileIndex = 0; this.sourceProtocol = NetConfigSourceProtocol.OPENSTACK_METADATA; }

Target:
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
Source:
public void testDefaultRouteWhenOutOfSyncOnOlderCluster() { cluster.setCompatibilityVersion(Version.v4_1); network.setDnsResolverConfiguration(sampleDnsResolverConfiguration); assertThat(createTestedInstance(true, sampleDnsResolverConfiguration).isNetworkInSync(), is(false)); }

Target:
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?
Source:
private TryBackToAllSnapshotsOfVmParameters(Guid vmId, Guid dstSnapshotId, boolean restoreMemory) { this(vmId, dstSnapshotId); this.restoreMemory = restoreMemory; }

Target:
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
Source:
protected BackendSystemOptionResource(String id) { this.id = id; }

Target:
Why protected?
Source:
private String readPid() throws IOException { @SuppressWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME") Path pidFile = Paths.get(PID_FILE); return (new String(Files.readAllBytes(pidFile))).trim(); }

Target:
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; }
Source:
static Set<Guid> mapDisks(DiskAttachments diskAttachments) { Set<Guid> diskIds = null; if (diskAttachments.isSetDiskAttachments()) { diskIds = mapDisksToSetOfGuids(diskAttachments.getDiskAttachments().stream() .map(DiskAttachment::getDisk)); } return diskIds; }

Target:
public?
Source:
public String render(Number number) { if (number != null) { NumberFormat format = NumberFormat.getDecimalFormat(); return format.format(number); } else { return null; } }

Target:
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()); } }
Source:
private void initLabelsToNetworks() { for (Network network : clusterNetworks) { if (network != null) { labelToNetworks.computeIfAbsent(network.getLabel(), k -> new ArrayList<>()).add(network); } } }

Target:
The network cannot be null in this case, the problem was the label was null. Besides this +2.
Source:
protected void executeCommand() { StoragePoolParametersBase parameters = new StoragePoolParametersBase(getStoragePoolId()); ActionReturnValue actionReturnValue = runInternalAction(ActionType.ProcessOvfUpdateForStoragePool, parameters, getContext()); HashSet<Guid> proccessedDomains = actionReturnValue.getActionReturnValue(); if (!proccessedDomains.isEmpty()) { runInternalActionWithTasksContext(ActionType.ProcessOvfUpdateForStorageDomain, createProcessOvfUpdateForDomainParams()); } setSucceeded(true); }

Target:
Please use Set instead of the concrete implementation
Source:
public AuditLogType getAuditLogTypeValue() { switch (getActionState()) { case END_FAILURE: return getSucceeded() ? AuditLogType.UNASSIGNED: AuditLogType.USER_DEACTIVATE_STORAGE_DOMAIN_FAILED; default: return AuditLogType.UNASSIGNED; } }

Target:
Hoe can getSucceeded() be true if the command ended with failure?
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 && placeManager instanceof WebAdminPlaceManager) { ((WebAdminPlaceManager) placeManager).setDefaultPlace(historyToken); } }

Target:
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.
Source:
private void writeAddress(VmDevice device) { if (!device.getAddress().isEmpty()) { writeAddress(StringMapUtils.string2Map(device.getAddress())); } }

Target:
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
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(). map(pair -> pair.getFirst()). findFirst().get(); setQcowCompat(diskImage.getImage(), storagePoolId, newImageGroupId, newImageId, newStorageDomainID, vm.getRunOnVds()); }

Target:
Where is the check if the disk is plugged?
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[]) innerMap.get(MESSAGE)); } else { message = innerMap.get(MESSAGE).toString(); } }

Target:
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.
Source:
protected boolean buildAndCheckDestStorageDomains() { if (diskInfoDestinationMap.isEmpty() && !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(); }

Target:
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; }
Source:
public RegisterTemplateModel() { super(); this.externalVnicProfilesPerTargetCluster = new HashMap<>(); }

Target:
redundant. 'super()' is called anyway if you don't call other ctor explicitly.
Source:
private void createVnicProfileMappingsModel() { updateExternalVnicProfilesPerTargetCluster(); vnicProfileMappingModel = new VnicProfileMappingModel( RegisterTemplateModel.this, externalVnicProfilesPerTargetCluster); vnicProfileMappingModel.initialize(); }

Target:
s/RegisterTemplateModel.this/this
Source:
public VmLeaseParameters(Guid storagePoolId, Guid storageDomainId, Guid vmId) { this.storagePoolId = storagePoolId; this.storageDomainId = storageDomainId; this.vmId = vmId; this.vmName = null; }

Target:
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; }
Source:
protected void executeCommand() { int missingDiskCount = getMissingDiskCount(); if (missingDiskCount <= 0) { setOvfUpdateStep(OvfUpdateStep.OVF_UPLOAD); updateOvfStoreContent(); setSucceeded(failedOvfDisks.isEmpty()); } else { setOvfUpdateStep(OvfUpdateStep.OVF_STORES_CREATION); setSucceeded(createOvfStoreDisks(getMissingDiskCount())); } }

Target:
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
Source:
public EntityModel<Integer> getMacsCount() { return macsCount; }

Target:
Any particular reason we can't change this to EntityModel<Long> so we don't have to cast the long to an int below?
Source:
private void internalEndSuccessfully() { log.info("Ending command '{}' successfully.", getClass().getName()); boolean clearCompensation = true; try { endSuccessfully(); } catch (Exception e) { clearCompensation = false; } finally { if (getCommandCompensationPhase() == CommandCompensationPhase.END_COMMAND) { if (clearCompensation) { getCompensationContext().cleanupCompensationDataAfterSuccessfulCommand(); } else { compensate(); } } } }

Target:
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); } }
Source:
public void testExecuteQueryNotSupported() { setup(ExpectedError.NOT_SUPPORTED); getQuery().executeQueryCommand(); Map<String, LldpInfo> returnValue = getQuery().getQueryReturnValue().getReturnValue(); assertTrue(returnValue == null); }

Target:
Please use assertEquals
Source:
public HostPoller(TimeBoundPollVDSCommandParameters parameters) { Objects.requireNonNull(parameters); this.parameters = parameters; }

Target:
Why this is splitted in two lines, why not: this.parameters = Objects.requireNonNull(parameters)
Source:
public void setGuestCpuType(String value) { if (!Objects.equals(createdByUser, value)) { guestCpuType = value; onPropertyChanged(new PropertyChangedEventArgs("GuestCpuType")); //$NON-NLS-1$ } }

Target:
Should this comparison be !Objects.equals(guestCpuType, value) ?
Source:
private void dataCenter_SelectedItemChanged() { if (getCurrentStorageItem() instanceof SanStorageModelBase) { SanStorageModelBase sanStorageModel = (SanStorageModelBase) getCurrentStorageItem(); sanStorageModel.updateRemovableLuns(getDataCenter().getSelectedItem().getCompatibilityVersion()); sanStorageModel.getRequireTableRefresh().setEntity(null); sanStorageModel.getRequireTableRefresh().setEntity(true); } updateItemsAvailability(); behavior.updateDataCenterAlert(); }

Target:
try removing these lines (371/372), it'd work without
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.", e)); } }

Target:
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.
Source:
private List<NetworkCluster> createNetworkAttachments() { List<NetworkCluster> networkAttachments = new ArrayList<>(); getClustersToAttach().stream().forEach(networkClusterModel -> { NetworkCluster networkCluster = new NetworkCluster(); networkCluster.setClusterId(networkClusterModel.getEntity().getId()); networkCluster.setRequired(networkClusterModel.isRequired()); networkAttachments.add(networkCluster); }); return networkAttachments; }

Target:
forEach() is available for Arrays, please remove .stream()
Source:
public void scheduleJobsForHosts() { vdsManagersDict.values().stream().forEach(VdsManager::scheduleJobs); }

Target:
can be omitted
Source:
public PreviewSnapshotModel(VM vm, Guid userSelectedSnapshotId) { this(); this.vm = vm; setVmId(vm.getId()); this.userSelectedSnapshotId = userSelectedSnapshotId; }

Target:
This field is written here but never read, can be removed (Findbugs)
Source:
public void validateInvalidDestinationDomain() { StorageDomain srcStorageDomain = initStorageDomain(srcStorageId); srcStorageDomain.setStatus(StorageDomainStatus.Active); 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); }

Target:
I think that this one can be removed as well :)
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); params.setPageNum(pageNum==null ? 1 : pageNum); return mapCollection(getBackendCollection(QueryType.GetAllVmsFilteredAndSorted, params)); }

Target:
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);));
Source:
public static long greatestCommonDivisor(long a, long b) { while (b != 0) { a = b; b = a % b; } return a; }

Target:
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;
Source:
protected boolean validate() { final boolean result = validateImpl(); if (!result && !isInternalExecution() && !getParameters().isRerun()) { logValidationFailed(); } return result; }

Target:
What do you think about making this method final? Just to be sure that descendants will override the correct method (validateImpl()) instead of validate().
Source:
public void onResponse(Map<String, Object> response) { try { VDSReturnValue caps = (VDSReturnValue) response.get("result"); handleRefreshCapabilitiesResponse(vds, caps); } catch (Throwable t) { onFailure(t); } }

Target:
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 ?
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(); assertTrue(returnDiskImage.equals(diskImage)); }

Target:
Don't reinvent the wheel, use assertEquals instead.
Source:
public DiskImage getDiskImageByDiskAndImageIds(Guid diskId, Guid imageId) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("disk_id", diskId) .addValue("image_id", imageId); return getCallsHandler().executeRead("GetDiskImageByDiskAndImageIds", DiskImageRowMapper.instance, parameterSource); }

Target:
You should also pass user_id and is_filtered - see example in getAncestor
Source:
private Guid findAvailableStorageDomain( Map<Guid, Long> targetDomainsSize, long diskSize, List<Guid> storageIds) { Guid dest = storageIds.stream() .min(Comparator.comparingLong(targetDomainsSize::get)) .orElse(storageIds.get(0)); long destSize = targetDomainsSize.get(dest); targetDomainsSize.put(dest, destSize - diskSize); return dest; }

Target:
shouldn't it be 'max'?
Source:
public MenuPresenterWidget(EventBus eventBus, MenuPresenterWidget.ViewDef view, Provider<ConfigurePopupPresenterWidget> configurePopupProvider) { super(eventBus, view); this.configurePopupProvider = configurePopupProvider; for (int i = 0; i < PrimaryMenuContainerType.values().length; i++) { 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); }

Target:
Personally I prefer for (PrimaryMenuContainerType type : PrimaryMenuContainerType.values()) { menuContainers.add(type.getId()); } but I'm OK with existing loop, not a big deal.
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 snapshotDao.getAll(getVmId()).stream().filter(s -> s.containsMemory()).collect(Collectors.toList()); } }

Target:
Style: Snapshot::containsMemory
Source:
protected void executeCommand() { registerRollbackHandler((TransactionRollbackListener)() -> TransactionSupport.executeInNewTransaction( (TransactionMethod<Void>) () -> { macPoolPerCluster.createPool(oldMacPool); return null; } )); macPoolDao.update(getMacPoolEntity()); macPoolPerCluster.modifyPool(getMacPoolEntity()); setSucceeded(true); getReturnValue().setActionReturnValue(getMacPoolId()); }

Target:
This is required in AddMacPoolCommand and RemoveMacPoolCommand, too.
Source:
public String getUsernameWithProfile() { String user = String.format("%s@%s", java.util.Objects.toString(username, ""), java.util.Objects.toString(profile, "")); return "@".equals(user) ? "N/A" : user; }

Target:
Any reason using full class reference instead of importing it and using just a class name afterwards?
Source:
public VmDevice() { alias = alias == null ? "" : alias; }

Target:
Why do we need to check for null here?
Source:
public Network() { vmNetwork = true; description = ""; comment = ""; }

Target:
Shouldn't we initialize also name here?
Source:
public VdsStatic() { serverSslEnabled = false; vdsStrength = 100; vdsSpmPriority = HOST_DEFAULT_SPM_PRIORITY; sshPort = DEFAULT_SSH_PORT; sshUsername = DEFAULT_SSH_USERNAME; name = ""; comment = comment == null ? "" : comment; vdsType = VDSType.VDS; autoRecoverable = true; disablePowerManagementPolicy = false; pmKdumpDetection = true; hostProviderId = null; }

Target:
Is this intended?
Source:
public VmDevice addSoundDevice(VmBase vmBase, Supplier<Cluster> clusterSupplier) { ChipsetType chipset = EmulatedMachineUtils.getEffectiveChipset(vmBase, clusterSupplier); Version compatibilityVersion = vmBase instanceof VmTemplate ? CompatibilityVersionUtils.getEffective((VmBase) null, clusterSupplier) : clusterUtils.getCompatibilityVersion(vmBase); return addSoundDevice(vmBase.getId(), vmBase.getOsId(), compatibilityVersion, chipset); }

Target:
why not to use the custom compatibility level of the template, if it is set?
Source:
private boolean shouldAbortOnClientInactivityTimeout(ImageTransfer entity, long ts, Integer idleTimeFromTicket) { int inactivityTimeout = entity.getClientInactivityTimeout() != null ? entity.getClientInactivityTimeout() : getTransferImageClientInactivityTimeoutInSeconds(); // For new daemon (1.3.0), we check timeout according to 'idle_time' in ticket; // otherwise, fallback to check according to entity's 'lastUpdated'. boolean timeoutExceeded = idleTimeFromTicket != null ? idleTimeFromTicket > inactivityTimeout : ts > (entity.getLastUpdated().getTime() / 1000) + inactivityTimeout; return inactivityTimeout > 0 && timeoutExceeded && !entity.getActive(); }

Target:
Looks like it can be taken directly from the entity.
Source:
protected void executeVmCommand() { Guid createdSnapshotId = updateActiveSnapshotId(); setActionReturnValue(createdSnapshotId); getParameters().setCreatedSnapshotId(createdSnapshotId); MemoryImageBuilder memoryImageBuilder = getMemoryImageBuilder(); freezeVm(); ActionReturnValue actionReturnValue = createSnapshotsForDisks(); if (actionReturnValue.getSucceeded()) { memoryImageBuilder.build(); addSnapshotToDB(createdSnapshotId, memoryImageBuilder); fastForwardDisksToActiveSnapshot(); setSucceeded(true); } else { setSucceeded(false); } }

Target:
redundant, right?
Source:
private static void toStringBuilder(Iterable iterable, StringBuilder builder) { Iterator<Object> iterator = iterable.iterator(); if (!iterator.hasNext()) { builder.append("[]"); return; } builder.append("["); while (iterator.hasNext()) { toStringBuilder(iterator.next(), builder); if (iterator.hasNext()) { builder.append(", "); } } builder.append("]"); }

Target:
You don't need this special case
Source:
protected void executeVmCommand() { RemoveMemoryVolumesParameters parameters = new RemoveMemoryVolumesParameters(snapshot, getVmId()); runInternalAction(ActionType.RemoveMemoryVolumes, parameters); snapshot.setMemoryDiskId(null); snapshot.setMetadataDiskId(null); snapshotDao.update(snapshot); setSucceeded(true); }

Target:
didn't you plan to clear the entity first?
Source:
private boolean supportsDeferredPrallocation() { return FeatureSupported.isDeferringFileVolumePreallocationSupported( getStoragePool().getCompatibilityVersion()) && getType() == VolumeType.Preallocated && getStorageDomain().getStorageType().isFileDomain(); }

Target:
Reverse the order, isFileDomain first then Preallocated then FeatureSupported
Source:
private boolean isConsoleCommandsExecutionAllowed() { if (getSelectedItem() == null) { return false; } // return true, if at least one console is available return getSelectedItems() .stream() .map(consolesFactory::getVmConsolesForVm) .anyMatch(VmConsoles::canConnectToConsole); }

Target:
are you sure the getSelectedItems() will never return null here? I would not be so sure :) Or did you mean the if() above should check for getSelectedItems() instead?
Source:
private boolean shouldAbortOnClientInactivityTimeout(ImageTransfer entity, long ts, Integer idleTimeFromTicket) { int inactivityTimeout = getTransferImageClientInactivityTimeoutInSeconds(); // For new daemon (1.3.0), we check timeout according to 'idle_time' in ticket; // otherwise, fallback to check according to entity's 'lastUpdated'. boolean timeoutExceeded = idleTimeFromTicket != null ? idleTimeFromTicket > inactivityTimeout : ts > (entity.getLastUpdated().getTime() / 1000) + inactivityTimeout; return inactivityTimeout > 0 && timeoutExceeded && entity.getPhase().canBePaused() && !entity.getActive(); }

Target:
Previously we didn't have it. Why do we need it now?
Source:
private void addPluginActionButtons(List<ActionButtonDefinition<?>> pluginActionButtonList) { if (hasActionPanelPresenterWidget()) { for(ActionButtonDefinition<?> buttonDef: pluginActionButtonList) { getActionPanelPresenterWidget().addActionButton((ActionButtonDefinition) buttonDef, (int) buttonDef.getPriority()); } } }

Target:
This effectively limits action button priority to integers, is this what we really want?
Source:
private void mapPhysicalNetworkParameters(com.woorea.openstack.quantum.model.Network externalNetwork, Network network) { String providerNetworkType = externalNetwork.getProviderNetworkType(); network.getProvidedBy().setExternalVlanId(providerNetworkType != null && providerNetworkType.equals(VLAN_NETWORK) ? externalNetwork.getProviderSegmentationId() : null); network.getProvidedBy().setCustomPhysicalNetworkName(externalNetwork.getProviderPhysicalNetwork()); }

Target:
VLAN_NETWORK.equals(externalNetwork.getProviderNetworkType())
Source:
protected VM getVmFromConfiguration() { QueryReturnValue queryReturnValue = runInternalQuery( QueryType.GetVmConfigurationBySnapshot, new IdQueryParameters(getParameters().getSnapshotId())); return queryReturnValue.getSucceeded() ? queryReturnValue.getReturnValue() : null; }

Target:
coverity will probably be mad because of a possible NPE when we return null here
Source:
private Guid getSnapshotId(Snapshots snapshots) { return (snapshots.getSnapshots() != null && !snapshots.getSnapshots().isEmpty()) ? asGuid(snapshots.getSnapshots().get(0).getId()) : Guid.Empty; }

Target:
if snapshots.getSnapshots() == null then we'll fail with NPE in validateSnapshotExistence, no?
Source:
public void startingVmCompleted(Guid vmId, String cause) { if (log.isDebugEnabled() && startingVms.contains(vmId)) { log.debug("Startup of VM completed ({})", vmId, cause); } startingVms.remove(vmId); }

Target:
since we're going to remove the vm anyway, this can be replaced with: if (startingVms.remove(vmId) && log.isDebugEnabled()) right?
Source:
private boolean isUserSearchUsingTags() { return getSearchObjectStr() != null && getSearchObjectStr().equals(SearchObjects.VDC_USER_OBJ_NAME) && origText.contains("vm"); }

Target:
If we revert the operands in the condition, we can remove not null check: return SearchObjects.VDC_USER_OBJ_NAME.equals(getSearchObjectStr()) && origText.contains("vm");
Source:
protected boolean isAnyVmRunOnVdsInDb(Guid vdsId) { if (!Config.<Boolean>getValue(ConfigValues.MaintenanceVdsIgnoreExternalVms)) { return vmDynamicDao.isAnyVmRunOnVds(vdsId); } return !vmStaticDao.getAllRunningForVds(vdsId) .stream() .filter(vm -> !OriginType.EXTERNAL.equals(vm.getOrigin())) .collect(Collectors.toList()) .isEmpty(); }

Target:
but there's no reason to change this method now, no?
Source:
public void vmTypeChanged(VmType vmType) { // provisioning thin -> false // provisioning clone -> true if (getModel().getProvisioning().getIsAvailable()) { getModel().getProvisioning().setEntity(vmType == VmType.Server || vmType == VmType.HighPerformance); } if (getModel().getIoThreadsEnabled().getIsAvailable()) { getModel().getIoThreadsEnabled().setEntity(vmType == VmType.Server || vmType == VmType.HighPerformance); } super.vmTypeChanged(vmType); }

Target:
why not in VmModelBaseBehavior#vmTypeChanged?
Source:
protected boolean validateBackupDomainNotFirstInPool() { if (getStoragePool() != null) { if (getStoragePool().getStatus() == StoragePoolStatus.Uninitialized && getStorageDomain().isBackup()) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_FIRST_DOMAIN_CANNOT_BE_BACKUP); } } return true; }

Target:
Please use here one if condition: if (getStoragePool() != null && getStoragePool().getStatus() == StoragePoolStatus.Uninitialized && getStorageDomain().isBackup())
Source:
protected boolean validate() { if (!super.validate() || !checkStorageDomain()) { return false; } // Only after validating the existence of the storage domain in DB, we set the field lastTimeUsedAsMaster in the // storage domain which is about to be updated. oldDomain = storageDomainStaticDao.get(getStorageDomain().getId()); getStorageDomain().setLastTimeUsedAsMaster(oldDomain.getLastTimeUsedAsMaster()); return validateMasterDomainCannotBeBackup() && validateStoragePropertiesUpdate(); }

Target:
I think that a proper place would be to put this after line 63 as part of validateStoragePropertiesUpdate. We can keep the validate method clean that way
Source:
public static BootProtocol map(Ipv6BootProtocol entity) { if (entity == null) { return null; } switch (entity) { case POLY_DHCP_AUTOCONF: case AUTOCONF: return BootProtocol.AUTOCONF; case DHCP: return BootProtocol.DHCP; case NONE: return BootProtocol.NONE; case STATIC_IP: return BootProtocol.STATIC; default: return null; } }

Target:
Why don't you add POLY_DHCP_AUTOCONF to BootProtocol?
Source:
private static boolean chipsetMatchesEmulatedMachine(ChipsetType chipsetType, String emulatedMachine) { if (chipsetType == ChipsetType.I440FX) { return true; } return chipsetType == ChipsetType.fromMachineType(emulatedMachine); }

Target:
that can be shorten to a single line: return chipsetType == ChipsetType.I440FX || chipsetType == ChipsetType.fromMachineType(emulatedMachine); but not a big deal from my side.
Source:
private void checkVdsMemoryThresholdPercentage(Cluster cluster, VdsStatistics stat) { Integer maxUsedPercentageThreshold = cluster.getLogMaxMemoryUsedThreshold(); if (stat.getUsageMemPercent() > maxUsedPercentageThreshold) { logMemoryAuditLog(vds, stat, AuditLogType.VDS_HIGH_MEM_USE, maxUsedPercentageThreshold); } }

Target:
please merge lines
Source:
VmDeviceUtils(VmStaticDao vmStaticDao, VmDeviceDao vmDeviceDao, ClusterDao clusterDao, VmTemplateDao vmTemplateDao, VmHandler vmHandler, MacPoolPerCluster macPoolPerCluster, RngDeviceUtils rngDeviceUtils, VideoDeviceSettings videoDeviceSettings, OsRepository osRepository) { this.vmStaticDao = vmStaticDao; this.vmDeviceDao = vmDeviceDao; this.clusterDao = clusterDao; this.vmTemplateDao = vmTemplateDao; this.vmHandler = vmHandler; this.macPoolPerCluster = macPoolPerCluster; this.rngDeviceUtils = rngDeviceUtils; this.videoDeviceSettings = videoDeviceSettings; this.osRepository = osRepository; this.compensationContext = null; }

Target:
redundant?
Source:
protected BaseDisk generateNewEntity() { BaseDisk d = new BaseDisk(); d.setId(Guid.newGuid()); d.setWipeAfterDelete(true); d.setPropagateErrors(PropagateErrors.Off); d.setDiskAlias("DiskName"); d.setSgio(ScsiGenericIO.FILTERED); d.setDiskDescription(""); return d; }

Target:
Not needed, part of constructor
Source:
protected boolean validateImages() { List<DiskImage> imagesToValidate = getDiskImagesToValidate(); List<DiskImage> allDiskImagesInSrcAndDstToValidate = getAllDiskImagesInSrcAndDstToValidate(); DiskImagesValidator diskImagesValidator = new DiskImagesValidator(imagesToValidate); DiskImagesValidator allDiskImagesInChainValidator = new DiskImagesValidator(allDiskImagesInSrcAndDstToValidate); return validateImagesNotLocked(diskImagesValidator) && (getVm().isQualifiedForLiveSnapshotMerge() || validate(allDiskImagesInChainValidator.diskImagesNotIllegal())) && (!getVm().isQualifiedForLiveSnapshotMerge() || validateSnapshotDisksArePlugged()); }

Target:
Please replace line #481 with line #482
Source:
public ArrayList<DiskInterface> getDiskInterfaceList() { return new ArrayList<>( Arrays.asList( DiskInterface.IDE, DiskInterface.VirtIO, DiskInterface.VirtIO_SCSI, DiskInterface.SPAPR_VSCSI, DiskInterface.SATA )); }

Target:
any reason not to just replace it with DiskInterface.values()?
Source:
public void addComboActionButton(ActionButtonDefinition<T> buttonDef, List<ActionButtonDefinition<T>> subActions) { ActionButton newButton = getView().addDropdownComboActionButton(buttonDef, subActions, this); actionButtonDefinitions.add(buttonDef); for (ActionButtonDefinition ab : subActions) { actionButtonDefinitions.add(ab); } initButton(buttonDef, newButton); }

Target:
aren't you changing the behavior of the existing method? I feel like I'm missing something
Source:
private void updateOverCommitPercent() { if (getAvailableDiskSize() == null || getAvailableDiskSize() == 0) { setStorageDomainOverCommitPercent(0); } else { setStorageDomainOverCommitPercent((int)((getCommittedDiskSize() - getActualImagesSize()) * 100 / getAvailableDiskSize())); } }

Target:
casting to int here is redundant now..
Source:
public long getStorageDomainOverCommitPercent() { return storageDomainOverCommitPercent; }

Target:
should be left as int
Source:
public String getMessage(NetworkItemModel<?> op1, NetworkItemModel<?> op2) { return appendDetachNetworkSuggestion(getVerb(getNotInSyncNetwork(op2)), op2); }

Target:
appendDetachNetworkSuggestion takes the problematic network from 'CulpritNetwork'. Seems that now it won't work since 'getNotInSyncNetwork' return a nework with no 'CulpritNetwork'. I don't have a running env but anyway seems that the old code has a bug, it will print the same network at both parts of the message, isn't it?
Source:
protected void executeQueryCommand() { Map<Guid, DiskImage> imagesAncestors = new HashMap<>(); for (Guid id : getParameters().getIds()) { DiskImage ancestor = diskImageDao.getAncestor(id, getUserID(), getParameters().isFiltered()); imagesAncestors.put(id, ancestor); } getQueryReturnValue().setReturnValue(imagesAncestors); }

Target:
Maybe we need to check that the ancestor is not null before adding to map?
Source:
public boolean shouldUseNativeIO(VM vm, DiskImage diskImage, VmDevice device) { StorageType storageType = diskImage.getStorageTypes().get(0); String diskType = getDiskType(vm, diskImage, device); boolean isNativeIO = !"file".equals(diskType) || (storageType == StorageType.GLUSTERFS && FeatureSupported.useNativeIOForGluster(vm.getCompatibilityVersion())); // marked as transient disk and uses cache when snapshotId is not null if ("file".equals(diskType) && device.getSnapshotId() != null) { isNativeIO = false; } return isNativeIO; }

Target:
Seems like we're duplicating code a little here by checking "file".equals(...) multiple times in consecutive lines, and there may be other cases. What about an additional method (public boolean isSnapshot(...)), or simply: boolean isSnapshot = device.getSnapshotId() != null; return isSnapshot ? false : !"file".equals(diskType) || (storageType == StorageType.GLUSTERFS && ...) Otherwise, we're now keeping track of
Source:
public void testNewStorageTypes() { assertEquals(9, StorageType.values().length, "A storage type was added/removed. Update this test, and the isFileDomain/isBlockDomain " + "method accordingly"); }

Target:
please change to 10
Source:
protected AddCinderStorageDomainCommand(Guid commandId) { super(commandId); }

Target:
public
Source:
public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof AddCinderStorageDomainParameters)) return false; AddCinderStorageDomainParameters that = (AddCinderStorageDomainParameters) o; return Objects.equals(driverName, that.driverName) && Objects.equals(driverOptions, that.driverOptions); }

Target:
please add {}. It fails the checkstyle validation
Source:
private String getStorageDomainNameById(String storageDomainId) { for (StorageDomain storageDomainItem : storageDomainDao.getAll()) { if (storageDomainItem != null && storageDomainItem.getStorageStaticData() != null) { if (storageDomainItem.getStorageStaticData().getStorage().equals(storageDomainId)) { return storageDomainItem.getStorageStaticData().getName(); } } } return ""; }

Target:
Since we already have the storage domain ID, can't we just use storageDomainDao.get(storageDomainId) and see if it exists?
Source:
public void addNotEmptyIdConnection() { StorageServerConnections newPosixConnection = createPosixConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data1", StorageType.POSIXFS, "nfs", "timeo=30"); newPosixConnection.setId(Guid.newGuid().toString()); parameters.setStorageServerConnection(newPosixConnection); parameters.setVdsId(Guid.Empty); doReturn("").when(command).isConnWithSameDetailsExists(newPosixConnection, null); ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY); }

Target:
still an empty string
Source:
public boolean isCinderDomain() { return this == CINDER || this == MANAGED_BLOCK_STORAGE; }

Target:
why do we want to correlate cinder and managed block storage?
Source:
public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof StorageOffloadDisk)) return false; if (!super.equals(o)) return false; StorageOffloadDisk that = (StorageOffloadDisk) o; return Objects.equals(volumeMetadata, that.volumeMetadata); }

Target:
please add {}. It fails the checkstyle validation
Source:
protected void handleSpecificCommandActions() { return; }

Target:
Not needed, please leave the method empty
Source:
public static final AbstractTextColumn<Disk> getLogicalNameColumn(String sortBy) { AbstractTextColumn<Disk> column = new AbstractTextColumn<Disk>() { @Override public String getValue(Disk object) { if (object.getDiskVmElements().size() == 1) { return object.getDiskVmElements().iterator().next().getLogicalName(); } return null; } }; return makeSortable(column, sortBy); }

Target:
Maybe we can skip the final here