auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private String getCassandraAlias() { if (renameCassandraMetrics()) { Map<String, String> beanParameters = getBeanParameters(); <START> String type = beanParameters.get("type"); <END> String metricName = beanParameters.get("name"); String attributeName = getAttributeName(); if (attributeName.equals("Value")) { return "cassandra." + metricName; } return "cassandra." + metricName + "." + attributeName; } return getDomain().replace("org.apache.", "") + "." + getAttributeName(); }</code><technical_language>This variable is used</technical_language>

Target:
private String getCassandraAlias() { if (renameCassandraMetrics()) { Map<String, String> beanParameters = getBeanParameters(); String metricName = beanParameters.get("name"); String attributeName = getAttributeName(); if (attributeName.equals("Value")) { return "cassandra." + metricName; } return "cassandra." + metricName + "." + attributeName; } return getDomain().replace("org.apache.", "") + "." + getAttributeName(); }
Source:
<code>public void processBitmapForWrite(BitmapCommit c, Bitmap bitmap, int flags) { EWAHCompressedBitmap compressed = retrieveCompressed(bitmap); compressed.trim(); StoredBitmap newest = new StoredBitmap(c, compressed, null, flags); searchOffset.add(newest); if (searchOffset.size() > MAX_XOR_OFFSET_SEARCH) { StoredEntry <START> writeEntry = <END> generateStoredEntry( searchOffset.pollFirst()); bitmapsToWrite.add(writeEntry); } if (c.isAddToIndex()) { addBitmap(c, bitmap, flags); } }</code><technical_language>inline this variable</technical_language>

Target:
public void processBitmapForWrite(BitmapCommit c, Bitmap bitmap, int flags) { EWAHCompressedBitmap compressed = retrieveCompressed(bitmap); compressed.trim(); StoredBitmap newest = new StoredBitmap(c, compressed, null, flags); bitmapsToWriteXorBuffer.add(newest); if (bitmapsToWriteXorBuffer.size() > MAX_XOR_OFFSET_SEARCH) { bitmapsToWrite.add( generateStoredEntry(bitmapsToWriteXorBuffer.pollFirst())); } if (c.isAddToIndex()) { addBitmap(c, bitmap, flags); } }
Source:
<code>public static synchronized RegistryService getInstance() { RegistryService local = instance; <START> if (local == null) { <END> local = new RegistryService(); instance = local; ReporterFactory.getOrCreateReporter(); } return local; }</code><technical_language>test assign instance passing local</technical_language>

Target:
public static synchronized RegistryService getInstance() { if (instance == null) { instance = new RegistryService(); ReporterFactory.getOrCreateReporter(); } return instance; }
Source:
<code><START> createEntityChangeBlock(Game game, Cause cause, Entity entity, BlockLoc block, BlockSnapshot replacementBlock) { <END> Map<String, Object> values = Maps.newHashMap(); values.put("game", game); values.put("cause", Optional.fromNullable(cause)); values.put("block", block); values.put("entity", entity); values.put("replacementBlock", replacementBlock); return createEvent(EntityChangeBlockEvent.class, values); }</code><technical_language>push method name a new line? In line [R406](<LINK_0> line [R174](<LINK_1> moved method arguments new line</technical_language>

Target:
public static EntityChangeBlockEvent createEntityChangeBlock(Game game, Cause cause, Entity entity, BlockLoc block, BlockSnapshot replacementBlock) { Map<String, Object> values = Maps.newHashMap(); values.put("game", game); values.put("cause", Optional.fromNullable(cause)); values.put("block", block); values.put("entity", entity); values.put("replacementBlock", replacementBlock); return createEvent(EntityChangeBlockEvent.class, values); }
Source:
<code>public SimpleTableDef[] detectTableDefs() { final List<SimpleTableDef> tableDefs = new ArrayList<>(); final String labelsJsonString = _requestWrapper.executeRestRequest(new HttpGet(_serviceRoot + "/labels")); final JSONArray labelsJsonArray; try { labelsJsonArray = new JSONArray(labelsJsonString); for (int i = 0; i < labelsJsonArray.length(); i++) { <START> fillTableDefsFromLabel(labelsJsonArray.getString(i), tableDefs); <END> } return tableDefs.toArray(new SimpleTableDef[tableDefs.size()]); } catch (final JSONException e) { logger.error("Error occured in parsing JSON while detecting the schema: ", e); throw new IllegalStateException(e); } }</code><technical_language>fillTableDefsFromLabel method fill tableDefs list, adds SimpleTableDef in case a SimpleTableDef created for label. I a method called getTableDefForLabel createTableDefFromLabel, returns a SimpleTableDef (or null in case created for label) adds tableDefs list if is null. point of view, in manner method simple responsibility code is easier understand</technical_language>

Target:
public SimpleTableDef[] detectTableDefs() { final List<SimpleTableDef> tableDefs = new ArrayList<>(); final String labelsJsonString = _requestWrapper.executeRestRequest(new HttpGet(_serviceRoot + "/labels")); final JSONArray labelsJsonArray; try { labelsJsonArray = new JSONArray(labelsJsonString); for (int i = 0; i < labelsJsonArray.length(); i++) { final SimpleTableDef tableDefFromLabel = createTableDefFromLabel(labelsJsonArray.getString(i)); if (tableDefFromLabel != null) { tableDefs.add(tableDefFromLabel); } } return tableDefs.toArray(new SimpleTableDef[tableDefs.size()]); } catch (final JSONException e) { logger.error("Error occurred in parsing JSON while detecting the schema: ", e); throw new IllegalStateException(e); } }
Source:
<code>private IResource copyTrace(final String newName) { WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { @Override public void execute(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask("", 1000); if (monitor.isCanceled()) { throw new OperationCanceledException(); } <START> fTrace.copy(newName, fTraceFolder, true); <END> if (monitor.isCanceled()) { throw new OperationCanceledException(); } } finally { monitor.done(); } } }; try { PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation); } catch (InterruptedException exception) { return null; } catch (InvocationTargetException exception) { MessageDialog.openError(getShell(), "", NLS.bind("", exception.getTargetException().getMessage())); return null; } catch (RuntimeException exception) { return null; } return fTrace.getResource(); }</code><technical_language>extra space</technical_language>

Target:
private IResource copyTrace(final String newName) { WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { @Override public void execute(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask("", 1000); if (monitor.isCanceled()) { throw new OperationCanceledException(); } fTrace.copy(newName, true); if (monitor.isCanceled()) { throw new OperationCanceledException(); } } finally { monitor.done(); } } }; try { PlatformUI.getWorkbench().getProgressService().busyCursorWhile(operation); } catch (InterruptedException exception) { return null; } catch (InvocationTargetException exception) { MessageDialog.openError(getShell(), "", NLS.bind("", exception.getTargetException().getMessage())); return null; } catch (RuntimeException exception) { return null; } return fTrace.getResource(); }
Source:
<code>protected void executeCommand() { List<DiskImage> imageTemplates = ImagesHandler.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm( getVmTemplateId()), false, false, true); for (DiskImage template : imageTemplates) { for (Guid domain : (Collection<Guid>) CollectionUtils.intersection(getParameters().getStorageDomainsList(), template.getStorageIds())) { RemoveImageParameters tempVar = new RemoveImageParameters(template.getImageId()); tempVar.setDiskImage(template); tempVar.setStorageDomainId(domain); tempVar.setStoragePoolId(template.getStoragePoolId()); tempVar.setImageGroupID(template.getId()); tempVar.setEntityInfo(getParameters().getEntityInfo()); tempVar.setWipeAfterDelete(template.isWipeAfterDelete()); tempVar.setParentCommand(getActionType()); tempVar.setParentParameters(getParameters()); VdcReturnValueBase vdcReturnValue = runInternalActionWithTasksContext( <START> VdcActionType.RemoveImage, <END> tempVar); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList()); } else { log.error("Can't remove image id '{}' for template id '{}' from domain id '{}' due to: {}.", template.getImageId(), getVmTemplateId(), domain, vdcReturnValue.getFault().getMessage()); } } } setSucceeded(true); }</code><technical_language>currently is a problem here, in case of disk copies disk execution for domain. In order overcome execute RemoveDisk instead of RemoveImage. RemoveDisk is adjusted template disk, execute RemoveImage correctly. note update RemoveDisk add created tasks list returned in getTaskIdList() instead of getReturnValue().getVdsmTaskIdList() today</technical_language>

Target:
protected void executeCommand() { List<DiskImage> imageTemplates = ImagesHandler.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm( getVmTemplateId()), false, false, true); for (DiskImage template : imageTemplates) { for (Guid domain : (Collection<Guid>) CollectionUtils.intersection(getParameters().getStorageDomainsList(), template.getStorageIds())) { RemoveDiskParameters tempVar = new RemoveDiskParameters(template.getId()); tempVar.setStorageDomainId(domain); tempVar.setParentCommand(getActionType()); tempVar.setParentParameters(getParameters()); VdcReturnValueBase vdcReturnValue = runInternalActionWithTasksContext( VdcActionType.RemoveDisk, tempVar); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList()); } else { log.error("Can't remove image id '{}' for template id '{}' from domain id '{}' due to: {}.", template.getImageId(), getVmTemplateId(), domain, vdcReturnValue.getFault().getMessage()); } } } setSucceeded(true); }
Source:
<code>public void shouldRevertFromTrash() { <START> RevertFromTrash testRevert = testRevertFromTrashService.create(new RevertFromTrash("revertTest")); <END> Long testSchemaVersion = testRevertFromTrashService.getSchemaVersion(); trashService.moveToTrash(testRevert, testSchemaVersion); assertNotNull("Instance is not in trash", testRevertFromTrashService.findTrashInstanceById(testRevert.getId())); testRevertFromTrashService.revertFromTrash(testRevert.getId()); assertNull("Instance is still in the trash.",testRevertFromTrashService.findTrashInstanceById(testRevert.getId())); }</code><technical_language>this test differently, try test real case. of refactor trash history instance lifecycle listeners, instance moved trash while deleting instance. do method moveToTrash, delete instance. id of created instance, in this example instance in main entity in trash, id is 1. I this test a bit more complicated. create instances, delete them, revert of trash check end if is instance in main table in trash</technical_language>

Target:
public void shouldRevertFromTrash() { HomeAddress homeAddress1 = revertFromTrashService.create(new HomeAddress("street1","city1")); HomeAddress homeAddress2 = revertFromTrashService.create(new HomeAddress("street2","city2")); revertFromTrashService.delete(homeAddress1); revertFromTrashService.delete(homeAddress2); revertFromTrashService.revertFromTrash(homeAddress1.getId()); QueryParams q = new QueryParams(1,10); Collection instancesInTrash = trashService.getInstancesFromTrash(HomeAddress.class.getName(), q); Collection<HomeAddress> instancesOutsideTrash = revertFromTrashService.retrieveAll(); assertEquals(1, instancesInTrash.size()); assertEquals(1, instancesOutsideTrash.size()); }
Source:
<code>public static List<OfflineSegmentZKMetadata> getOfflineSegmentZKMetadataListForTable( ZkHelixPropertyStore<ZNRecord> propertyStore, String tableName) { String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName); String parentPath = constructPropertyStorePathForResource(offlineTableName); <START> List<ZNRecord> znRecords = propertyStore.getChildren(parentPath, null, AccessOption.PERSISTENT, ZK_OP_RETRY_COUNT, ZK_OP_RETRY_INTERVAL_MS); <END> if (znRecords != null) { int numZNRecords = znRecords.size(); List<OfflineSegmentZKMetadata> offlineSegmentZKMetadataList = new ArrayList<>(numZNRecords); for (ZNRecord znRecord : znRecords) { if (znRecord != null) { offlineSegmentZKMetadataList.add(new OfflineSegmentZKMetadata(znRecord)); } } int numNullZNRecords = numZNRecords - offlineSegmentZKMetadataList.size(); if (numNullZNRecords > 0) { LOGGER.warn("Failed to read {}/{} offline segment ZK metadata under path: {}", numZNRecords - numNullZNRecords, numZNRecords, parentPath); } return offlineSegmentZKMetadataList; } else { LOGGER.warn("Path: does not exist", parentPath); return Collections.emptyList(); } }</code><technical_language>This effect... is Helix code for (I count a bug): @Override public List<T> getChildren(String parentPath, List<Stat> stats, int options, int retryCount, int retryInterval) throws HelixException { return getChildren(parentPath, stats, options); } I easy throw exception for this API create children paths manually</technical_language>

Target:
public static List<OfflineSegmentZKMetadata> getOfflineSegmentZKMetadataListForTable( ZkHelixPropertyStore<ZNRecord> propertyStore, String tableName) { String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName); String parentPath = constructPropertyStorePathForResource(offlineTableName); List<ZNRecord> znRecords = propertyStore.getChildren(parentPath, null, AccessOption.PERSISTENT, CommonConstants.Helix.ZkClient.RETRY_COUNT, CommonConstants.Helix.ZkClient.RETRY_INTERVAL_MS); if (znRecords != null) { int numZNRecords = znRecords.size(); List<OfflineSegmentZKMetadata> offlineSegmentZKMetadataList = new ArrayList<>(numZNRecords); for (ZNRecord znRecord : znRecords) { if (znRecord != null) { offlineSegmentZKMetadataList.add(new OfflineSegmentZKMetadata(znRecord)); } } int numNullZNRecords = numZNRecords - offlineSegmentZKMetadataList.size(); if (numNullZNRecords > 0) { LOGGER.warn("Failed to read {}/{} offline segment ZK metadata under path: {}", numZNRecords - numNullZNRecords, numZNRecords, parentPath); } return offlineSegmentZKMetadataList; } else { LOGGER.warn("Path: does not exist", parentPath); return Collections.emptyList(); } }
Source:
<code>private void writeEncryptedMapToJSON(String jsonMapName, LinkedHashMap<String, Object> data, boolean includeNullField, String encryption_key, String secret_key) throws IOException{ JsonGenerator generator = jsonGeneratorThreadLocal.get(); <START> JSONObject obj = new JSONObject(); <END> for (String key : data.keySet()) { Object value = data.get(key); if (value == null && !includeNullField) continue; if ( value instanceof List ) { List stringList = (List) value; obj.put(key, stringList); } else if (value instanceof RawJSONString) { obj.put(key, ((RawJSONString) value).json); } else { obj.put(key, value); } } generator.writeStringField(jsonMapName, RowEncrypt.encrypt(obj.toString(), encryption_key, secret_key)); }</code><technical_language>avoid this creating a new dependency for maxwell. Instead, writeMapToJson accept a JsonGenerator object, write a raw map generator. (you'll remove part writeMapToJson writes data key). regular code path write main generator object, encryption code path create a new generator for map capture bytes encrypt them. sense</technical_language>

Target:
private void writeEncryptedMapToJSON(String jsonMapName, LinkedHashMap<String, Object> data, boolean includeNullField, String encryption_key, String secret_key) throws IOException{ JsonGenerator generator = jsonGeneratorThreadLocal.get(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); JsonGenerator obj = jsonFactory.createGenerator(outputStream); obj.writeStartObject(); for (String key : data.keySet()) { Object value = data.get(key); if (value == null && !includeNullField) continue; if ( value instanceof List ) { List stringList = (List) value; obj.writeArrayFieldStart(key); for ( Object s : stringList ) { obj.writeObject(s); } obj.writeEndArray(); } else if (value instanceof RawJSONString) { obj.writeFieldName(key); obj.writeRawValue(((RawJSONString) value).json); } else { obj.writeObjectField(key, value); } } obj.writeEndObject(); obj.close(); outputStream.close(); generator.writeStringField(jsonMapName, RowEncrypt.encrypt(outputStream.toString(), encryption_key, secret_key)); }
Source:
<code>public void validate_shouldRejectAVisitIfItHasMoreThanMaxOccursOfAnAttributeWhenExpectedExactlyOne() throws Exception { executeDataSet("org/openmrs/validator/include/VisitValidatorTest-additionalAttributeType1.xml"); Visit visit = makeVisit(); visit.addAttribute(makeAttribute("one")); visit.addAttribute(makeAttribute("two")); visit.addAttribute(makeAttribute("three")); visit.addAttribute(makeAttribute("four")); try { ValidateUtil.validate(visit); } catch (ValidationException e) { Errors errors = e.getErrors(); <START> assertEquals(1, errors.getErrorCount()); <END> assertEquals("attribute.error.maxOccurs", errors.getFieldError("activeAttributes").getCode()); } }</code><technical_language>If validation exception is thrown, assertions get executed</technical_language>

Target:
public void validate_shouldRejectAVisitIfItHasMoreThanMaxOccursOfAnAttributeWhenExpectedExactlyOne() throws Exception { executeDataSet("org/openmrs/validator/include/VisitValidatorTest-additionalAttributeType1.xml"); Visit visit = makeVisit(); visit.addAttribute(makeAttribute("one")); visit.addAttribute(makeAttribute("two")); visit.addAttribute(makeAttribute("three")); visit.addAttribute(makeAttribute("four")); try { ValidateUtil.validate(visit); fail(); } catch (ValidationException e) { Errors errors = e.getErrors(); assertEquals(1, errors.getErrorCount()); assertEquals("attribute.error.maxOccurs", errors.getFieldError("activeAttributes").getCode()); } }
Source:
<code>public String toString() { <START> return String.format("%30s: fboId: %s", this.getClass().getSimpleName(), fboId); <END> }</code><technical_language>Hmmmm. I noticed this change good: a human perspective fbo id in logger output is of limited use. name printed out is important. I imagine a couple of solution: 1. pass fbo's URN construction, solely for purpose of printing out in log fboId 2. store URN in FBO, if this is bite in future</technical_language>

Target:
public String toString() { return String.format("%30s: %s (fboId: %s)", this.getClass().getSimpleName(), fboName, fboId); }
Source:
<code>public void doGradualExport() { <START> busyIndicatorView.showBusyIndicator("Loading Export Wizard"); <END> dataTransferServices.call((DataTransferAssets v) -> { busyIndicatorView.hideBusyIndicator(); exportWizard.start(v); }, (message, error) -> { busyIndicatorView.hideBusyIndicator(); view.exportError(error); return false; }).assetsToExport(); }</code><technical_language>Consider i18n for "Loading Export Wizard"</technical_language>

Target:
public void doGradualExport() { busyIndicatorView.showBusyIndicator(i18n.loadingExportWizard()); dataTransferServices.call((DataTransferAssets v) -> { busyIndicatorView.hideBusyIndicator(); exportWizard.start(v); }, (message, error) -> { busyIndicatorView.hideBusyIndicator(); view.exportError(error); return false; }).assetsToExport(); }
Source:
<code>static CDIInterceptorWrapper createWrapper(Class<?> restClient) { try { return AccessController.doPrivileged((PrivilegedExceptionAction<CDIInterceptorWrapper>) () -> { Class<?> cdiClass = Class.forName("javax.enterprise.inject.spi.CDI", false, restClient.getClassLoader()); Method currentMethod = cdiClass.getMethod("current"); Object cdiCurrent = currentMethod.invoke(null); Method getBeanMgrMethod = cdiClass.getMethod("getBeanManager"); getBeanMgrMethod.invoke(cdiCurrent); <START> return new CDIInterceptorWrapperImpl(restClient); <END> }); } catch (PrivilegedActionException pae) { if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "Unable to load CDI SPI classes, assuming no CDI is available", pae); } return new BasicCDIInterceptorWrapper(); } }</code><technical_language>pass BeanManager getBeanMgrMethod.invoke(cdiCurrent) CDIInterceptorWrapperImpl invoke CDI.current() in there</technical_language>

Target:
static CDIInterceptorWrapper createWrapper(Class<?> restClient) { try { return AccessController.doPrivileged((PrivilegedExceptionAction<CDIInterceptorWrapper>) () -> { Class<?> cdiClass = Class.forName("javax.enterprise.inject.spi.CDI", false, restClient.getClassLoader()); Method currentMethod = cdiClass.getMethod("current"); Object cdiCurrent = currentMethod.invoke(null); Method getBeanMgrMethod = cdiClass.getMethod("getBeanManager"); return new CDIInterceptorWrapperImpl(restClient, getBeanMgrMethod.invoke(cdiCurrent)); }); } catch (PrivilegedActionException pae) { if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "Unable to load CDI SPI classes, assuming no CDI is available", pae); } return new BasicCDIInterceptorWrapper(); } }
Source:
<code>private Job getProject(ItemGroup ctx, String projectName) { String[] parts = projectName.split("/"); for (String part : parts) { if (part == null) continue; Item i = ctx.getItem(part); if (i instanceof ItemGroup) ctx = (ItemGroup) i; if (i instanceof Job) { return (Job) i; <START> } <END> } return null; }</code><technical_language>? test ctx next part? sense</technical_language>

Target:
private Job getProject(ItemGroup ctx, String projectName) { String[] parts = projectName.split("/"); if (projectName.startsWith("/")) ctx = Jenkins.getInstance(); for (String part : parts) { if (part.length() == 0) continue; if (part.equals("..")) { ctx = ((Item) ctx).getParent(); continue; } Item i = ctx.getItem(part); if (i instanceof Job) return (Job) i; ctx = (ItemGroup) i; } return null; }
Source:
<code>private void refreshConfig(TreeViewer tv, final TaskRepository repository) { clearError(); try { final GerritClient client = GerritCorePlugin.getGerritClient(repository); getContainer().run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { <START> monitor.beginTask(Messages.GerritRepositorySearchPage_Refreshing + repository.getRepositoryLabel(), IProgressMonitor.UNKNOWN); <END> try { client.refreshConfig(monitor); } catch (GerritException e) { throw new InvocationTargetException(e, e.getMessage()); } monitor.done(); } }); tv.refresh(repository); } catch (InvocationTargetException e) { showError(e, e.getMessage()); } catch (InterruptedException e) { } }</code><technical_language>Refreshing_X NLS.bind()</technical_language>

Target:
private void refreshConfig(TreeViewer tv, final TaskRepository repository) { clearError(); try { final GerritClient client = GerritCorePlugin.getGerritClient(repository); getContainer().run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask( NLS.bind(Messages.GerritRepositorySearchPage_Refreshing_X, repository.getRepositoryLabel()), IProgressMonitor.UNKNOWN); try { client.refreshConfig(monitor); } catch (GerritException e) { throw new InvocationTargetException(e, e.getMessage()); } monitor.done(); } }); tv.refresh(repository); } catch (InvocationTargetException e) { showError(e, e.getMessage()); } catch (InterruptedException e) { } }
Source:
<code>protected TreeViewer doCreateTreeViewer(Composite parent, int style) { <START> return new TreeViewer(parent, style); <END> }</code><technical_language>This change removed code unrelated</technical_language>

Target:
protected TreeViewer doCreateTreeViewer(Composite parent, int style) { return new NotifyingTreeViewer(parent, style); }
Source:
<code><START> public byte[] getData() { <END> return data; }</code><technical_language>return a copy of data DataExtension immutable</technical_language>

Target:
public byte[] getData() { return data.clone(); }
Source:
<code>public void bbCodesWithTextThatShouldFail(String postBody, String messageIfTestFails) throws Exception { info("Running a test case [" + messageIfTestFails + "]"); try { Topics.postAnswer(TEST_TOPIC, new Post(postBody)); fail(messageIfTestFails); } catch (ValidationException e) { } catch (CouldNotOpenPageException e) { <START> fail("Something went wrong and user was thrown out of topic."); <END> } }</code><technical_language>do catch this kind of exception if thin do is re-throwing exception</technical_language>

Target:
public void bbCodesWithTextThatShouldFail(String postBody, String messageIfTestFails) throws Exception { info("Running a test case [" + messageIfTestFails + "]"); try { Topics.postAnswer(TEST_TOPIC, new Post(postBody)); fail(messageIfTestFails); } catch (ValidationException e) { } }
Source:
<code>public MessageHandler transformer(BeanFactory beanFactory) throws Exception { FilterFactoryBean factoryBean = new FilterFactoryBean(); factoryBean.setBeanFactory(beanFactory); factoryBean.setOutputChannel(channels.output()); <START> properties.configure(factoryBean); <END> return factoryBean.getObject(); }</code><technical_language>IMO logic is in configure method of properties class instead</technical_language>

Target:
public MessageHandler transformer(BeanFactory beanFactory) throws Exception { FilterFactoryBean factoryBean = new FilterFactoryBean(); factoryBean.setBeanFactory(beanFactory); factoryBean.setOutputChannel(channels.output()); if (properties.getScript() != null) { GroovyScriptExecutingMessageProcessor processor = new GroovyScriptExecutingMessageProcessor( new ResourceScriptSource(properties.getScript()), scriptVariableGenerator); factoryBean.setTargetObject(processor); } else { factoryBean.setExpression(properties.getExpression()); } return factoryBean.getObject(); }
Source:
<code>public ValidationResult isDiskAttachedToVm(VM vm) { List<VM> vms = getVmDao().getVmsListForDisk(disk.getId(), true); <START> String[] replacements = {String.format(DISK_NAME_REPLACEMENT, disk.getDiskAlias()), String.format(VM_NAME_REPLACEMENT, vm.getName())}; <END> return ValidationResult.failWith(EngineMessage.ACTION_TYPE_FAILED_DISK_NOT_ATTACHED_TO_VM, replacements). when(vms.stream().noneMatch(vm1 -> vm1.getId().equals(vm.getId()))); }</code><technical_language>ReplacementUtils here</technical_language>

Target:
public ValidationResult isDiskAttachedToVm(VM vm) { List<VM> vms = getVmDao().getVmsListForDisk(disk.getId(), true); String[] replacements = {ReplacementUtils.createSetVariableString(DISK_NAME_VARIABLE, disk.getDiskAlias()), ReplacementUtils.createSetVariableString(VM_NAME_VARIABLE, vm.getName())}; return ValidationResult.failWith(EngineMessage.ACTION_TYPE_FAILED_DISK_NOT_ATTACHED_TO_VM, replacements). when(vms.stream().noneMatch(vm1 -> vm1.getId().equals(vm.getId()))); }
Source:
<code>private void onFinish() { <START> synchronized (processing) { <END> processing.getAndDecrement(); if (processing.get() == 0) { serializer.store(rootFile.getName(), rootFile); } } }</code><technical_language>Synchronizing processing necessarily guarantee exclusive access processing object, i.e., another thread allowed call getAndDecrement() this synchronized block depending AtomicLong is implemented. safer a combination of Semaphore CountdownLatch, lines, instead of a single counting variable for both</technical_language>

Target:
private void onFinish() { synchronized (processingLock) { if (processing.decrementAndGet() == 0) { serializer.store(rootFile.getName(), rootFile); isProcessing = false; } } }
Source:
<code>public int getSupportFlags() { <START> return 0; <END> }</code><technical_language>add SUPPORT_FLAG_ENDLESS_SCROLLING here, UI a lot faster</technical_language>

Target:
public int getSupportFlags() { return SUPPORT_FLAG_ENDLESS_SCROLLING; }
Source:
<code>public Value evaluate(ValueFactory valueFactory, Value... values) throws ValueExprEvaluationException { <START> Preconditions.checkArgument(values.length == 4); <END> Preconditions.checkArgument(values[0] instanceof Literal); Preconditions.checkArgument(values[1] instanceof Literal); Preconditions.checkArgument(values[2] instanceof Literal); Preconditions.checkArgument(values[3] instanceof URI); long epochTime1 = convertDatetimeToMillis((Literal) values[0]); long epochTime2 = convertDatetimeToMillis((Literal) values[1]); long periodMillis = convertPeriodToMillis((Literal) values[2], (URI) values[3]); return valueFactory.createLiteral(Math.abs(epochTime1 - epochTime2) < periodMillis); }</code><technical_language>Do want throw a ValueExprEvaluationException in order follow Function interface contract</technical_language>

Target:
public Value evaluate(ValueFactory valueFactory, Value... values) throws ValueExprEvaluationException { checkNotNull(valueFactory); checkNotNull(values); try { checkArgument(values.length == 4); checkArgument(values[0] instanceof Literal); checkArgument(values[1] instanceof Literal); checkArgument(values[2] instanceof Literal); checkArgument(values[3] instanceof URI); Instant dateTime1 = convertToInstant((Literal) values[0]); Instant dateTime2 = convertToInstant((Literal) values[1]); long periodMillis = convertPeriodToMillis((Literal) values[2], (URI) values[3]); long timeBetween = Math.abs(Duration.between(dateTime1, dateTime2).toMillis()); return valueFactory.createLiteral(timeBetween < periodMillis); } catch (Exception e) { throw new ValueExprEvaluationException(e); } }
Source:
<code><START> public JSONObject toJson() throws JSONException { <END> JSONObject metadata = new JSONObject(); metadata.put(JSON_VERSION_KEY, CURRENT_JSON_VERSION); metadata.put(CONTAINER_ID_KEY, id); metadata.put(CONTAINER_NAME_KEY, name); metadata.put(STATUS_KEY, status); metadata.put(DESCRIPTION_KEY, description); metadata.put(IS_PRIVATE_KEY, !cacheable); metadata.put(PARENT_ACCOUNT_ID_KEY, parentAccountId); return metadata; }</code><technical_language>this</technical_language>

Target:
JSONObject toJson() throws JSONException { JSONObject metadata = new JSONObject(); switch (currentJsonVersion) { case JSON_VERSION_1: metadata.put(JSON_VERSION_KEY, JSON_VERSION_1); metadata.put(CONTAINER_ID_KEY, id); metadata.put(CONTAINER_NAME_KEY, name); metadata.put(STATUS_KEY, status); metadata.put(DESCRIPTION_KEY, description); metadata.put(IS_PRIVATE_KEY, !cacheable); metadata.put(PARENT_ACCOUNT_ID_KEY, parentAccountId); break; case JSON_VERSION_2: metadata.put(Container.JSON_VERSION_KEY, JSON_VERSION_2); metadata.put(CONTAINER_ID_KEY, id); metadata.put(CONTAINER_NAME_KEY, name); metadata.put(Container.STATUS_KEY, status); metadata.put(DESCRIPTION_KEY, description); metadata.put(ENCRYPTED_KEY, encrypted); metadata.put(PREVIOUSLY_ENCRYPTED_KEY, previouslyEncrypted); metadata.put(CACHEABLE_KEY, cacheable); metadata.put(MEDIA_SCAN_DISABLED, mediaScanDisabled); break; default: throw new IllegalStateException("Unsupported container json version=" + currentJsonVersion); } return metadata; }
Source:
<code><START> public ListMultimap<Job, Future<Run>> perform2(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { <END> ListMultimap<Job, Future<Run>> futures = super.perform2(build, launcher, listener); if(block==null) return ArrayListMultimap.create(); return futures; }</code><technical_language>Binary compatibility breach. Collections promoted in</technical_language>

Target:
public ListMultimap<AbstractProject, Future<AbstractBuild>> perform2(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { ListMultimap<AbstractProject, Future<AbstractBuild>> futures = super.perform2(build, launcher, listener); if(block==null) return ArrayListMultimap.create(); return futures; }
Source:
<code>private int openBrowser(String command, String... parameters) { try { String[] commandArray = new String[parameters.length + 1]; commandArray[0] = command; <START> for (int i = 0; i < parameters.length; i++) { <END> commandArray[i + 1] = parameters[i]; } Process pr = Runtime.getRuntime().exec(commandArray); StreamConsumer outputs = new StreamConsumer(pr.getInputStream()); (outputs).start(); StreamConsumer errors = new StreamConsumer(pr.getErrorStream()); (errors).start(); pr.waitFor(); int ret = pr.exitValue(); if (ret == 0 && errorsInOutput(outputs, errors)) { return -1; } return ret; } catch (InterruptedException e) { } catch (IOException e) { WebBrowserUIPlugin.logError("Launching " + executable + " has failed.", e); return 0; } return -1; }</code><technical_language>System.arraycopy(parameters, 0, commandArray, 1, parameters.length)</technical_language>

Target:
private int openBrowser(String command, String... parameters) { try { String[] commandArray = new String[parameters.length + 1]; commandArray[0] = command; System.arraycopy(parameters, 0, commandArray, 1, parameters.length); Process pr = Runtime.getRuntime().exec(commandArray); StreamConsumer outputs = new StreamConsumer(pr.getInputStream()); (outputs).start(); StreamConsumer errors = new StreamConsumer(pr.getErrorStream()); (errors).start(); pr.waitFor(); int ret = pr.exitValue(); if (ret == 0 && errorsInOutput(outputs, errors)) { return -1; } return ret; } catch (InterruptedException e) { } catch (IOException e) { WebBrowserUIPlugin.logError("Launching " + executable + " has failed.", e); return 0; } return -1; }
Source:
<code>public JavaKeyStoreSecureStoreConfig setPassword(String password) { <START> checkNotNull(password, "Java Key Store password cannot be null!"); <END> this.password = password; return this; }</code><technical_language>keystore types require a password another channel (e.g. WINDOWS-MY type)</technical_language>

Target:
public JavaKeyStoreSecureStoreConfig setPassword(String password) { this.password = password; return this; }
Source:
<code>private synchronized boolean persist(GerritTriggeredEvent evt) { long ts = evt.getEventCreatedOn().getTime(); if (ts == 0) { logger.warn("Event CreatedOn is 0...Gerrit Server does not support attribute eventCreateOn. " + "Will NOT persist this event and Missed Events will be disabled!"); isSupported = false; return false; } if (serverTimestamp != null && ts < serverTimestamp.getTimeSlice()) { <START> logger.debug("Event has same time slice or is earlier...NOT Updating time slice.", ts); <END> } else { if (serverTimestamp == null) { serverTimestamp = new EventTimeSlice(ts); serverTimestamp.addEvent(evt); } else { if (ts > serverTimestamp.getTimeSlice()) { logger.debug("Current timestamp is GREATER than slice time {}.", ts, serverTimestamp.getTimeSlice()); serverTimestamp = new EventTimeSlice(ts); serverTimestamp.addEvent(evt); } else { if (ts == serverTimestamp.getTimeSlice()) { logger.debug("Current timestamp is EQUAL to slice time {}.", ts, serverTimestamp.getTimeSlice()); serverTimestamp.addEvent(evt); } } } } XmlFile config = getConfigXml(serverName); try { config.write(serverTimestamp); } catch (IOException e) { logger.error(e.getMessage(), e); return false; } return true; }</code><technical_language>return instead of persisting disk</technical_language>

Target:
private synchronized boolean persist(GerritTriggeredEvent evt) { long ts = evt.getEventCreatedOn().getTime(); if (ts == 0) { logger.warn("Event CreatedOn is 0...Gerrit Server does not support attribute eventCreateOn. " + "Will NOT persist this event and Missed Events will be disabled!"); isSupported = false; return false; } if (serverTimestamp != null && ts < serverTimestamp.getTimeSlice()) { logger.debug("Event has same time slice or is earlier...NOT Updating time slice.", ts); return false; } else { if (serverTimestamp == null) { serverTimestamp = new EventTimeSlice(ts); serverTimestamp.addEvent(evt); } else { if (ts > serverTimestamp.getTimeSlice()) { logger.debug("Current timestamp is GREATER than slice time {}.", ts, serverTimestamp.getTimeSlice()); serverTimestamp = new EventTimeSlice(ts); serverTimestamp.addEvent(evt); } else { if (ts == serverTimestamp.getTimeSlice()) { logger.debug("Current timestamp is EQUAL to slice time {}.", ts, serverTimestamp.getTimeSlice()); serverTimestamp.addEvent(evt); } } } } try { XmlFile config = getConfigXml(serverName); config.write(serverTimestamp); } catch (IOException e) { logger.error(e.getMessage(), e); return false; } return true; }
Source:
<code>public ApplePayConfig getApplePayConfig() { <START> return applePay; <END> }</code><technical_language>rename variable applePayConfig match please</technical_language>

Target:
public ApplePayConfig getApplePayConfig() { return applePayConfig; }
Source:
<code>public void executeTool() { try { Configuration conf = HBaseConfiguration.addHbaseResources(getConf()); <START> Connection conn = ConnectionUtil.getInputConnection(conf); <END> ConnectionQueryServices queryServices = conn.unwrap(PhoenixConnection.class) .getQueryServices(); extractTablesAndIndexes(conn.unwrap(PhoenixConnection.class)); executeTool(conn, queryServices, conf); } catch (SQLException e) { LOGGER.severe("Something went wrong in executing tool "+ e); System.exit(-1); } }</code><technical_language>is this conn closed? a try-with-resources</technical_language>

Target:
public int executeTool() { Configuration conf = HBaseConfiguration.addHbaseResources(getConf()); try (Connection conn = ConnectionUtil.getInputConnection(conf)) { ConnectionQueryServices queryServices = conn.unwrap(PhoenixConnection.class) .getQueryServices(); boolean status = extractTablesAndIndexes(conn.unwrap(PhoenixConnection.class)); if (status) { return executeTool(conn, queryServices, conf); } } catch (SQLException e) { LOGGER.severe("Something went wrong in executing tool "+ e); } return -1; }
Source:
<code><START> private LinkedHashMap<String, ArrayList<String>> getPathToAliases(MapredWork mrWork) { <END> String mapWorkClassName = "org.apache.hadoop.hive.ql.plan.MapWork"; Class<?> clazz = MapredWork.class; Method m_getMapWork = null; try { clazz = Class.forName(mapWorkClassName); m_getMapWork = MapredWork.class.getDeclaredMethod("getMapWork"); } catch (Exception e) { LOG.info("No Hive 0.12.0 compatible API was found, couldn't load " + mapWorkClassName); LOG.debug(e); } try { Method m_getPathToAlias = clazz.getDeclaredMethod("getPathToAliases"); Object obj = (m_getMapWork == null) ? mrWork : m_getMapWork.invoke(mrWork); return (LinkedHashMap<String, ArrayList<String>>) m_getPathToAlias.invoke(obj); } catch (Exception e) { LOG.fatal("Can't access to getPathToAliases() on " + MapredWork.class.getName(), e); throw new RuntimeException("Incompatible Hive API found. Expected: 0.11.0+", e); } }</code><technical_language>Consider performing hive version check keeping reference a Function instance this work for you. Function impl is chosen based result of version check</technical_language>

Target:
private LinkedHashMap<String, ArrayList<String>> getPathToAliases(MapredWork mrWork) { return closure.apply(mrWork); }
Source:
<code>public void registerConvertersIn(GenericConversionService conversionService) { Assert.notNull(conversionService, "ConversionService must not be null!"); converters.forEach(it -> { boolean added = false; if (it instanceof Converter) { conversionService.addConverter(Converter.class.cast(it)); added = true; } if (it instanceof ConverterFactory) { conversionService.addConverterFactory(ConverterFactory.class.cast(it)); added = true; } if (it instanceof GenericConverter) { conversionService.addConverter(GenericConverter.class.cast(it)); added = true; } if (!added) { <START> throw new IllegalArgumentException( <END> "Given set contains element that is neither Converter nor ConverterFactory!"); } }); }</code><technical_language>sense mention offending object in exception message</technical_language>

Target:
public void registerConvertersIn(GenericConversionService conversionService) { Assert.notNull(conversionService, "ConversionService must not be null!"); converters.forEach(it -> { boolean added = false; if (it instanceof Converter) { conversionService.addConverter(Converter.class.cast(it)); added = true; } if (it instanceof ConverterFactory) { conversionService.addConverterFactory(ConverterFactory.class.cast(it)); added = true; } if (it instanceof GenericConverter) { conversionService.addConverter(GenericConverter.class.cast(it)); added = true; } if (!added) { throw new IllegalArgumentException(String.format(NOT_A_CONVERTER, it)); } }); }
Source:
<code>protected boolean isLinked(String channelId) { Channel channel = thing.getChannel(channelId); if (channel != null) { <START> return !linkRegistry.getLinks(channel.getUID()).isEmpty(); <END> } else { throw new IllegalArgumentException("Channel with ID '" + channelId + "' does not exists."); } }</code><technical_language>I assume linkRegistry null here</technical_language>

Target:
protected boolean isLinked(String channelId) { Channel channel = thing.getChannel(channelId); if (channel != null) { return linkRegistry != null ? !linkRegistry.getLinks(channel.getUID()).isEmpty() : false; } else { throw new IllegalArgumentException("Channel with ID '" + channelId + "' does not exists."); } }
Source:
<code>public void setDefaultPrivilegesForCoowner() { <START> this.courseLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE, Boolean.valueOf(true)); <END> this.courseLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, Boolean.valueOf(true)); this.courseLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION, Boolean.valueOf(true)); this.courseLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, Boolean.valueOf(true)); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTION, Boolean.valueOf(true)); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTION, Boolean.valueOf(true)); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTION, Boolean.valueOf(true)); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTION, Boolean.valueOf(true)); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTION, Boolean.valueOf(true)); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTION, Boolean.valueOf(true)); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTION, Boolean.valueOf(true)); }</code><technical_language>passing true work? Java 7 is supposed auto-boxing</technical_language>

Target:
public void setDefaultPrivilegesForCoowner() { this.courseLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE, true); this.courseLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, true); this.courseLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION, true); this.courseLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, true); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTION, true); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTION, true); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTION, true); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTION, true); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTION, true); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTION, true); this.sectionLevel.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTION, true); }
Source:
<code>private void downloadSingleProjectTest() throws IOException { List<String> expectedPackageFileList = asList( ".che/classpath", "README.md", "pom.xml", "src/main/java/org/eclipse/qa/examples/AppController.java", "src/main/webapp/WEB-INF/jsp/guess_num.jsp", "src/main/webapp/WEB-INF/spring-servlet.xml", "src/main/webapp/WEB-INF/web.xml", "src/main/webapp/index.jsp"); projectExplorer.waitAndSelectItem(TEST_PROJECT_1); projectExplorer.openContextMenuByPathSelectedItem(TEST_PROJECT_1); projectExplorer.clickOnItemInContextMenu(ContextMenuFirstLevelItems.DOWNLOAD); assertEquals( getPackageFileList(DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME), expectedPackageFileList.toString()); <START> <END> menu.runCommand( TestMenuCommandsConstants.Project.PROJECT, TestMenuCommandsConstants.Project.DOWNLOAD_AS_ZIP); assertEquals( getPackageFileList(DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME), expectedPackageFileList.toString()); }</code><technical_language>need remove downloaded package</technical_language>

Target:
private void downloadSingleProjectTest() throws IOException { List<String> expectedPackageFileList = asList( ".che/classpath", "README.md", "pom.xml", "src/main/java/org/eclipse/qa/examples/AppController.java", "src/main/webapp/WEB-INF/jsp/guess_num.jsp", "src/main/webapp/WEB-INF/spring-servlet.xml", "src/main/webapp/WEB-INF/web.xml", "src/main/webapp/index.jsp"); projectExplorer.waitAndSelectItem(TEST_PROJECT_1); projectExplorer.openContextMenuByPathSelectedItem(TEST_PROJECT_1); projectExplorer.clickOnItemInContextMenu(ContextMenuFirstLevelItems.DOWNLOAD); assertEquals( getPackageFileList(DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME), expectedPackageFileList.toString()); downloadedFileUtil.removeDownloadedFiles( seleniumWebDriver.getSessionId(), DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME); menu.runCommand( TestMenuCommandsConstants.Project.PROJECT, TestMenuCommandsConstants.Project.DOWNLOAD_AS_ZIP); assertEquals( getPackageFileList(DOWNLOADED_TEST_PROJECT_1_PACKAGE_NAME), expectedPackageFileList.toString()); }
Source:
<code>public EC2OndemandSlave(String instanceId, String description, String remoteFS, int numExecutors, String labelString, Mode mode, String initScript, String tmpDir, String remoteAdmin, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, String cloudName, boolean useDedicatedTenancy, int launchTimeout, AMITypeData amiType) throws FormException, IOException { <START> this(description + " (" + instanceId + ")", instanceId, description, remoteFS, numExecutors, labelString, mode, initScript, tmpDir, Collections.emptyList(), remoteAdmin, jvmopts, stopOnTerminate, idleTerminationMinutes, publicDNS, privateDNS, tags, cloudName, useDedicatedTenancy, launchTimeout, amiType); <END> }</code><technical_language>compatibility concern in EC2AbstractSlave</technical_language>

Target:
public EC2OndemandSlave(String instanceId, String description, String remoteFS, int numExecutors, String labelString, Mode mode, String initScript, String tmpDir, String remoteAdmin, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, String cloudName, boolean useDedicatedTenancy, int launchTimeout, AMITypeData amiType) throws FormException, IOException { this(instanceId, description, remoteFS, numExecutors, labelString, mode, initScript, tmpDir, remoteAdmin, jvmopts, stopOnTerminate, idleTerminationMinutes, publicDNS, privateDNS, tags, cloudName, false, useDedicatedTenancy, launchTimeout, amiType); }