auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private Guid determineSourceImageGroup(DiskImage image) { if (Guid.Empty.equals(image.getParentId())) { return Guid.Empty; } START else { if (!getParameters().getDestImages().isEmpty()) END { return getParameters().getDestImageGroupId(); } } return image.getImageTemplateId().equals(image.getParentId()) ? imageDao.get(image.getImageTemplateId()).getDiskId() : getParameters().getImageGroupID(); } I think either "else if" or totally removing "else" is more readable. Also 1 less indent.

Target:
private Guid determineSourceImageGroup(DiskImage image) { if (Guid.Empty.equals(image.getParentId())) { return Guid.Empty; } else if (!getParameters().getDestImages().isEmpty()) { return getParameters().getDestImageGroupId(); } return image.getImageTemplateId().equals(image.getParentId()) ? imageDao.get(image.getImageTemplateId()).getDiskId() : getParameters().getImageGroupID(); }
Source:
public START RemoveUnregisteredEntityParameters() END { this.setEntityId(Guid.Empty); this.setStorageDomainId(Guid.Empty); this.setStoragePoolId(Guid.Empty); } 1) Better move the no-arg C'tor to be the first C'tor. 2) It can be nice if it will call the 3-arg C'tor: this(Guid.Empty, Guid.Empty, Guid.Empty);

Target:
public RemoveUnregisteredEntityParameters() { this(Guid.Empty, Guid.Empty, Guid.Empty); }
Source:
START protected void END endRemoveEntity() { setCommandShouldBeLogged(false); setSucceeded(true); } I think that this one is used only here. Can you consider changing it to private?

Target:
private void endRemoveEntity() { setCommandShouldBeLogged(false); setSucceeded(true); }
Source:
private void initUnregisteredEntity(Guid entityId, Guid storageDomainId) { START if (!isUnregisteredEntityExists()) { END List<OvfEntityData> ovfEntityList = unregisteredOVFDataDao.getByEntityIdAndStorageDomain(entityId, storageDomainId); if (!ovfEntityList.isEmpty()) { // We should get only one entity, since we fetched the entity with a specific Storage Domain ovfEntityData = ovfEntityList.get(0); try { setUnregisteredEntityAndImages(); } catch (OvfReaderException e) { log.error("Failed to parse a given ovf configuration: {}:\n{}", e.getMessage(), ovfEntityData.getOvfData()); log.debug("Exception: ", e); } } } } maybe convert it to an early return with log, just to make it a bit clearer.

Target:
private void initUnregisteredEntity(Guid entityId, Guid storageDomainId) { List<OvfEntityData> ovfEntityList = unregisteredOVFDataDao.getByEntityIdAndStorageDomain(entityId, storageDomainId); if (!ovfEntityList.isEmpty()) { // We should get only one entity, since we fetched the entity with a specific Storage Domain ovfEntityData = ovfEntityList.get(0); try { setUnregisteredEntityAndImages(); } catch (OvfReaderException e) { log.error("Failed to parse a given ovf configuration: {}:\n{}", e.getMessage(), ovfEntityData.getOvfData()); log.debug("Exception: ", e); } } }
Source:
START protected void END initUnregisteredEntity(Guid entityId, Guid storageDomainId) { if (!isUnregisteredEntityExists()) { List<OvfEntityData> ovfEntityList = unregisteredOVFDataDao.getByEntityIdAndStorageDomain(entityId, storageDomainId); if (!ovfEntityList.isEmpty()) { // We should get only one entity, since we fetched the entity with a specific Storage Domain ovfEntityData = ovfEntityList.get(0); try { setUnregisteredEntityAndImages(); } catch (OvfReaderException e) { log.error("Failed to parse a given ovf configuration: {}:\n{}", e.getMessage(), ovfEntityData.getOvfData()); log.debug("Exception: ", e); } } } } private?

Target:
private void initUnregisteredEntity(Guid entityId, Guid storageDomainId) { if (!isUnregisteredEntityExists()) { List<OvfEntityData> ovfEntityList = unregisteredOVFDataDao.getByEntityIdAndStorageDomain(entityId, storageDomainId); if (!ovfEntityList.isEmpty()) { // We should get only one entity, since we fetched the entity with a specific Storage Domain ovfEntityData = ovfEntityList.get(0); try { setUnregisteredEntityAndImages(); } catch (OvfReaderException e) { log.error("Failed to parse a given ovf configuration: {}:\n{}", e.getMessage(), ovfEntityData.getOvfData()); log.debug("Exception: ", e); } } } }
Source:
START public void END setUpQueryEntitiesNotFound() { // Mock the Daos when(unregisteredOVFDataDaoMock.getByEntityIdAndStorageDomain(entityId, storageDomainId)).thenReturn( new ArrayList<>()); } Can be private

Target:
private void setUpQueryEntitiesNotFound() { // Mock the Daos when(unregisteredOVFDataDaoMock.getByEntityIdAndStorageDomain(entityId, storageDomainId)).thenReturn( new ArrayList<>()); }
Source:
public void executeCommand(UICommand command) { super.executeCommand(command); if (command == getImportCommand()) { restore(); } else if (command == getRemoveCommand()) { remove(); } else if START ("OnRemove".equals(command.getName())) END { //$NON-NLS-1$) onRemove(); } else if (command.getName().equals("Cancel")) { //$NON-NLS-1$ cancel(); } } Consider changing it to "command.getName().equals("OnRemove")" so it will fit the 'else if'

Target:
public void executeCommand(UICommand command) { super.executeCommand(command); if (command == getImportCommand()) { restore(); } else if (command == getRemoveCommand()) { remove(); } else if (command.getName().equals("OnRemove")) { //$NON-NLS-1$) onRemove(); } else if (command.getName().equals("Cancel")) { //$NON-NLS-1$ cancel(); } }
Source:
protected void updateDetailsAvailability() { if (getSelectedItem() != null) { Disk disk = getSelectedItem(); START vmListModel.setIsAvailable(disk.getVmEntityType() == null || !disk.getVmEntityType().isTemplateType()); END templateListModel.setIsAvailable(isTemplateDisk(disk)); storageListModel.setIsAvailable(disk.getDiskStorageType() == DiskStorageType.IMAGE || disk.getDiskStorageType() == DiskStorageType.CINDER); } } I think this section is exactly: "!isTemplateDisk(disk)"

Target:
protected void updateDetailsAvailability() { if (getSelectedItem() != null) { Disk disk = getSelectedItem(); vmListModel.setIsAvailable(!isTemplateDisk(disk)); templateListModel.setIsAvailable(isTemplateDisk(disk)); storageListModel.setIsAvailable(disk.getDiskStorageType() == DiskStorageType.IMAGE || disk.getDiskStorageType() == DiskStorageType.CINDER); } }
Source:
public static Stream<MockConfigDescriptor<?>> mockConfiguration() { START return Stream.of( MockConfigDescriptor.of(ConfigValues.OrganizationName, "oVirt"), MockConfigDescriptor.of(ConfigValues.SetupNetworksWaitTimeoutSeconds, 5000) ); END } you can remove this (API no longer accesses configuration so no need to mock) and instead of this please change in testActivate() and similar tests to expect the new Parameters sub-class that you have added

Target:
public static Stream<MockConfigDescriptor<?>> mockConfiguration() { return Stream.of(MockConfigDescriptor.of(ConfigValues.OrganizationName, "oVirt")); }
Source:
public static void getAdditionalDeviceImageList(AsyncQuery<List<String>> aQuery, Guid storagePoolId, int osId, Version clusterVersion) { START AsyncDataProvider.isFloppySupported(new AsyncQuery<>(isFloppySupported -> { END if (isFloppySupported) { getIrsImageList(aQuery, storagePoolId, false, ImageFileType.Floppy, new RepoImageToImageFileNameAsyncConverter()); } }), osId, clusterVersion); } Can you move this call to the calling method RunOnceModel::updateFloppyImages ? Here it seems strange that a method called 'get' something never calls the callback if the floppy is not supported.

Target:
public static void getAdditionalDeviceImageList(AsyncQuery<List<String>> aQuery, Guid storagePoolId, int osId, Version clusterVersion) { getIrsImageList(aQuery, storagePoolId, false, ImageFileType.Floppy, new RepoImageToImageFileNameAsyncConverter()); }
Source:
public HostRestartConfirmationModel() { super(); setForceToMaintenance(new EntityModel<>()); getForceToMaintenance().setEntity(false); START getForceToMaintenance().setIsAvailable(true); END } It should be available by default, no need to set it.

Target:
public HostRestartConfirmationModel() { super(); setForceToMaintenance(new EntityModel<>()); getForceToMaintenance().setEntity(false); }
Source:
private void saveCommonStorageProperties(StorageModel model) { START storageDomain.setStorageName(model.getName().getEntity()); END saveDefaultedStorageProperties(model, storageDomain); } This one is already done on line 816. Do we need it again here?

Target:
private void saveCommonStorageProperties(StorageModel model) { saveDefaultedStorageProperties(model, storageDomain); }
Source:
public Disk update(Disk incoming) { // If the QCOW version is specified, then perform the update: if (incoming.isSetQcowVersion()) { START return performUpdate( END incoming, new QueryIdResolver<>(QueryType.GetDiskByDiskId, IdQueryParameters.class), ActionType.AmendImageGroupVolumes, new UpdateParametersProvider()); } return performUpdate(incoming, new DiskResolver(), ActionType.UpdateVmDisk, new BackendDiskResource.UpdateParametersProvider()); } What about updating QCOW and other parameters in the same call?

Target:
public Disk update(Disk incoming) { // If the QCOW version is specified, then perform the update: if (incoming.isSetQcowVersion()) { return performUpdate( incoming, new QueryIdResolver<>(QueryType.GetDiskByDiskId, IdQueryParameters.class), ActionType.AmendImageGroupVolumes, new UpdateParametersProvider()); } return performUpdate(incoming, new QueryIdResolver<>(QueryType.GetDiskByDiskId, IdQueryParameters.class), ActionType.UpdateVmDisk, new BackendDiskResource.UpdateParametersProvider()); }
Source:
public void setItems(Collection<T> value, T selectedItem) { List<T> items = new ArrayList<>(value); START if (items.get(0) != null) END { items.add(0, null); } super.setItems(items, selectedItem); } this will fail if the "value" is an empty collection.

Target:
public void setItems(Collection<T> value, T selectedItem) { List<T> items = value == null ? new ArrayList<>() : new ArrayList<>(value); if (items.isEmpty() || items.get(0) != null) { items.add(0, null); } super.setItems(items, selectedItem); }
Source:
START private void updateArbiterAvailability() { END getArbiterVolume().setIsAvailable(getTypeList().getSelectedItem().isReplicatedType() && getCluster().getSelectedItem() != null); } Doesn't the former condition mean that the Arbiter volume is available only for version 4.1 and lower? In that case removing the version check changes the logic and makes it available for other versions. The Arbiter volume should be probably removed completely.

Target:
private void updateArbiterAvailability() { getArbiterVolume().setIsAvailable(getTypeList().getSelectedItem().isReplicatedType()); }
Source:
public ValidationResult validateOpenStackImageConstraints() { if (ProviderType.OPENSTACK_IMAGE != provider.getType()) { return ValidationResult.VALID; } List<Provider<?>> existingProviders = Injector.get(ProviderDao.class).getAllByTypes(ProviderType.OPENSTACK_IMAGE); START if (OpenStackTokenProviderFactory.isApiV3(provider)) { return openStackImageV3Constraints(existingProviders); } else { return openStackImageV2Constraints(existingProviders); } END } Consider using ? : syntax - return ... ? x : y

Target:
public ValidationResult validateOpenStackImageConstraints() { if (ProviderType.OPENSTACK_IMAGE != provider.getType()) { return ValidationResult.VALID; } List<Provider<?>> existingProviders = Injector.get(ProviderDao.class).getAllByTypes(ProviderType.OPENSTACK_IMAGE); return OpenStackTokenProviderFactory.isApiV3(provider) ? openStackImageV3Constraints(existingProviders) : openStackImageV2Constraints(existingProviders); }
Source:
private boolean validateCanAmendDisk() { DiskImage disk = (DiskImage) getNewDisk(); setStoragePoolId(disk.getStoragePoolId()); if (!validate(new StoragePoolValidator(getStoragePool()).existsAndUp())) { return false; } DiskImagesValidator diskImagesValidator = new START DiskImagesValidator(Collections.singletonList(disk)); END return validate(diskImagesValidator.diskImagesNotIllegal()); } Consider using new Java 11 List.of()

Target:
private boolean validateCanAmendDisk() { DiskImage disk = (DiskImage) getNewDisk(); setStoragePoolId(disk.getStoragePoolId()); if (!validate(new StoragePoolValidator(getStoragePool()).existsAndUp())) { return false; } DiskImagesValidator diskImagesValidator = new DiskImagesValidator(List.of(disk)); return validate(diskImagesValidator.diskImagesNotIllegal()); }
Source:
private AuditLogable createAuditLogable(AnsibleCommandConfig command, String taskName) { return AuditLogableImpl.createHostEvent( command.hosts().get(0), command.correlationId(), START new HashMap<>() { { put("Message", taskName); put("PlayAction", command.playAction()); } } END ); } I think it should be safe now with java > 9 to use Map.of("key1","value1", "key2", "value2");

Target:
private AuditLogable createAuditLogable(AnsibleCommandConfig command, String taskName) { return AuditLogableImpl.createHostEvent( command.hosts().get(0), command.correlationId(), Map.of("Message", taskName, "PlayAction", command.playAction()) ); }
Source:
public AuditLogType getAuditLogTypeValue() { START addCustomValue("UserName", String.format("%s", getUserName())); END return getSucceeded() ? AuditLogType.USER_REBOOT_VM : AuditLogType.USER_FAILED_REBOOT_VM; } This line should not be needed. 'UserName' will be automatically replaced by calling getUserName().

Target:
public AuditLogType getAuditLogTypeValue() { return getSucceeded() ? AuditLogType.USER_REBOOT_VM : AuditLogType.USER_FAILED_REBOOT_VM; }
Source:
protected void analyze() { if (isVmStoppedBeingReported()) { proceedDisappearedVm(); return; } if (isExternalOrUnmanagedHostedEngineVm()) { processUnmanagedVm(); return; } if (isVmDown()) { proceedDownVm(); return; } START if (isVmRebooting()) { END proceedRebootingVm(); } if (!isVmRunningInDatabaseOnMonitoredHost()) { proceedVmReportedOnOtherHost(); return; } proceedVmReportedOnExpectedHost(); } Please move this call to proceedVmReportedOnExpectedHost() method. That method contains multiple similar statements, to check VM state and add audit log line.

Target:
protected void analyze() { if (isVmStoppedBeingReported()) { proceedDisappearedVm(); return; } if (isExternalOrUnmanagedHostedEngineVm()) { processUnmanagedVm(); return; } if (isVmDown()) { proceedDownVm(); return; } if (!isVmRunningInDatabaseOnMonitoredHost()) { proceedVmReportedOnOtherHost(); return; } proceedVmReportedOnExpectedHost(); }
Source:
START public HostNetworkQos END selectQos(NetworkAttachment networkAttachment, HostNetworkQos daoHostNetworkQos) { return networkAttachment != null && networkAttachment.isQosOverridden() ? HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos()) : daoHostNetworkQos; } public seems not required, only used inside vdsbroker

Target:
HostNetworkQos selectQos(NetworkAttachment networkAttachment, HostNetworkQos daoHostNetworkQos) { return networkAttachment != null && networkAttachment.isQosOverridden() ? HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos()) : daoHostNetworkQos; }
Source:
START public HostNetworkQos END getHostNetworkQosFromNetwork(Network network) { return network != null ? hostNetworkQosDao.get(network.getQosId()) : null; } public seems not required

Target:
HostNetworkQos getHostNetworkQosFromNetwork(Network network) { return network != null ? hostNetworkQosDao.get(network.getQosId()) : null; }
Source:
START public List<HostNetworkQos> END getAll() { return hostNetworkQosDao.getAll(); } public not required

Target:
List<HostNetworkQos> getAll() { return hostNetworkQosDao.getAll(); }
Source:
private void setDiskImageActiveBySnapshotType(Map<Guid, DiskImage> diskImageMap, Snapshot snapshot) { DiskImage diskImage = diskImageMap.get(snapshot.getId()); if (diskImage == null) { return; } START if (snapshot.getType() == SnapshotType.ACTIVE || snapshot.getType() == SnapshotType.PREVIEW) { END diskImage.setActive(true); } else { diskImage.setActive(false); } } It's possible to make this even shorter: diskImage.setActive(snapshot.getType == ... || ...);

Target:
private void setDiskImageActiveBySnapshotType(Map<Guid, DiskImage> diskImageMap, Snapshot snapshot) { DiskImage diskImage = diskImageMap.get(snapshot.getId()); if (diskImage == null) { return; } diskImage.setActive(snapshot.getType() == SnapshotType.ACTIVE || snapshot.getType() == SnapshotType.PREVIEW); }
Source:
private void updateDiskSize(DiskImage diskImage) { START getSizeExtend().validateEntity(new IValidation[] { END new NotEmptyValidation(), new NonNegativeLongNumberValidation(), }); if (getSizeExtend().getIsValid()) { long sizeToAddInGigabytes = Long.parseLong(getSizeExtend().getEntity()); if (sizeToAddInGigabytes > 0) { diskImage.setSizeInGigabytes(diskImage.getSizeInGigabytes() + sizeToAddInGigabytes); } } } please move to 'validate' method, so this method could handle only size updating.

Target:
private void updateDiskSize(DiskImage diskImage) { long sizeToAddInGigabytes = Long.parseLong(getSizeExtend().getEntity()); if (sizeToAddInGigabytes > 0) { diskImage.setSizeInGigabytes(diskImage.getSizeInGigabytes() + sizeToAddInGigabytes); } }
Source:
private void updateDiskSize(DiskImage diskImage) { try { START long sizeToAddInGigabytes = Long.parseLong(getSizeExtend().getEntity()); END if (sizeToAddInGigabytes > 0) { diskImage.setSizeInGigabytes(diskImage.getSizeInGigabytes() + sizeToAddInGigabytes); } } catch (NumberFormatException ignored) { } } Suggest to surround just this parsing with the try-catch. This is is the line that has a potential to throw.

Target:
private void updateDiskSize(DiskImage diskImage) { long sizeToAddInGigabytes; try { sizeToAddInGigabytes = Long.parseLong(getSizeExtend().getEntity()); } catch (NumberFormatException ignored) { // the catch block is ignored because of the error will be caught in the validation stage // the engine log and the UI will show appropriate error and force valid input. return; } if (sizeToAddInGigabytes > 0) { diskImage.setSizeInGigabytes(diskImage.getSizeInGigabytes() + sizeToAddInGigabytes); } }
Source:
public int setTabIndexes(int nextTabIndex) { START certificateAuthority.setTabIndex(++nextTabIndex); prometheusUrl.setTabIndex(++nextTabIndex); prometheusCertificateAuthority.setTabIndex(++nextTabIndex); END return nextTabIndex; } Please change incrementing the index to (nextTabIndex++) instead of (++nextTabIndex) for all 3 lines, since otherwise you'll need to click tab twice on each field to get to the next one.

Target:
public int setTabIndexes(int nextTabIndex) { certificateAuthority.setTabIndex(nextTabIndex++); prometheusUrl.setTabIndex(nextTabIndex++); prometheusCertificateAuthority.setTabIndex(nextTabIndex++); return nextTabIndex; }
Source:
protected void executeCommand() { Cluster cluster = clusterDao.get(getParameters().getClusterId()); if (cluster.supportsGlusterService()) { try { glusterSyncJob.refreshSelfHealData(cluster); } catch (Exception e) { START log.error("Error while refreshing Gluster self heal data of cluster '{}': {}", END cluster.getName(), e.getMessage()); log.debug("Exception", e); } setSucceeded(true); } } setSucceeded(false) and raise error here?

Target:
protected void executeCommand() { try { glusterSyncJob.refreshSelfHealData(cluster); } catch (Exception e) { log.error("Error while refreshing Gluster self heal data of cluster '{}': {}", cluster.getName(), e.getMessage()); log.debug("Exception", e); setSucceeded(false); } setSucceeded(true); }
Source:
private VM mockVm(VMStatus vmStatus) { vm.setStatus(vmStatus); vm.setId(vmId); vm.setRunOnVds(Guid.newGuid()); when(vmDao.get(command.getParameters().getVmId())).thenReturn(vm); START return vm; END } If I'm not wrong, the method can return void, as other mockXYZ methods. The return value is never used.

Target:
private void mockVm(VMStatus vmStatus) { vm.setStatus(vmStatus); vm.setId(vmId); vm.setRunOnVds(Guid.newGuid()); when(vmDao.get(command.getParameters().getVmId())).thenReturn(vm); }
Source:
public static int findInColumnSortList(ColumnSortList sortList, AbstractTextColumn<?> column) { if (sortList == null || column == null) { return -1; } for (int i = 0; i < sortList.size(); i++) { ColumnSortList.ColumnSortInfo sortInfo = sortList.get(i); if START (column == sortInfo.getColumn()) { END return i; } } return -1; } Smells like a bug. Are you sure it should not be equals?

Target:
public static int findInColumnSortList(ColumnSortList sortList, AbstractTextColumn<?> column) { if (sortList == null || column == null) { return -1; } for (int i = 0; i < sortList.size(); i++) { ColumnSortList.ColumnSortInfo sortInfo = sortList.get(i); if (column.equals(sortInfo.getColumn())) { return i; } } return -1; }
Source:
public Guid getHostForExecution(Guid poolId, Collection<Guid> hostsToFilter) { return getHostForExecution(poolId, vds -> START !hostsToFilter.contains(vds)); END } check for VDS in collection of Guids probably vds.getId()

Target:
public Guid getHostForExecution(Guid poolId, Collection<Guid> hostsToFilter) { return getHostForExecution(poolId, vds -> !hostsToFilter.contains(vds.getId())); }
Source:
public boolean isLeafVolType(Guid storagePoolId, Guid storageDomainId, Guid imageGroupId, Guid imageId) { DiskImage dbImage = getSnapshotLeaf(imageGroupId); DiskImage vdsmImage = getVolumeInfoFromVdsm(storagePoolId, storageDomainId, imageGroupId, imageId); START return dbImage.getId().equals(vdsmImage.getId()) ? VolType.LEAF == vdsmImage.getVolType() : true; END } This one can be simplified: return !dbImage.getId().equals(vdsmImage.getId()) || VolType.LEAF == vdsmImage.getVolType();

Target:
public boolean isLeafVolType(Guid storagePoolId, Guid storageDomainId, Guid imageGroupId, Guid imageId) { DiskImage dbImage = getSnapshotLeaf(imageGroupId); DiskImage vdsmImage = getVolumeInfoFromVdsm(storagePoolId, storageDomainId, imageGroupId, imageId); return !dbImage.getId().equals(vdsmImage.getId()) || VolType.LEAF == vdsmImage.getVolType(); }
Source:
public boolean hasCorrectVolType(Guid storagePoolId, Guid storageDomainId, Guid imageGroupId, Guid imageId) { DiskImage dbImage = getSnapshotLeaf(imageGroupId); DiskImage vdsmImage = getVolumeInfoFromVdsm(storagePoolId, storageDomainId, imageGroupId, imageId); if (dbImage.getId().equals(vdsmImage.getId())) { return VolType.LEAF == vdsmImage.getVolType(); } return START true; END } can be replaced with: return dbImage.getId().equals(vdsmImage.getId()) ? VolType.LEAF == vdsmImage.getVolType() : true; But it is not a must, just a matter of style.

Target:
public boolean hasCorrectVolType(Guid storagePoolId, Guid storageDomainId, Guid imageGroupId, Guid imageId) { DiskImage dbImage = getSnapshotLeaf(imageGroupId); DiskImage vdsmImage = getVolumeInfoFromVdsm(storagePoolId, storageDomainId, imageGroupId, imageId); return dbImage.getId().equals(vdsmImage.getId()) ? VolType.LEAF == vdsmImage.getVolType() : true; }
Source:
private String readContent(HttpResponse response) { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); } catch (IOException e) { e.printStackTrace(); } START return reader.lines().collect(Collectors.joining()); END } This can fail with null pointer exception, hide errors reading the response, and log 2 errors for same issue (e..g first print stack trace when reading fails, then return empty string and fail when parsing the json). Lets this code raise the IOException and handle it in the caller - we already wrap all the calls in try/catch block.

Target:
private String readContent(HttpResponse response) throws IOException { BufferedReader reader = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); return reader.lines().collect(Collectors.joining()); }
Source:
private ImageioClient getImageioClient() { if (imageioClient == null) { imageioClient = new ImageioClient(getImageioUnixSocketPath().toString()); } START return imageioClient; END } Since the client does not provide reliable persistent connection, I would not keep an instance in the command and create a new client for each request instead. Adding more state to the command does not help and we avoid the need to create client lazily.

Target:
private ImageioClient getImageioClient() { if (imageioClient == null) { imageioClient = new ImageioClient(getImageioUnixSocketPath().toString()); } return new ImageioClient(getImageioUnixSocketPath().toString()); }
Source:
START public void scheduleWithFixedDelay(Object instance, END String methodName, Class<?>[] inputTypes, Object[] inputParams, long initialDelay, long taskDelay, TimeUnit timeUnit) { executor.scheduleWithFixedDelay(getRunnable(instance, methodName), initialDelay, taskDelay, TimeUnit.SECONDS); } isn't this implementing scheduleWithFixedDelay of the SchedulerUtil interface? why's the return type changed?

Target:
public void scheduleWithFixedDelay(Object instance, String methodName, Class<?>[] inputTypes, Object[] inputParams, long initialDelay, long taskDelay, TimeUnit timeUnit) { executor.scheduleWithFixedDelay(getRunnable(instance, methodName, inputTypes, inputParams), initialDelay, taskDelay, TimeUnit.SECONDS); }
Source:
public void close() throws IOException { START httpClient.close(); END } there is no case in which httpClient become null, right ?

Target:
public void close() throws IOException { if (httpClient != null) { httpClient.close(); } }
Source:
public void afterRefreshTreatment() { try { START prometheusClient.close(); END } catch (IOException e) { // ignore } } pls verify that prometheusClient is not null.

Target:
public void afterRefreshTreatment() { try { if (prometheusClient != null) { prometheusClient.close(); } } catch (IOException e) { // ignore } }
Source:
public void stopMonitoring() { super.stopMonitoring(); try { START prometheusClient.close(); END } catch (IOException e) { // ignore } } pls check that prometheusClient isn't null

Target:
public void stopMonitoring() { super.stopMonitoring(); try { if (prometheusClient != null) { prometheusClient.close(); } } catch (IOException e) { // ignore } }
Source:
public boolean performNextOperation(int completedChildCount) { restoreCommandState(); switch (getParameters().getVmBackup().getPhase()) { case STARTING: START if (runVmBackup()) { updateVmBackupPhase(VmBackupPhase.READY); } else { setCommandStatus(CommandStatus.FAILED); } END log.info("Ready to start image transfers using backup URLs"); break; case READY: return true; case FINALIZING: finalizeVmBackup(); setCommandStatus(CommandStatus.SUCCEEDED); break; } persistCommandIfNeeded(); return true; } IMHO can be inserted into "runVmBackup()". "setCommandStatus(CommandStatus.FAILED);" instead of "return false;". "updateVmBackupPhase(VmBackupPhase.READY);" instead of "return true;".

Target:
public boolean performNextOperation(int completedChildCount) { restoreCommandState(); switch (getParameters().getVmBackup().getPhase()) { case STARTING: if (runVmBackup()) { updateVmBackupPhase(VmBackupPhase.READY); log.info("Ready to start image transfers using backup URLs"); } else { setCommandStatus(CommandStatus.FAILED); } break; case READY: return true; case FINALIZING: finalizeVmBackup(); setCommandStatus(CommandStatus.SUCCEEDED); break; } persistCommandIfNeeded(); return true; }
Source:
private static Cluster createClusterWithNoCpuName() { Cluster group = new Cluster(); group.setName("Default"); group.setCpuName(""); group.setId(DEFAULT_CLUSTER_ID); group.setCompatibilityVersion(VERSION_1_1); group.setStoragePoolId(DC_ID1); group.setArchitecture(ArchitectureType.undefined); group.setClusterPolicyId(Guid.newGuid()); group.setMaxVdsMemoryOverCommit(100); START group.setBiosType(BiosType.CLUSTER_DEFAULT); END return group; } that's invalid anyway, isn't it? what's the meaning of CLUSTER_DEFAULT on cluster, you can never set it. autodetect==null, and then only concrete values are allowed

Target:
private static Cluster createClusterWithNoCpuName() { Cluster group = new Cluster(); group.setName("Default"); group.setCpuName(""); group.setId(DEFAULT_CLUSTER_ID); group.setCompatibilityVersion(VERSION_1_1); group.setStoragePoolId(DC_ID1); group.setArchitecture(ArchitectureType.undefined); group.setClusterPolicyId(Guid.newGuid()); group.setMaxVdsMemoryOverCommit(100); return group; }
Source:
public VmBackupInfo(Map<String, Object> innerMap) { super(innerMap); disks = (Map<String, Object>) innerMap.get(VdsProperties.vm_disks); Object tempObj = innerMap.get(VdsProperties.CHECKPOINT); if (tempObj != null) { checkpoint = (String) START innerMap.get(VdsProperties.CHECKPOINT); END } } Why? Just case tempObj

Target:
public VmBackupInfo(Map<String, Object> innerMap) { super(innerMap); disks = (Map<String, Object>) innerMap.get(VdsProperties.vm_disks); Object tempObj = innerMap.get(VdsProperties.CHECKPOINT); if (tempObj != null) { checkpoint = (String) tempObj; } }
Source:
private String buildMessage(int from, int to, int total) { if (total > 0) { return messages.fromIndexToIndexOfTotalCount(from, to, total); START } else { END return messages.fromIndexToIndex(from, to); } } Can be removed

Target:
private String buildMessage(int from, int to, int total) { if (total > 0) { return messages.fromIndexToIndexOfTotalCount(from, to, total); } return messages.fromIndexToIndex(from, to); }
Source:
private void resetVmAttributes(VmDynamic vm) { vm.setMigratingToVds(null); vm.getGraphicsInfos().clear(); vm.setGuestCurrentUserName(null); vm.setConsoleCurrentUserName(null); vm.setConsoleUserId(null); START vm.setClientIp(""); END vm.setIp(null); vm.setFqdn(null); vm.setCpuName(null); vm.setEmulatedMachine(null); vm.setVolatileRun(false); vm.setGuestAgentNicsHash(0); } Good, if there are no other places where it may be set to null. But I would rather fix the comparison.

Target:
private void resetVmAttributes(VmDynamic vm) { vm.setMigratingToVds(null); vm.getGraphicsInfos().clear(); vm.setGuestCurrentUserName(null); vm.setConsoleCurrentUserName(null); vm.setConsoleUserId(null); vm.setClientIp(null); vm.setIp(null); vm.setFqdn(null); vm.setCpuName(null); vm.setEmulatedMachine(null); vm.setVolatileRun(false); vm.setGuestAgentNicsHash(0); }
Source:
private boolean addImageTicketToProxy(Guid imagedTicketId, String hostUri) { // Create image ticket String START imagePath = END String.format( // ToDo: move formatting to an helper for reuse in ImageTransfer "%s%s/%s", hostUri, IMAGES_PATH, imagedTicketId); ImageTicket imageTicket = buildImageTicket(imagedTicketId, imagePath); log.info("Adding image ticket to ovirt-imageio-proxy, id {}", imagedTicketId); try { getProxyClient().putTicket(imageTicket); } catch (RuntimeException e) { log.error("Failed to add image ticket to ovirt-imageio-proxy: {}", e.getMessage(), e); return false; } return true; } This is a URL (.e.g "file:///path/to/image" or "nbd:unix:/path/to/socket:exportname=vda"). String url = ...

Target:
private boolean addImageTicketToProxy(Guid imagedTicketId, String hostUri) { // Create image ticket String url = String.format( // ToDo: move formatting to an helper for reuse in ImageTransfer "%s%s/%s", hostUri, IMAGES_PATH, imagedTicketId); ImageTicket imageTicket = buildImageTicket(imagedTicketId, url); log.info("Adding image ticket to ovirt-imageio-proxy, id {}", imagedTicketId); try { getProxyClient().putTicket(imageTicket); } catch (RuntimeException e) { log.error("Failed to add image ticket to ovirt-imageio-proxy: {}", e.getMessage(), e); return false; } return true; }
Source:
START public static END TransferDiskImageParameters createInitParams(DiskImage diskImage) { TransferDiskImageParameters parameters = new TransferDiskImageParameters(); parameters.setTransferType(TransferType.Download); parameters.setImageGroupID(diskImage.getId()); String fileExtension = diskImage.getVolumeFormat() == VolumeFormat.COW ? ".qcow2" : ".raw"; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setDownloadFilename(diskImage.getDiskAlias() + fileExtension); //$NON-NLS-1$ parameters.setTransferSize(diskImage.getActualSizeInBytes()); parameters.setTransferringViaBrowser(true); return parameters; } Not sure whether worth doing, but since the only usage is "DownloadImageManager" (that is in the same package), it is possible to remove "public".

Target:
static TransferDiskImageParameters createInitParams(DiskImage diskImage) { TransferDiskImageParameters parameters = new TransferDiskImageParameters(); parameters.setTransferType(TransferType.Download); parameters.setImageGroupID(diskImage.getId()); String fileExtension = diskImage.getVolumeFormat() == VolumeFormat.COW ? ".qcow2" : ".raw"; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setDownloadFilename(diskImage.getDiskAlias() + fileExtension); //$NON-NLS-1$ parameters.setTransferSize(diskImage.getActualSizeInBytes()); parameters.setTransferringViaBrowser(true); return parameters; }
Source:
START public TransferDiskImageParameters createInitParams(DiskImage diskImage) { END TransferDiskImageParameters parameters = new TransferDiskImageParameters(); parameters.setTransferType(TransferType.Download); parameters.setImageGroupID(diskImage.getId()); String fileExtension = diskImage.getVolumeFormat() == VolumeFormat.COW ? ".qcow2" : ".raw"; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setDownloadFilename(diskImage.getDiskAlias() + fileExtension); //$NON-NLS-1$ parameters.setTransferSize(diskImage.getActualSizeInBytes()); parameters.setTransferringViaBrowser(true); return parameters; } can be static to avoid to avoid redundant object creation on startDownload

Target:
public static TransferDiskImageParameters createInitParams(DiskImage diskImage) { TransferDiskImageParameters parameters = new TransferDiskImageParameters(); parameters.setTransferType(TransferType.Download); parameters.setImageGroupID(diskImage.getId()); String fileExtension = diskImage.getVolumeFormat() == VolumeFormat.COW ? ".qcow2" : ".raw"; //$NON-NLS-1$ //$NON-NLS-2$ parameters.setDownloadFilename(diskImage.getDiskAlias() + fileExtension); //$NON-NLS-1$ parameters.setTransferSize(diskImage.getActualSizeInBytes()); parameters.setTransferringViaBrowser(true); return parameters; }
Source:
private boolean isAssignQuotaAllowed() { List<Disk> disks = getSelectedItems(); return disks != null && START disks.size() != 0; END } can be !disks.isEmpty()

Target:
private boolean isAssignQuotaAllowed() { List<Disk> disks = getSelectedItems(); return disks != null && !disks.isEmpty(); }
Source:
private START List performVmCheckpointsOperation(VDSCommandType END vdsCommandType, VdsAndVmIDVDSParametersBase params) { VDSReturnValue vdsRetVal; try { vdsRetVal = runVdsCommand(vdsCommandType, params); if (!vdsRetVal.getSucceeded()) { EngineException engineException = new EngineException(); engineException.setVdsError(vdsRetVal.getVdsError()); throw engineException; } } catch (EngineException e) { log.error("Failed to execute '{}': {}", vdsCommandType, e); throw e; } return (List) vdsRetVal.getReturnValue(); } Can it be a List of specific objects, not just "List"?

Target:
private List<Guid> performVmCheckpointsOperation(VDSCommandType vdsCommandType, VdsAndVmIDVDSParametersBase params) { VDSReturnValue vdsRetVal; try { vdsRetVal = runVdsCommand(vdsCommandType, params); if (!vdsRetVal.getSucceeded()) { EngineException engineException = new EngineException(); engineException.setVdsError(vdsRetVal.getVdsError()); throw engineException; } } catch (EngineException e) { log.error("Failed to execute '{}': {}", vdsCommandType, e); throw e; } return (List<Guid>) vdsRetVal.getReturnValue(); }
Source:
private boolean shouldUpdateVmsAndTemplates() { return isVersionChanged() || isBiosTypeChanged() || isCpuNameChanged() START || oldCluster.getArchitecture() == getArchitecture(); END } The condition was inverted, wasn't it?

Target:
private boolean shouldUpdateVmsAndTemplates() { return isVersionChanged() || isBiosTypeChanged() || isCpuNameChanged() || oldCluster.getArchitecture() != getArchitecture(); }
Source:
protected boolean validate() { if (!(getSourceVmFromDb().getStatus() == VMStatus.Suspended || getSourceVmFromDb().isDown())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_IS_NOT_DOWN); } DiskImagesValidator diskImagesValidator = new DiskImagesValidator(diskImagesFromConfiguration); START validate(diskImagesValidator.diskImagesNotIllegal()); END return super.validate(); } no need for `if (!validate(diskImagesValidator.diskImagesNotIllegal()) { ... }` ?

Target:
protected boolean validate() { if (!(getSourceVmFromDb().getStatus() == VMStatus.Suspended || getSourceVmFromDb().isDown())) { return failValidation(EngineMessage.ACTION_TYPE_FAILED_VM_IS_NOT_DOWN); } DiskImagesValidator diskImagesValidator = new DiskImagesValidator(diskImagesFromConfiguration); if (!validate(diskImagesValidator.diskImagesNotIllegal())) { return false; } return super.validate(); }
Source:
public boolean isIpv4InSubnet(String networkAddress, String mask, String START candidateAddress) { END String netmask = IPv4MaskValidator.getInstance().getOctetNetmask(mask); Ipv4NetworkRange ipv4NetworkRange = ipAddressConverter.createIpv4NetworkRange(networkAddress, netmask); BigInteger ipToTestInt = ipAddressConverter.convertIpAddressToBigInt(candidateAddress); return ipv4NetworkRange.isInRange(ipToTestInt); } Please handle that candidateAddress might be null.

Target:
public boolean isIpv4InSubnet(String networkAddress, String mask, String candidateAddress) { if (candidateAddress == null) { return true; } String netmask = IPv4MaskValidator.getInstance().getOctetNetmask(mask); Ipv4NetworkRange ipv4NetworkRange = ipAddressConverter.createIpv4NetworkRange(networkAddress, netmask); BigInteger ipToTestInt = ipAddressConverter.convertIpAddressToBigInt(candidateAddress); return ipv4NetworkRange.isInRange(ipToTestInt); }
Source:
protected void createCommentEditor(final int suggestRow, final int column, final int line, final short file) { START createCommentEditor(suggestRow, column, line, file, ""); END } But existing rows use null not "" for the parentUuid.

Target:
protected void createCommentEditor(final int suggestRow, final int column, final int line, final short file) { createCommentEditor(suggestRow, column, line, file, null /* no parent */); }
Source:
private static List<String> optionalList(final Config config, final String name) { String s[] = config.getStringList("ldap", null, name); START if(s == null || s.length == 0) { END return null; } final List<String> vlist = new ArrayList<String>(); for(int i = 0; i < s.length; i++) { vlist.add(s[i]); } return vlist; } IIRC getStringList returns String[0] when there are no elements, thus you will never get null here.

Target:
private static List<String> optionalList(final Config config, final String name) { String s[] = config.getStringList("ldap", null, name); return Arrays.asList(s); }
Source:
SshKeyCacheEntry(final AccountSshKey.Id i, final PublicKey k) { id = i; publicKey = k; START lastUsed = null; END } Hmm, our caller should be invoking us with a full AccountSshKey object in hand. They should pass down the last used time from the database column to initialize this field, rather than always assume it is null.

Target:
SshKeyCacheEntry(final AccountSshKey.Id i, final PublicKey k) { id = i; publicKey = k; }
Source:
public void addChangeListener(ChangeListener listener, IdentifiedUser user) { START ChangeListenerHolder holder = new ChangeListenerHolder(listener, user); END listeners.put(listener, holder); } Style-nit: The code would be shorter if you remove the holder variable: listeners.put(listener, new ChangeListenerHolder(listener, user));

Target:
public void addChangeListener(ChangeListener listener, IdentifiedUser user) { listeners.put(listener, new ChangeListenerHolder(listener, user)); }
Source:
private boolean isVisibleTo(Change change, IdentifiedUser user) { START final ProjectState pe = projectCache.get(change.getProject()); END final ProjectControl pc = pe.controlFor(user); final RefControl rc = pc.controlForRef(change.getDest().get()); return rc.isVisible(); } This can return null if the project suddenly were to disappear. I think we should guard against that by testing for null and skipping the rest of the method: if (pe == null) { return false; }

Target:
private boolean isVisibleTo(Change change, IdentifiedUser user) { final ProjectState pe = projectCache.get(change.getProject()); if (pe == null) { return false; } final ProjectControl pc = pe.controlFor(user); return pc.controlFor(change).isVisible(); }
Source:
START public InheritedRefRight(){ END } Make this protected, it exists only for the JSON serialization library.

Target:
protected InheritedRefRight(){ }
Source:
protected ListBranchesResult() { START this(new ArrayList<Branch>(), false); END } Since this constructor exists only for the JSON encoding, which will recursively process and populate the fields, there's no need to call this(). Just accept the default initialization of false/null for the fields and let the JSON decoder finish building the object.

Target:
protected ListBranchesResult() { }
Source:
public int allowedValueForRef(Set<AccountGroup.Id> groups) { int val = Integer.MIN_VALUE; for (RefRight right : rights) { if (groups.contains(right.getAccountGroupId())) { START if ((val < 0 && right.getMaxValue() > 0)) { END // If one of the user's groups had denied them access, but // this group grants them access, prefer the grant over // the denial. We have to break the tie somehow and we // prefer being "more open" to being "more closed". // val = Math.max(right.getMaxValue(), val); } } } return val; } Drop this if entirely. The if-else block right here can just be simplified down to the val = Math.max(...) expression.

Target:
public int allowedValueForRef(Set<AccountGroup.Id> groups) { int val = Integer.MIN_VALUE; for (RefRight right : rights) { if (groups.contains(right.getAccountGroupId())) { val = Math.max(right.getMaxValue(), val); } } return val; }
Source:
ProjectQoSFilter(final Provider<CurrentUser> userProvider, QueueProvider queue, final ServletContext context, @GerritServerConfig final Config cfg) { this.userProvider = userProvider; START this.executor = queue.getInteractiveQueue(); END this.context = context; this.maxWait = getTimeUnit(cfg, "httpd", null, "maxwait", 5, MINUTES); } No, you really need to do this selection dynamically based on the current user. Batch jobs coming in over the http:// interface for fetch should get degraded service just like when they come in over ssh://.

Target:
ProjectQoSFilter(final Provider<CurrentUser> userProvider, QueueProvider queue, final ServletContext context, @GerritServerConfig final Config cfg) { this.userProvider = userProvider; this.queue = queue; this.context = context; this.maxWait = getTimeUnit(cfg, "httpd", null, "maxwait", 5, MINUTES); }
Source:
public static String invertSortKey(String sk) { if (sk.equalsIgnoreCase("z")) { return "/"; // The character before '0' START } END StringBuilder inv = new StringBuilder(16); inv.setLength(16); formatHexLong(inv, -1l - parseUnsignedHex(sk)); return inv.toString(); } For completeness should we also invert '/' to 'z' ?

Target:
public static String invertSortKey(String sk) { if (sk.equalsIgnoreCase("z")) { return "/"; // The character before '0' } else if (sk.equalsIgnoreCase("/")) { return "z"; } StringBuilder inv = new StringBuilder(16); inv.setLength(16); formatHexLong(inv, -1l - parseUnsignedHex(sk)); return inv.toString(); }
Source:
public void testCreateSchema_DefaultAccess_AnonymousUsers() throws OrmException { db.create(); final SystemConfig config = db.getSystemConfig(); START assertDefaultRight(RefRight.REGEX_SYMBOL+"refs/*", config.anonymousGroupId, END ApprovalCategory.READ, 1, 1); } Style-nit: Spaces around operators like +.

Target:
public void testCreateSchema_DefaultAccess_AnonymousUsers() throws OrmException { db.create(); final SystemConfig config = db.getSystemConfig(); assertDefaultRight("refs/*", config.anonymousGroupId, ApprovalCategory.READ, 1, 1); }
Source:
public SessionCacheCleaner( SchemaFactory<ReviewDb> reviewDbFactory, @Named(WebSession.CACHE_NAME) final Cache<ActiveSession.Key, ActiveSession> cache) throws OrmException { START this.activeSessionAccess = reviewDbFactory.open().activeSessions(); END this.cache = cache; } Please don't hold onto the database connection for 12 hours, open and close it during the run method each time you execute. These are borrowed from a small pool, and keeping it tied up for hours with no use isn't friendly to the other threads in the JVM.

Target:
public SessionCacheCleaner( SchemaFactory<ReviewDb> reviewDbFactory, @Named(WebSession.CACHE_NAME) final Cache<ActiveSession.Key, ActiveSession> cache) { this.reviewDbFactory = reviewDbFactory; this.cache = cache; }
Source:
public AccountDiffPreference getAccountDiffPreference() { START AccountDiffPreference diffPref = null; END try { diffPref = dbProvider.get().accountDiffPreferences().get(getAccountId()); if (diffPref == null) { return AccountDiffPreference.createDefault(getAccountId()); } } catch (OrmException e) { log.warn("Cannot query account diff preferences", e); } return diffPref; } Please don't initialize a local variable to null. Instead leave it uninitialized so the compiler can prove we have correctly populated it before use. Right now this is hiding a bug here where the diffPref can be null if the database threw an exception. That would probably crash the JSON encoder in HostPageServlet. If the database fails, we should return a default preference after logging the warning here.

Target:
public AccountDiffPreference getAccountDiffPreference() { AccountDiffPreference diffPref; try { diffPref = dbProvider.get().accountDiffPreferences().get(getAccountId()); if (diffPref == null) { diffPref = AccountDiffPreference.createDefault(getAccountId()); } } catch (OrmException e) { log.warn("Cannot query account diff preferences", e); diffPref = AccountDiffPreference.createDefault(getAccountId()); } return diffPref; }
Source:
void onUpdate(ClickEvent event) { update(); if (Gerrit.isSignedIn()) { START persistDiffPreferences(); END } } This should be in the update() method below, ensuring that we save preferences even if we were invoked by the key binding to "Enter", setup in our constructor.

Target:
void onUpdate(ClickEvent event) { update(); }
Source:
private void deactivate() { if (activePatchSetId != -1) { PatchSetComplexDisclosurePanel patchSetPanel = patchSetPanels.get(activePatchSetId); START if (patchSetPanel != null) { END patchSetPanel.setActive(false); } activePatchSetId = -1; } } I can't seem to reproduce this failure. Can you update the commit message to better explain under what condition we don't have a panel, but think we should?

Target:
private void deactivate() { if (activePatchSetId != -1) { PatchSetComplexDisclosurePanel patchSetPanel = patchSetPanels.get(activePatchSetId); patchSetPanel.setActive(false); activePatchSetId = -1; } }
Source:
START public SshKeyCacheEntryIterable(Iterable<SshKeyCacheEntry> sshKeyIter) { END this.sshKeyIter = sshKeyIter; } This doesn't have to be public. Just use default package access since only thee cache impl in this package has to see it.

Target:
SshKeyCacheEntryIterable(Iterable<SshKeyCacheEntry> sshKeyIter) { this.sshKeyIter = sshKeyIter; }
Source:
START public Iterable<SshKeyCacheEntry> getSshKeyCacheEntries() { END return sshKeyIter; } This doesn't have to be public. Just use default package access since only thee cache impl in this package has to see it.

Target:
Iterable<SshKeyCacheEntry> getSshKeyCacheEntries() { return sshKeyIter; }
Source:
public static BaseEdit fromEdit(Edit e) { BaseEdit goe = new BaseEdit(e.getBeginA(), e.getEndA(), e.getBeginB(), e.getEndB()); START if (e instanceof ReplaceEdit) { END ReplaceEdit re = (ReplaceEdit) e; List<BaseEdit> intlEdits = BaseEdit.fromEditList(re.getInternalEdits()); goe = new com.google.gerrit.prettify.common.ReplaceEdit(goe, intlEdits); } return goe; } We should just remove ReplaceEdit. Its our own private hacked class.

Target:
public static BaseEdit fromEdit(Edit e) { BaseEdit goe = new BaseEdit(e.getBeginA(), e.getEndA(), e.getBeginB(), e.getEndB()); return goe; }
Source:
public static List<BaseEdit> fromEditList(List<Edit> edits) { ArrayList<BaseEdit> gwtOrmEdits = new ArrayList<BaseEdit>(edits.size()); for (Edit e : edits) { START gwtOrmEdits.add(fromEdit(e)); END } return Collections.unmodifiableList(gwtOrmEdits); } The name "gwtOrmEdits" doesn't mean much here. Maybe "res", "result", "out", "r" would be better?

Target:
public static List<BaseEdit> fromEditList(List<Edit> edits) { ArrayList<BaseEdit> out = new ArrayList<BaseEdit>(edits.size()); for (Edit e : edits) { out.add(fromEdit(e)); } return Collections.unmodifiableList(out); }