auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void run() { try { while (!shouldStop()) { isRunning = true; List rowValues = new ArrayList<String>(); synchronized (resultHandler) { for (MonitorDetails monitorDetails : MONITOR_DETAILS_LIST) { rowValues.clear(); try { StandardMBean bean = new StandardMBean(monitorDetails.getMonitor(), Monitor.class); Calendar calendar = new GregorianCalendar(); rowValues.add(monitorDetails); rowValues.add(((Monitor) bean.getImplementation()).getStat()); rowValues.add(DateUtil.DEFAULT_MS_DATE_FORMATTER.format(calendar.getTime())); Result result = new Result(ResultFileDetails.CSV, ResultFileDetails.CSV_MONITOR.getHeader().toString(), rowValues); resultHandler.write(result); } catch (Exception e) { throw new FileLoaderRuntimeException("Could not log monitor result.", e); } rowCount++; } try { Thread.sleep(getMonitorFrequency()); } catch (InterruptedException e) { <START> e.printStackTrace(); <END> } } } } finally { try { isRunning = false; if (resultHandler != null) { resultHandler.flush(); resultHandler.close(); } } catch (Exception e) { throw new FileLoaderRuntimeException("Could not close monitor results.", e); } } }</code><technical_language>catching interrupted exceptions, is a good practice set interrupted flag calling Thread.currentThread().interrupt();</technical_language>

Target:
public void run() { try { while (!shouldStop()) { isRunning = true; List rowValues = new ArrayList<String>(); synchronized (resultHandler) { for (MonitorDetails monitorDetails : MONITOR_DETAILS_LIST) { rowValues.clear(); try { StandardMBean bean = new StandardMBean(monitorDetails.getMonitor(), Monitor.class); Calendar calendar = new GregorianCalendar(); rowValues.add(monitorDetails); rowValues.add(((Monitor) bean.getImplementation()).getStat()); rowValues.add(DateUtil.DEFAULT_MS_DATE_FORMATTER.format(calendar.getTime())); Result result = new Result(ResultFileDetails.CSV, ResultFileDetails.CSV_MONITOR.getHeader().toString(), rowValues); resultHandler.write(result); } catch (Exception e) { throw new FileLoaderRuntimeException("Could not log monitor result.", e); } rowCount.getAndIncrement(); } try { Thread.sleep(getMonitorFrequency()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); e.printStackTrace(); } } } } finally { try { isRunning = false; if (resultHandler != null) { resultHandler.flush(); resultHandler.close(); } } catch (Exception e) { throw new FileLoaderRuntimeException("Could not close monitor results.", e); } } }
Source:
<code><START> public void updateIfNeeded(VdsDynamic vdsDynamic) { <END> VdsDynamic dbData = get(vdsDynamic.getId()); if (!dbData.equals(vdsDynamic)) { update(vdsDynamic); } else { log.info("Ignored an unneeded update of VdsDynamic"); } }</code><technical_language>Liran I thinking implementation in order easily extend other places of concerns is IMHO usages call update internal implementation check if update needed Other is IIRC infrastructure hierarchy implement in a higher level I solution more general , lets discuss offline</technical_language>

Target:
public void updateIfNeeded(VdsDynamic vdsDynamic) { VdsDynamic dbData = get(vdsDynamic.getId()); if (!dbData.equals(vdsDynamic)) { update(vdsDynamic); } else { log.debug("Ignored an unneeded update of VdsDynamic"); } }
Source:
<code>public int compareTo(@Nullable ITmfStateValue object) { <START> if (!(object instanceof IntegerStateValue)) { <END> return -1; } IntegerStateValue other = (IntegerStateValue) object; return Integer.compare(this.value, other.value); }</code><technical_language>also, comparison of similar types long doubles (checking for overflow)</technical_language>

Target:
public int compareTo(@Nullable ITmfStateValue object) { if (object == null) { return 1; } int result = 0; switch (object.getType()) { case INTEGER: IntegerStateValue other = (IntegerStateValue) object; result = Integer.compare(this.value, other.value); break; case DOUBLE: double otherDoubleValue = ((DoubleStateValue) object).unboxDouble(); double thisDoubleValue = this.value; result = Double.compare(thisDoubleValue, otherDoubleValue); break; case LONG: long otherLongValue = ((LongStateValue) object).unboxLong(); result = Long.compare(this.value, otherLongValue); break; case NULL: result = 1; break; case STRING: result = -1; break; default: break; } return result; }
Source:
<code>public void run() { try { while <START> (!end || <END> !queue.isEmpty()) { RDFRecordedAction action = queue.take(); action.exec(targetHandler); } } catch (RDFHandlerException e) { onFailureListener.accept(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); onFailureListener.accept(e); } }</code><technical_language>Thread.isInterrupted() ? I discussion already, memory need refreshed</technical_language>

Target:
public void run() { try { while (!end || !queue.isEmpty()) { RDFRecordedAction action = queue.poll(100, MILLISECONDS); if (action != null) { action.exec(targetHandler); } } } catch (RDFHandlerException e) { onFailureListener.accept(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); onFailureListener.accept(e); } }
Source:
<code>private Object doDeleteRange(ConsecutiveNarrowTable table, int numBatches) { <START> Iterable<RangeRequest> rangeRequests; <END> if (numBatches == 1) { rangeRequests = ImmutableList.of(RangeRequest.all()); } else { rangeRequests = table.getRangeRequests(1, table.getNumRows() / numBatches); } rangeRequests.forEach(rangeRequest -> table.getKvs().deleteRange(table.getTableRef(), rangeRequest)); return rangeRequests; }</code><technical_language>? : syntax join declaration assignment. I prefer this way, block it</technical_language>

Target:
private Object doDeleteRange(ConsecutiveNarrowTable table, int numBatches) { Iterable<RangeRequest> rangeRequests = numBatches == 1 ? ImmutableList.of(RangeRequest.all()) : table.getRangeRequests(1, table.getNumRows() / numBatches); rangeRequests.forEach(rangeRequest -> table.getKvs().deleteRange(table.getTableRef(), rangeRequest)); return rangeRequests; }
Source:
<code>public static void createProjects( final Set<ProjectRecord> projectsToCreate, final Repository repository, final IWorkingSet[] selectedWorkingSets, IProgressMonitor monitor) throws CoreException, OperationCanceledException { IWorkspaceRunnable wsr = new IWorkspaceRunnable() { public void run(IProgressMonitor actMonitor) throws CoreException { IWorkingSetManager workingSetManager = PlatformUI .getWorkbench().getWorkingSetManager(); try { actMonitor.beginTask("", projectsToCreate.size()); <START> if (actMonitor.isCanceled()) { <END> throw new OperationCanceledException(); } for (ProjectRecord projectRecord : projectsToCreate) { if (actMonitor.isCanceled()) { throw new OperationCanceledException(); } actMonitor.setTaskName(projectRecord.getProjectLabel()); IProject project = createExistingProject(projectRecord, new SubProgressMonitor(actMonitor, 1)); if (repository != null) { ConnectProviderOperation connectProviderOperation = new ConnectProviderOperation( project, repository.getDirectory()); connectProviderOperation.execute(actMonitor); } if (selectedWorkingSets != null && selectedWorkingSets.length > 0) workingSetManager.addToWorkingSets(project, selectedWorkingSets); } } finally { actMonitor.done(); } } }; ResourcesPlugin.getWorkspace().run(wsr, monitor); }</code><technical_language>style nit: braces</technical_language>

Target:
public static void createProjects( final Set<ProjectRecord> projectsToCreate, final Repository repository, final IWorkingSet[] selectedWorkingSets, IProgressMonitor monitor) throws CoreException, OperationCanceledException { IWorkspaceRunnable wsr = new IWorkspaceRunnable() { public void run(IProgressMonitor actMonitor) throws CoreException { IWorkingSetManager workingSetManager = PlatformUI .getWorkbench().getWorkingSetManager(); try { actMonitor.beginTask("", projectsToCreate.size()); if (actMonitor.isCanceled()) throw new OperationCanceledException(); for (ProjectRecord projectRecord : projectsToCreate) { if (actMonitor.isCanceled()) throw new OperationCanceledException(); actMonitor.setTaskName(projectRecord.getProjectLabel()); IProject project = createExistingProject(projectRecord, new SubProgressMonitor(actMonitor, 1)); if (repository != null) { ConnectProviderOperation connectProviderOperation = new ConnectProviderOperation( project, repository.getDirectory()); connectProviderOperation.execute(actMonitor); } if (selectedWorkingSets != null && selectedWorkingSets.length > 0) workingSetManager.addToWorkingSets(project, selectedWorkingSets); } } finally { actMonitor.done(); } } }; ResourcesPlugin.getWorkspace().run(wsr, monitor); }
Source:
<code>public int getCookieMaxAge() { <START> return "".equals(this.cookieValue) ? 0 : this.cookieMaxAge; <END> }</code><technical_language>I this means empty String value. code sets cookie "" set max age too</technical_language>

Target:
public int getCookieMaxAge() { return this.cookieMaxAge; }
Source:
<code>private static BoundCustomizer defaultParameterCustomizer(Class<?> type, Method method, Parameter parameter, Integer i) { return (stmt, args) -> getDefaultParameterCustomizerFactory(stmt) .createForParameter(null, type, method, parameter, i) <START> .apply(stmt, args[i]); <END> }</code><technical_language>introduce a separate factory interface for default customizer, similar #754 is default handlers. feels weird pass a null for annotation, case is specifically for _is_ annotation. e.g. java interface DefaultParameterCustomizerFactory { SqlStatementParameterCustomizer createForParameter(Class<?> sqlObjectType, Method method, Parameter param, int index); }</technical_language>

Target:
private static BoundCustomizer defaultParameterCustomizer(Class<?> type, Method method, Parameter parameter, Integer i) { return (stmt, args) -> getDefaultParameterCustomizerFactory(stmt) .createForParameter(type, method, parameter, i) .apply(stmt, args[i]); }
Source:
<code><START> public static int compareRecords(String key, String value, StructuredRecord structuredRecord1, <END> StructuredRecord structuredRecord2) { int res; Schema.Type type = structuredRecord1.getSchema().getField(key).getSchema().getType(); if (type.equals(Schema.Type.STRING)) { res = getSortingOrder(value) * ((String) structuredRecord1.get(key)) .compareTo((String) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.INT)) { res = getSortingOrder(value) * Integer.compare((Integer) structuredRecord1.get(key), (Integer) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.LONG)) { res = getSortingOrder(value) * Long.compare((Long) structuredRecord1.get(key), (Long) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.FLOAT)) { res = getSortingOrder(value) * Float.compare((Float) structuredRecord1.get(key), (Float) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.DOUBLE)) { res = getSortingOrder(value) * Double.compare((Double) structuredRecord1.get(key), (Double) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.BYTES)) { res = getSortingOrder(value) * Byte.compare((Byte) structuredRecord1.get(key), (Byte) structuredRecord2.get(key)); } else { throw new IllegalArgumentException("Sorting can be performed only on the following CDAP data types: " + "String, Int, Long, Float, Double, Byte"); } return res; }</code><technical_language>Comparison support recursive complex records. want implement a recursive function for that. StructuredRecord basic types Record, Union, etc</technical_language>

Target:
public static int compareRecords(String key, String value, StructuredRecord structuredRecord1, StructuredRecord structuredRecord2) { int res; res = compareNull(key, structuredRecord1, structuredRecord2); if (res == DEFAULT_COMP_VALUE) { Schema schema = structuredRecord1.getSchema().getField(key).getSchema(); Schema.Type type = schema.isNullableSimple() ? schema.getNonNullable().getType() : schema.getType(); if (type.equals(Schema.Type.STRING)) { res = getSortingOrder(value) * ((String) structuredRecord1.get(key)) .compareTo((String) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.INT)) { res = getSortingOrder(value) * Integer.compare((Integer) structuredRecord1.get(key), (Integer) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.LONG)) { res = getSortingOrder(value) * Long.compare((Long) structuredRecord1.get(key), (Long) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.FLOAT)) { res = getSortingOrder(value) * Float.compare((Float) structuredRecord1.get(key), (Float) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.DOUBLE)) { res = getSortingOrder(value) * Double.compare((Double) structuredRecord1.get(key), (Double) structuredRecord2.get(key)); } else if (type.equals(Schema.Type.BYTES)) { res = getSortingOrder(value) * Byte.compare((Byte) structuredRecord1.get(key), (Byte) structuredRecord2.get(key)); } else { throw new IllegalArgumentException("Sorting can be performed only on the following CDAP data types: " + "String, Int, Long, Float, Double, Byte"); } } return res; }
Source:
<code>public ReportedConfigurations reportConfigurationsOnHost () { ReportedConfigurations result = new ReportedConfigurations(); Integer networkMtu = network.getMtu() == 0 ? NetworkUtils.getDefaultMtu() : network.getMtu(); result.add(ReportedConfigurationType.MTU, iface.getMtu(), networkMtu, isNetworkMtuInSync()); result.add(ReportedConfigurationType.BRIDGED, iface.isBridged(), network.isVmNetwork()); result.add(ReportedConfigurationType.VLAN, iface.getVlanId(), network.getVlanId()); result.add(ReportedConfigurationType.SWITCH_TYPE, iface.getReportedSwitchType(), cluster.getRequiredSwitchTypeForCluster()); addReportedIpv4Configuration(result); boolean reportHostQos = ifaceQos != null || hostNetworkQos != null; if (reportHostQos) { result.add(OUT_AVERAGE_LINK_SHARE, getOutAverageLinkshare(ifaceQos), getOutAverageLinkshare(hostNetworkQos)); result.add(OUT_AVERAGE_UPPER_LIMIT, getOutAverageUpperlimit(ifaceQos), getOutAverageUpperlimit(hostNetworkQos)); result.add(OUT_AVERAGE_REAL_TIME, getOutAverageRealtime(ifaceQos), getOutAverageRealtime(hostNetworkQos)); } addDnsConfiguration(result); boolean defaultRouteSupported = FeatureSupported.defaultRouteSupported(cluster.getCompatibilityVersion()); result.add(DEFAULT_ROUTE, iface.isIpv4DefaultRoute(), <START> !defaultRouteSupported || isDefaultRouteNetwork); <END> return result; }</code><technical_language>if defaultRouteSupported == false iface.isIpv4DefaultRoute() == true actual == expected? is this a desired result</technical_language>

Target:
public ReportedConfigurations reportConfigurationsOnHost () { ReportedConfigurations result = new ReportedConfigurations(); Integer networkMtu = network.getMtu() == 0 ? NetworkUtils.getDefaultMtu() : network.getMtu(); result.add(ReportedConfigurationType.MTU, iface.getMtu(), networkMtu, isNetworkMtuInSync()); result.add(ReportedConfigurationType.BRIDGED, iface.isBridged(), network.isVmNetwork()); result.add(ReportedConfigurationType.VLAN, iface.getVlanId(), network.getVlanId()); result.add(ReportedConfigurationType.SWITCH_TYPE, iface.getReportedSwitchType(), cluster.getRequiredSwitchTypeForCluster()); addReportedIpv4Configuration(result); boolean reportHostQos = ifaceQos != null || hostNetworkQos != null; if (reportHostQos) { result.add(OUT_AVERAGE_LINK_SHARE, getOutAverageLinkshare(ifaceQos), getOutAverageLinkshare(hostNetworkQos)); result.add(OUT_AVERAGE_UPPER_LIMIT, getOutAverageUpperlimit(ifaceQos), getOutAverageUpperlimit(hostNetworkQos)); result.add(OUT_AVERAGE_REAL_TIME, getOutAverageRealtime(ifaceQos), getOutAverageRealtime(hostNetworkQos)); } addDnsConfiguration(result); boolean defaultRouteSupported = FeatureSupported.defaultRouteSupported(cluster.getCompatibilityVersion()); result.add(DEFAULT_ROUTE, iface.isIpv4DefaultRoute(), isDefaultRouteNetwork, !defaultRouteSupported || Objects.equals(iface.isIpv4DefaultRoute(), isDefaultRouteNetwork)); return result; }
Source:
<code>public void testExecute() { aDeleteNodeCommand.execute(); hasExecuted = true; <START> try { <END> ArrayList<Node> aListNodesToBeRemoved = (ArrayList<Node>)(aNodesToBeRemoved.get(aGraph)); assertTrue(aListNodesToBeRemoved.contains((Node)aNode)); } catch (IllegalArgumentException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } try { assertTrue((boolean)aNeedsLayout.get(aGraph)); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }</code><technical_language>encapsulate exception handling in a method. done in TestPropertyChangeTracker.getPropertyName</technical_language>

Target:
public void testExecute() { aDeleteNodeCommand.execute(); ArrayList<Node> aListNodesToBeRemoved; try { aListNodesToBeRemoved = (ArrayList<Node>) (aNodesToBeRemoved.get(aGraph)); assertTrue(aListNodesToBeRemoved.contains((Node) aNode)); } catch (IllegalArgumentException | IllegalAccessException e1) { fail(); } }
Source:
<code>public void testScanExercise() { plugin.scanExercise(simpleAllTestsPassProject, "main.R"); File availablePointsJson = new File(simpleAllTestsPassProject.toAbsolutePath().toString() + "/.available_points.json"); <START> assertTrue(availablePointsJson.exists()); <END> }</code><technical_language>this pass if file is empty corrupted</technical_language>

Target:
public void testScanExercise() { plugin.scanExercise(simpleAllTestsPassProject, "main.R"); assertTrue(Files.exists(simpleAllTestsPassProject.resolve(".available_points.json"))); }
Source:
<code>public DiskImage createDisk(Guid domainId) { <START> DiskImage createdDistImage = new DiskImage(); <END> createdDistImage.setDiskInterface(DiskInterface.IDE); createdDistImage.setWipeAfterDelete(false); createdDistImage.setDiskAlias(OvfInfoFileConstants.OvfStoreDescriptionLabel); createdDistImage.setDiskDescription(OvfInfoFileConstants.OvfStoreDescriptionLabel); createdDistImage.setShareable(shouldOvfStoreBeShareable()); createdDistImage.setStorageIds(new ArrayList<>(Arrays.asList(domainId))); createdDistImage.setSize(SizeConverter.BYTES_IN_MB * 128); createdDistImage.setvolumeFormat(VolumeFormat.RAW); createdDistImage.setVolumeType(VolumeType.Preallocated); createdDistImage.setDescription("OVF store for domain " + domainId); Date creationDate = new Date(); createdDistImage.setCreationDate(creationDate); createdDistImage.setLastModified(creationDate); return createdDistImage; }</code><technical_language>createdDiskImage (k replaced t for some reason)</technical_language>

Target:
public DiskImage createDisk(Guid domainId) { DiskImage createdDiskImage = new DiskImage(); createdDiskImage.setDiskInterface(DiskInterface.IDE); createdDiskImage.setWipeAfterDelete(false); createdDiskImage.setDiskAlias(OvfInfoFileConstants.OvfStoreDescriptionLabel); createdDiskImage.setDiskDescription(OvfInfoFileConstants.OvfStoreDescriptionLabel); createdDiskImage.setShareable(shouldOvfStoreBeShareable()); createdDiskImage.setStorageIds(new ArrayList<>(Arrays.asList(domainId))); createdDiskImage.setSize(SizeConverter.BYTES_IN_MB * 128); createdDiskImage.setvolumeFormat(VolumeFormat.RAW); createdDiskImage.setVolumeType(VolumeType.Preallocated); createdDiskImage.setDescription("OVF store for domain " + domainId); Date creationDate = new Date(); createdDiskImage.setCreationDate(creationDate); createdDiskImage.setLastModified(creationDate); return createdDiskImage; }
Source:
<code>public void handleEvent(Event event) { EventContext ctx = event.getContext(); if (ctx instanceof DocumentEventContext) { DocumentEventContext docCtx = (DocumentEventContext) ctx; CoreSession session = docCtx.getCoreSession(); DocumentModel doc = docCtx.getSourceDocument(); if (doc == null) { return; } String docId = doc.getId(); TagService tagService = Framework.getService(TagService.class); if (doc instanceof DeletedDocumentModel) { tagService.removeTags(session, docId); return; } DocumentRef versionRef = (DocumentRef) ctx.getProperty("checkedInVersionRef"); <START> if (versionRef instanceof IdRef && Framework.getService(ConfigurationService.class).isBooleanPropertyFalse( <END> TagServiceImpl.FACETED_TAG_SERVICE_ENABLED)) { tagService.copyTags(session, docId, versionRef.toString()); } } }</code><technical_language>Do boolean facetedTags = Framework.getService(ConfigurationService.class).isBooleanPropertyTrue(TagServiceImpl.FACETED_TAG_SERVICE_ENABLED) if (versionRef instanceof IdRef && !facetedTags) for clarity</technical_language>

Target:
public void handleEvent(Event event) { EventContext ctx = event.getContext(); if (ctx instanceof DocumentEventContext) { DocumentEventContext docCtx = (DocumentEventContext) ctx; CoreSession session = docCtx.getCoreSession(); DocumentModel doc = docCtx.getSourceDocument(); if (doc == null) { return; } String docId = doc.getId(); TagService tagService = Framework.getService(TagService.class); if (doc instanceof DeletedDocumentModel) { tagService.removeTags(session, docId); return; } DocumentRef versionRef = (DocumentRef) ctx.getProperty("checkedInVersionRef"); boolean facetedTags = Framework.getService(ConfigurationService.class) .isBooleanPropertyTrue(TagServiceImpl.FACETED_TAG_SERVICE_ENABLED); if (versionRef instanceof IdRef && !facetedTags) { tagService.copyTags(session, docId, versionRef.toString()); } } }
Source:
<code>public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveShellChecked(event); DirectoryDialog dlg = new DirectoryDialog(shell); dlg.setFilterPath(getFilterPath()); dlg.setText(Messages.DownloadFilesHandler_folderDlg_text); dlg.setMessage(Messages.DownloadFilesHandler_folderDlg_message); final String destination = dlg.open(); if (destination == null) return null; File destinationFile = new File(destination); saveFilterPath(destinationFile); IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); List<IFSTreeNode> nodes = selection.toList(); IRuntimeModel peer = nodes.get(0).getRuntimeModel(); peer.operationDownload(nodes, destinationFile, new MoveCopyCallback()).runInUserJob(new Callback() { @Override protected void internalDone(Object caller, IStatus status) { <START> if (status.isOK() || status.matches(IStatus.CANCEL)) { <END> IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(new Path(destination)); if (container != null) { try { container.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { e.printStackTrace(); } } } } }); return null; }</code><technical_language>I this is correct. Consider copying a tree of files, 50% fails due "disk full" --> want a refresh of 50%. correct check status all</technical_language>

Target:
public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveShellChecked(event); DirectoryDialog dlg = new DirectoryDialog(shell); dlg.setFilterPath(getFilterPath()); dlg.setText(Messages.DownloadFilesHandler_folderDlg_text); dlg.setMessage(Messages.DownloadFilesHandler_folderDlg_message); final String destination = dlg.open(); if (destination == null) return null; final File destinationFile = new File(destination); saveFilterPath(destinationFile); IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); List<IFSTreeNode> nodes = selection.toList(); IRuntimeModel peer = nodes.get(0).getRuntimeModel(); peer.operationDownload(nodes, destinationFile, new MoveCopyCallback()).runInUserJob(new Callback() { @Override protected void internalDone(Object caller, IStatus status) { for (IContainer container : ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(destinationFile.toURI())) { if (container != null) { try { container.refreshLocal(IResource.DEPTH_ONE, null); } catch (CoreException e) { e.printStackTrace(); } } } } }); return null; }
Source:
<code>public boolean next() { if ( added != null && added.hasNext() ) { this.node = added.next(); return true; } else { <START> LabelScanValueIndexProgressor p = progressor; <END> return p != null && p.next(); } }</code><technical_language>This change do anything? code exists in innerNext, right</technical_language>

Target:
public boolean next() { if ( added != null && added.hasNext() ) { this.node = added.next(); return true; } else { return innerNext(); } }
Source:
<code>public void deleteFromRevision() throws ConflictException { DocumentRevision deleted = datastore.deleteDocumentFromRevision(saved); Assert.assertNotNull("Deleted DocumentRevision is null", deleted); Assert.assertTrue("Deleted DocumentRevision is not flagged as deleted", deleted.isDeleted()); <START> } <END></code><technical_language>Tests for sending nil, out-of-date revision etc.</technical_language>

Target:
public void deleteFromRevision() throws ConflictException { BasicDocumentRevision deleted = datastore.deleteDocumentFromRevision(saved); Assert.assertNotNull("Deleted DocumentRevision is null", deleted); Assert.assertTrue("Deleted DocumentRevision is not flagged as deleted", deleted.isDeleted()); }
Source:
<code>public boolean post(Runnable runnable) { <START> RealmLog.error("RRRRR + " + handler); <END> return handler != null && handler.post(runnable); }</code><technical_language>RRRRR</technical_language>

Target:
public boolean post(Runnable runnable) { return handler != null && handler.post(runnable); }
Source:
<code>public void preTaskDeactivated(ITask task) { Repository repository = Activator.getDefault().getRepositoryCache() <START> .getAllRepositories()[0]; <END> try { BranchOperation operation = new BranchOperation(repository, Constants.R_REMOTES + "origin/" + Constants.MASTER); operation.execute(null); } catch (CoreException e) { e.printStackTrace(); } }</code><technical_language>if multiple repositories ? is right</technical_language>

Target:
public void preTaskDeactivated(ITask task) { for (Repository repo : usedRepositories) { try { BranchOperation operation = new BranchOperation(repo, Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER); operation.execute(null); } catch (CoreException e) { e.printStackTrace(); } } }
Source:
<code>void checkMismatch(Object expectedReceiver, List<String> expectedMethodNames) { String expectedMethodName = expectedMethodNames.get(0); <START> if(MetaClass.class.isInstance(expectedReceiver) && expectedMethodName.equals("invokeMethod")){ <END> return; } if(methodName.equals("methodMissing")){ return; } if (!expectedMethodNames.contains(methodName)) { MismatchHandler handler = handlers.get(); if (handler != null) { handler.handle(expectedReceiver, expectedMethodName, receiver, methodName); } } }</code><technical_language>KISS :-) suggestion if (expectedReceiver instanceof MetaClass && expectedMethodName.equals("invokeMethod")) {</technical_language>

Target:
void checkMismatch(Object expectedReceiver, List<String> expectedMethodNames) { String expectedMethodName = expectedMethodNames.get(0); if (expectedReceiver instanceof MetaClass && expectedMethodName.equals("invokeMethod")) { return; } if(methodName.equals("methodMissing")){ return; } if (!expectedMethodNames.contains(methodName)) { MismatchHandler handler = handlers.get(); if (handler != null) { handler.handle(expectedReceiver, expectedMethodName, receiver, methodName); } } }
Source:
<code>public void deleteBucket() throws Exception { final String bucketName = "test_delete_bucket"; try { final String expected = "Success: Deleted " + bucketName + " and all the objects contained in it."; Util.createBucket(client, bucketName); final CommandResponse response = Util.deleteBucket(client, bucketName); assertThat(response.getMessage(), is(expected)); <START> } finally { <END> } }</code><technical_language>is empty finally here</technical_language>

Target:
public void deleteBucket() throws Exception { final String bucketName = "test_delete_bucket"; final String expected = "Success: Deleted " + bucketName + " and all the objects contained in it."; Util.createBucket(client, bucketName); final CommandResponse response = Util.deleteBucket(client, bucketName); assertThat(response.getMessage(), is(expected)); }
Source:
<code>public void installMirrorController(MirrorController mirrorController) { <START> logger.debug("Remote control is being installed"); <END> if (postOffice != null) { postOffice.setMirrorControlSource(mirrorController); } this.mirrorControllerService = mirrorController; }</code><technical_language>Name in log message needs updated</technical_language>

Target:
public void installMirrorController(MirrorController mirrorController) { logger.debug("Mirror controller is being installed"); if (postOffice != null) { postOffice.setMirrorControlSource(mirrorController); } this.mirrorControllerService = mirrorController; }
Source:
<code>private Component buildCriteriaPane() { FormLayout layout = new FormLayout( "left:pref, 3dlu, fill:0:grow", "p, 3dlu, p, 3dlu, p" ); PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); JLabel criteriaLabel = new JLabel("Criteria"); criteriaLabel.setFont( criteriaLabel.getFont().deriveFont(Font.BOLD)); builder.add(criteriaLabel, cc.xy(1, 1)); <START> if ( checkValidMetaAnalysesAvailable( d_pm ) ) { <END> int row = 1; for(OutcomeMeasure out : d_metaPM.getCriteriaListModel()){ if(d_metaPM.getMetaAnalyses(out).isEmpty()) continue; row = addCriterionCheckbox(out, d_metaPM, layout, builder, cc, row); row = LayoutUtil.addRow(layout, row); builder.add(buildRadioButtonAnalysisPanel(out), cc.xy(3, row, CellConstraints.LEFT, CellConstraints.DEFAULT)); } } else { String warnHTMLText = "<i>Note</i>: To create a benefit-risk analysis, first create at least two " + "meta-analyses with at least two overlapping alternatives."; JComponent htmlField = AuxComponentFactory.createHtmlField( warnHTMLText ); htmlField.setPreferredSize( new Dimension( PREFERRED_COLUMN_SIZE.width - 5, 100 ) ); int row = 1; row = LayoutUtil.addRow(layout, row); builder.add(htmlField, cc.xyw( 1, row, 3 )); } return AuxComponentFactory.createInScrollPane(builder, PREFERRED_COLUMN_SIZE); }</code><technical_language>Code style: put extra whitespace parentheses. exceptions keywords a parenthesis: "if (", "for (", etc</technical_language>

Target:
private Component buildCriteriaPane() { FormLayout layout = new FormLayout( "left:pref, 3dlu, fill:0:grow", "p, 3dlu, p, 3dlu, p" ); PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); JLabel criteriaLabel = new JLabel("Criteria"); criteriaLabel.setFont( criteriaLabel.getFont().deriveFont(Font.BOLD)); builder.add(criteriaLabel, cc.xy(1, 1)); if (checkSuitableMetaAnalysesAvailable(d_pm)) { int row = 1; for (OutcomeMeasure out : d_metaPM.getCriteriaListModel()){ if (!d_metaPM.getMetaAnalyses(out).isEmpty()) { row = addCriterionCheckbox(out, d_metaPM, layout, builder, cc, row); row = LayoutUtil.addRow(layout, row); builder.add(buildRadioButtonAnalysisPanel(out), cc.xy(3, row, CellConstraints.LEFT, CellConstraints.DEFAULT)); } } } else { String warnHTMLText = "<i>Note</i>: To create a benefit-risk analysis, first create " + "at least two meta-analyses with at least two overlapping alternatives."; JComponent htmlField = AuxComponentFactory.createHtmlField(warnHTMLText); htmlField.setPreferredSize(new Dimension(PREFERRED_COLUMN_SIZE.width - 5, 100)); int row = 1; row = LayoutUtil.addRow(layout, row); builder.add(htmlField, cc.xyw(1, row, 3)); } return AuxComponentFactory.createInScrollPane(builder, PREFERRED_COLUMN_SIZE); }
Source:
<code>public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof DeviceAuthorization)) { return false; } final DeviceAuthorization authorization = (DeviceAuthorization) o; final boolean isDeviceEqual = Objects.equals(this.device, authorization.device); final boolean isOrganisationEqual = Objects.equals(this.organisation, authorization.organisation); final boolean isDeviceFunctionGroupEqual = Objects.equals(this.functionGroup.name(), <START> authorization.functionGroup.name()); <END> return isDeviceEqual && isOrganisationEqual && isDeviceFunctionGroupEqual; }</code><technical_language>While hurt, I is necessary add name() checking enum values functionGroup for equality</technical_language>

Target:
public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof DeviceAuthorization)) { return false; } final DeviceAuthorization authorization = (DeviceAuthorization) o; final boolean isDeviceEqual = Objects.equals(this.device, authorization.device); final boolean isOrganisationEqual = Objects.equals(this.organisation, authorization.organisation); final boolean isDeviceFunctionGroupEqual = Objects.equals(this.functionGroup, authorization.functionGroup); return isDeviceEqual && isOrganisationEqual && isDeviceFunctionGroupEqual; }
Source:
<code>private File createKnownCertFileIfNotExists() throws IOException { if ( !knownCerts.exists() ) { File parentDir = knownCerts.getParentFile(); if( parentDir != null && !parentDir.exists() ) { if(!parentDir.mkdirs()) { throw new IOException( "Failed to create directories for the known hosts file in " + knownCerts.getAbsolutePath() + ". This is usually " + <START> "because you do not have write permissions to the directory. Try configuring the Neo4j driver to use a file " + <END> "system location you do have write permissions to." ); } } if(!knownCerts.createNewFile()) { throw new IOException( "Failed to create a known hosts file at " + knownCerts.getAbsolutePath() + ". This is usually " + "because you do not have write permissions to the directory. Try configuring the Neo4j driver to use a file " + "system location you do have write permissions to." ); } BufferedWriter writer = new BufferedWriter( new FileWriter( knownCerts ) ); writer.write( "# This file contains trusted certificates for Neo4j servers, it's created by Neo4j drivers." ); writer.newLine(); writer.write( "# You can configure the location of this file in `org.neo4j.driver.Config`" ); writer.newLine(); writer.close(); } return knownCerts; }</code><technical_language>a failure due write permissions</technical_language>

Target:
private File createKnownCertFileIfNotExists() throws IOException { if ( !knownHosts.exists() ) { File parentDir = knownHosts.getParentFile(); try { if ( parentDir != null && !parentDir.exists() ) { if ( !parentDir.mkdirs() ) { throw new IOException( "Failed to create directories for the known hosts file in " + knownHosts.getAbsolutePath() + ". This is usually because you do not have write permissions to the directory. " + "Try configuring the Neo4j driver to use a file system location you do have write permissions to." ); } } if ( !knownHosts.createNewFile() ) { throw new IOException( "Failed to create a known hosts file at " + knownHosts.getAbsolutePath() + ". This is usually because you do not have write permissions to the directory. " + "Try configuring the Neo4j driver to use a file system location you do have write permissions to." ); } } catch( SecurityException e ) { throw new IOException( "Failed to create known host file and/or parent directories at " + knownHosts.getAbsolutePath() + ". This is usually because you do not have write permission to the directory. " + "Try configuring the Neo4j driver to use a file location you have write permissions to." ); } BufferedWriter writer = new BufferedWriter( new FileWriter( knownHosts ) ); writer.write( "# This file contains trusted certificates for Neo4j servers, it's created by Neo4j drivers." ); writer.newLine(); writer.write( "# You can configure the location of this file in `org.neo4j.driver.Config`" ); writer.newLine(); writer.close(); } return knownHosts; }
Source:
<code>public void setUp() throws Exception { super.setUp(); defaultDb = createWorkRepository(); try (Git git = new Git(defaultDb)) { JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "branch world"); git.add().addFilepattern("hello.txt").call(); git.commit().setMessage("Initial commit").call(); git.checkout().setName(BRANCH).setCreateBranch(true).call(); git.checkout().setName("master").call(); <START> git.tag().setName(TAG).call(); <END> JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "master world"); git.add().addFilepattern("hello.txt").call(); git.commit().setMessage("Second commit").call(); addRepoToClose(defaultDb); } defaultUri = defaultDb.getDirectory().toURI().toString(); int root = defaultUri.lastIndexOf("/", defaultUri.lastIndexOf("/.git") - 1) + 1; rootUri = defaultUri.substring(0, root) + "manifest"; defaultUri = defaultUri.substring(root); }</code><technical_language>do need create this tag</technical_language>

Target:
public void setUp() throws Exception { super.setUp(); defaultDb = createWorkRepository(); try (Git git = new Git(defaultDb)) { JGitTestUtil.writeTrashFile(defaultDb, "hello.txt", "hello world"); git.add().addFilepattern("hello.txt").call(); git.commit().setMessage("Initial commit").call(); addRepoToClose(defaultDb); } defaultUri = defaultDb.getDirectory().toURI().toString(); int root = defaultUri.lastIndexOf("/", defaultUri.lastIndexOf("/.git") - 1) + 1; rootUri = defaultUri.substring(0, root) + "manifest"; defaultUri = defaultUri.substring(root); }
Source:
<code>public GroupByColumnNode(VariableReferenceExpression inputColumn, VariableReferenceExpression output) { super(ExpressionType.GROUP_BY, output); <START> this.inputColumn = inputColumn; <END> }</code><technical_language>requireNonNull</technical_language>

Target:
public GroupByColumnNode(VariableReferenceExpression inputColumn, VariableReferenceExpression output) { super(ExpressionType.GROUP_BY, output); this.inputColumn = requireNonNull(inputColumn, "inputColumn is null"); }
Source:
<code>public E next() { <START> E e = iterator.next(); <END> lastRet = ObservableArrayList.this.list.indexOf(e); return e; }</code><technical_language>final</technical_language>

Target:
public E next() { final E e = iterator.next(); lastRet = ObservableArrayList.this.list.indexOf(e); return e; }
Source:
<code>public void realmClosed(RealmConfiguration configuration) { if (configuration instanceof SyncConfiguration) { SyncConfiguration syncConfig = (SyncConfiguration) configuration; <START> SyncSessionHolder.remove(syncConfig); <END> } else { throw new IllegalArgumentException(WRONG_TYPE_OF_CONFIGURATION); } }</code><technical_language>lock fine this change. change, locks protect sessions, lock SyncManager class SyncSessionHolder class. I feel a problem calling methods SyncManager close Realm. optimize code single lock instead</technical_language>

Target:
public void realmClosed(RealmConfiguration configuration) { if (configuration instanceof SyncConfiguration) { SyncConfiguration syncConfig = (SyncConfiguration) configuration; invokeRemoveSession(syncConfig); } else { throw new IllegalArgumentException(WRONG_TYPE_OF_CONFIGURATION); } }
Source:
<code>public static boolean isCompatibleName(String name) { <START> return (TABLE_NAME_START.matches(name.charAt(0)) && <END> TABLE_NAME_CHARS.matchesAllOf(name)); }</code><technical_language>a regex</technical_language>

Target:
public static boolean isCompatibleName(String name) { return hiveCompatible.matcher(name).matches(); }
Source:
<code>static AuthenticationResult createResult(final TokenCacheItem cacheItem) { if (cacheItem == null) { AuthenticationResult result = new AuthenticationResult(); result.mStatus = AuthenticationStatus.Failed; return result; } final AuthenticationResult result = new AuthenticationResult(cacheItem.getAccessToken(), cacheItem.getRefreshToken(), cacheItem.getExpiresOn(), cacheItem.getIsMultiResourceRefreshToken(), cacheItem.getUserInfo(), cacheItem.getTenantId(), cacheItem.getRawIdToken(), null); <START> if (cacheItem.isExtendedLifetimeValid()) { <END> result.setExtendedExpiresOn(cacheItem.getExtendedExpiresOn()); } return result; }</code><technical_language>confused here. If check isExtendedLifetimeValid, checking expiresOn? is a extended time existed expired is exist</technical_language>

Target:
static AuthenticationResult createResult(final TokenCacheItem cacheItem) { if (cacheItem == null) { AuthenticationResult result = new AuthenticationResult(); result.mStatus = AuthenticationStatus.Failed; return result; } final AuthenticationResult result = new AuthenticationResult(cacheItem.getAccessToken(), cacheItem.getRefreshToken(), cacheItem.getExpiresOn(), cacheItem.getIsMultiResourceRefreshToken(), cacheItem.getUserInfo(), cacheItem.getTenantId(), cacheItem.getRawIdToken(), cacheItem.getExtendedExpiresOn()); return result; }
Source:
<code>private void redirectToLoggedOnPage() { <START> String token = placeManager.getCurrentPlaceRequest().getParameter(REDIRECT_PARAMETER_NAME, NameTokens.getOnLoginDefaultPage()); <END> PlaceRequest placeRequest = new Builder().nameToken(token).build(); placeManager.revealPlace(placeRequest); }</code><technical_language>Line width = 120</technical_language>

Target:
private void redirectToLoggedOnPage() { String token = placeManager .getCurrentPlaceRequest() .getParameter(ParameterTokens.REDIRECT, NameTokens.getOnLoginDefaultPage()); PlaceRequest placeRequest = new Builder().nameToken(token).build(); placeManager.revealPlace(placeRequest); }
Source:
<code>protected Subject createEvidenceSubject(final CallbackProperties properties, final X509Certificate certificate, final PublicKey publicKey) throws SAMLComponentBuilderException { final String evidenceSubject = properties.getEvidenceSubject(); String x509Name; if (NullChecker.isNullish(evidenceSubject)) { String userName = properties.getUsername(); <START> if ((NullChecker.isNullish(userName) || !checkDistinguishedName(userName)) && null != certificate <END> && null != certificate.getSubjectDN()) { userName = certificate.getSubjectDN().getName(); } x509Name = userName; } else { x509Name = evidenceSubject; } return createSubject(x509Name, publicKey); }</code><technical_language>Duplicate in createSubject createEvidenceSubject methods. Consider refactoring helper method</technical_language>

Target:
protected Subject createEvidenceSubject(final CallbackProperties properties, final X509Certificate certificate, final PublicKey publicKey) throws SAMLComponentBuilderException { final String evidenceSubject = properties.getEvidenceSubject(); String x509Name; if (NullChecker.isNullish(evidenceSubject)) { String userName = properties.getUsername(); if ((NullChecker.isNullish(userName) || !checkDistinguishedName(userName)) && null != certificate && null != certificate.getSubjectDN()) { userName = certificate.getSubjectDN().getName(); } x509Name = userName; } else { x509Name = evidenceSubject; } return OpenSAML2ComponentBuilder.getInstance().createSubject(x509Name, publicKey); }
Source:
<code>public void addDeviceAuthorization(@Identification final String ownerOrganisationIdentification, @Identification final String organisationIdentification, @Identification final String deviceIdentification, @NotNull final DeviceFunctionGroup group) throws FunctionalException { if (group == DeviceFunctionGroup.OWNER) { throw new FunctionalException(FunctionalExceptionType.METHOD_NOT_ALLOWED_FOR_OWNER, ComponentType.WS_ADMIN, new OperationNotSupportedException("Owner not allowed to set via this method.")); } final Organisation organisation = this.findOrganisation(organisationIdentification); final Organisation ownerOrganisation = this.findOrganisation(ownerOrganisationIdentification); final Device device = this.findDevice(deviceIdentification); this.isAllowed(ownerOrganisation, device, DeviceFunction.SET_DEVICE_AUTHORIZATION); for (final DeviceAuthorization authorization : device.getAuthorizations()) { if (authorization.getOrganisation() == organisation && authorization.getFunctionGroup() == group) { LOGGER.info("Organisation already has authorization for group on device {}", new Object[] { <START> organisationIdentification, deviceIdentification, group }); <END> return; } } final DeviceAuthorization authorization = device.addAuthorization(organisation, group); this.deviceRepository.save(device); this.authorizationRepository.save(authorization); LOGGER.info("Organisation now has authorization for function group on device {}", organisationIdentification, deviceIdentification, group); }</code><technical_language>Switch order of deviceIdentification group</technical_language>

Target:
public void addDeviceAuthorization(@Identification final String ownerOrganisationIdentification, @Identification final String organisationIdentification, @Identification final String deviceIdentification, @NotNull final DeviceFunctionGroup group) throws FunctionalException { if (group == DeviceFunctionGroup.OWNER) { throw new FunctionalException(FunctionalExceptionType.METHOD_NOT_ALLOWED_FOR_OWNER, ComponentType.WS_ADMIN, new OperationNotSupportedException("Owner not allowed to set via this method.")); } final Organisation organisation = this.findOrganisation(organisationIdentification); final Organisation ownerOrganisation = this.findOrganisation(ownerOrganisationIdentification); final Device device = this.findDevice(deviceIdentification); this.isAllowed(ownerOrganisation, device, DeviceFunction.SET_DEVICE_AUTHORIZATION); for (final DeviceAuthorization authorization : device.getAuthorizations()) { if (authorization.getOrganisation() == organisation && authorization.getFunctionGroup() == group) { LOGGER.info("Organisation already has authorization for group on device {}", organisationIdentification, group, deviceIdentification); return; } } final DeviceAuthorization authorization = device.addAuthorization(organisation, group); this.deviceRepository.save(device); this.authorizationRepository.save(authorization); LOGGER.info("Organisation now has authorization for function group on device {}", organisationIdentification, group, deviceIdentification); }
Source:
<code>protected CqlSessionBuilder buildBuilder() { Assert.hasText(this.contactPoints, "At least one server is required"); CqlSessionBuilder sessionBuilder = setCqlSessionBuilderSupplier.get(); if (contactPointsWithPort == null) { StringUtils.commaDelimitedListToSet(this.contactPoints) .forEach(host -> sessionBuilder.addContactPoint(InetSocketAddress.createUnresolved(host, this.port))); } else { StringUtils.commaDelimitedListToSet(this.contactPointsWithPort).stream().map(HOST_PORT_SPLITTER::splitToList) .forEach(hostAndPort -> { <START> if (hostAndPort.size() != 2) { <END> throw new IllegalArgumentException( String.format("The provided contactPointsWithPort: %s has wrong format.", contactPointsWithPort)); } sessionBuilder.addContactPoint( InetSocketAddress.createUnresolved(hostAndPort.get(0), Integer.parseInt(hostAndPort.get(1)))); }); } if (StringUtils.hasText(this.username)) { sessionBuilder.withAuthCredentials(this.username, this.password); } if (StringUtils.hasText(this.localDatacenter)) { sessionBuilder.withLocalDatacenter(this.localDatacenter); } return this.sessionBuilderConfigurer != null ? this.sessionBuilderConfigurer.configure(sessionBuilder) : sessionBuilder; }</code><technical_language>Argument validation happen early possible, ideally in setContactPoints allow invalid values get factory bean in place. afterPropertiesSet() is kind-of fact good check if required values configured. discussed for compatibility, leniently accept host host port. need check if host contains IPv6 : is in IPv6 addresses, need check address is resource identifier format square brackets ([2001:db8:85a3:8d3:1319:8a2e:370:7348]:443) correctly identify port</technical_language>

Target:
protected CqlSessionBuilder buildBuilder() { Collection<InetSocketAddress> addresses = contactPoints.apply(this.port); Assert.notEmpty(addresses, "At least one server is required"); CqlSessionBuilder sessionBuilder = setCqlSessionBuilderSupplier.get(); addresses.forEach(sessionBuilder::addContactPoint); if (StringUtils.hasText(this.username)) { sessionBuilder.withAuthCredentials(this.username, this.password); } if (StringUtils.hasText(this.localDatacenter)) { sessionBuilder.withLocalDatacenter(this.localDatacenter); } return this.sessionBuilderConfigurer != null ? this.sessionBuilderConfigurer.configure(sessionBuilder) : sessionBuilder; }