auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public VirtualColumns getVirtualColumns(final ExprMacroTable macroTable, final boolean includeDimensions) { final List<VirtualColumn> retVal = new ArrayList<>(); if (selectProjection != null) { retVal.addAll(selectProjection.getVirtualColumns()); } else { if (sortProject != null) { for (Aggregation aggregation : sortProject.getPostAggregators()) { <START> retVal.addAll(aggregation.getVirtualColumns()); <END> } } if (grouping != null) { if (includeDimensions) { for (DimensionExpression dimensionExpression : grouping.getDimensions()) { retVal.addAll(dimensionExpression.getVirtualColumns(macroTable)); } } for (Aggregation aggregation : grouping.getAggregations()) { retVal.addAll(aggregation.getVirtualColumns()); } } } return VirtualColumns.create(retVal); }</code><technical_language>virtual columns added post-aggregators (virtual columns added aggregators read input data). This code removed naturally if getPostAggregators changed return List<PostAggregator> List<Aggregation>, a point in favor of changing types</technical_language>

Target:
public VirtualColumns getVirtualColumns(final ExprMacroTable macroTable, final boolean includeDimensions) { final List<VirtualColumn> retVal = new ArrayList<>(); if (selectProjection != null) { retVal.addAll(selectProjection.getVirtualColumns()); } else { if (grouping != null) { if (includeDimensions) { for (DimensionExpression dimensionExpression : grouping.getDimensions()) { retVal.addAll(dimensionExpression.getVirtualColumns(macroTable)); } } for (Aggregation aggregation : grouping.getAggregations()) { retVal.addAll(aggregation.getVirtualColumns()); } } } return VirtualColumns.create(retVal); }
Source:
<code>public void jenkinsSecretHidden() throws Exception { SemaphoreStep.waitForStart("pod/1", b); List<SlaveComputer> kc = Arrays.stream(r.jenkins.getComputers()) .filter(SlaveComputer.class::isInstance) .map(SlaveComputer.class::cast) <START> .collect(Collectors.toList()); <END> assertThat(kc, hasSize(1)); SlaveComputer slaveComputer = kc.get(0); String jnlpMac = slaveComputer.getJnlpMac(); SemaphoreStep.success("pod/1", b); r.assertBuildStatusSuccess(r.waitForCompletion(b)); r.assertLogNotContains("value: \""+jnlpMac+"\"", b); }</code><technical_language>findAny</technical_language>

Target:
public void jenkinsSecretHidden() throws Exception { SemaphoreStep.waitForStart("pod/1", b); Optional<SlaveComputer> scOptional = Arrays.stream(r.jenkins.getComputers()) .filter(SlaveComputer.class::isInstance) .map(SlaveComputer.class::cast) .findAny(); assertTrue(scOptional.isPresent()); String jnlpMac = scOptional.get().getJnlpMac(); SemaphoreStep.success("pod/1", b); r.assertBuildStatusSuccess(r.waitForCompletion(b)); r.assertLogNotContains(jnlpMac, b); }
Source:
<code>public SampleList getLastCreatedByUserID(final Integer userID, final String programUUID) { try { if (userID != null) { final Criteria criteria = this.getSession().createCriteria(SampleList.class); criteria.add(Restrictions.eq("createdBy.userid", userID)); this.addCriteriaForProgramUUIDInLists(programUUID, criteria); this.hideSnapshotListTypes(criteria); criteria.addOrder(Order.desc("id")); final List result = criteria.list(); if (!result.isEmpty()) { return (SampleList) result.get(0); } else { return null; } } } catch (final HibernateException e) { <START> this.logAndThrowException("Error with getByUserID(userID=" + userID + ") query from GermplasmList: " + e.getMessage(), e); <END> } return null; }</code><technical_language>@cuenyad replace Log Throw</technical_language>

Target:
public SampleList getLastCreatedByUserID(final Integer userID, final String programUUID) { try { if (userID != null) { final Criteria criteria = this.getSession().createCriteria(SampleList.class); criteria.add(Restrictions.eq("createdBy.userid", userID)); this.addCriteriaForProgramUUIDInLists(programUUID, criteria); this.hideSnapshotListTypes(criteria); criteria.addOrder(Order.desc("id")); final List result = criteria.list(); if (!result.isEmpty()) { return (SampleList) result.get(0); } else { return null; } } } catch (final HibernateException e) { throw new MiddlewareQueryException("Error with getByUserID(userID=" + userID + ") query from GermplasmList: " + e.getMessage(), e); } return null; }
Source:
<code>protected boolean isDirectEditEnabled() { boolean directEditEnabled = false; final EObject eObj = resolveSemanticElement(); if (eObj instanceof DMappingBased) { final DMappingBased mappingBasedObject = (DMappingBased) eObj; if (mappingBasedObject.getMapping() != null && mappingBasedObject instanceof DDiagramElement && ((DDiagramElement) mappingBasedObject).getDiagramElementMapping().getLabelDirectEdit() != null) { directEditEnabled = !isInLayoutingModeDiagram((DDiagramElement) mappingBasedObject); DirectEditLabel labelDirectEdit = ((DDiagramElement) mappingBasedObject).getDiagramElementMapping().getLabelDirectEdit(); final DirectEditCommandBuilder builder = new DirectEditCommandBuilder((DDiagramElement) mappingBasedObject, labelDirectEdit, null); directEditEnabled = directEditEnabled && <START> builder.checkPrecondition(); <END> } } return directEditEnabled; }</code><technical_language>call canDirectEdit instead , this method IsInLayoutingMode check is private this moment</technical_language>

Target:
protected boolean isDirectEditEnabled() { boolean directEditEnabled = false; final EObject eObj = resolveSemanticElement(); if (eObj instanceof DMappingBased) { final DMappingBased mappingBasedObject = (DMappingBased) eObj; if (mappingBasedObject.getMapping() != null && mappingBasedObject instanceof DDiagramElement && ((DDiagramElement) mappingBasedObject).getDiagramElementMapping().getLabelDirectEdit() != null) { DirectEditLabel labelDirectEdit = ((DDiagramElement) mappingBasedObject).getDiagramElementMapping().getLabelDirectEdit(); final DirectEditCommandBuilder builder = new DirectEditCommandBuilder((DDiagramElement) mappingBasedObject, labelDirectEdit, null); directEditEnabled = builder.canDirectEdit(); } } return directEditEnabled; }
Source:
<code>public void deploy(DeploymentPhaseContext phaseContext) { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); ModuleLoader moduleLoader = Module.getBootModuleLoader(); <START> moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, "org.eclipse.microprofile.fault-tolerance.api", false, false, true, false)); <END> moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, "io.smallrye.fault-tolerance", false, false, true, false)); }</code><technical_language>services this module import</technical_language>

Target:
public void deploy(DeploymentPhaseContext phaseContext) { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); Optional<WeldCapability> weldCapability = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class); if (weldCapability.isPresent() && weldCapability.get().isPartOfWeldDeployment(deploymentUnit) && MicroProfileFaultToleranceMarker.hasMicroProfileFaultToleranceAnnotations(deploymentUnit)) { MicroProfileFaultToleranceMarker.mark(deploymentUnit); ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); ModuleLoader moduleLoader = Module.getBootModuleLoader(); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, "org.eclipse.microprofile.fault-tolerance.api", false, false, false, false)); } }
Source:
<code>private String parse(String fieldName, String qs, String lang) { <START> qs = qs.replaceAll("\\:", "\\\\:") <END> .replaceAll("\\+", "\\\\+") .replaceAll("\\-", "\\\\-") .replaceAll("\\=", "\\\\=") .replaceAll("\\&", "\\\\&") .replaceAll("\\|", "\\\\|") .replaceAll("\\>", "\\\\>") .replaceAll("\\<", "\\\\<") .replaceAll("\\!", "\\\\!") .replaceAll("\\(", "\\\\(") .replaceAll("\\)", "\\\\)") .replaceAll("\\{", "\\\\{") .replaceAll("\\}", "\\\\}") .replaceAll("\\]", "\\\\]") .replaceAll("\\[", "\\\\[") .replaceAll("\\^", "\\\\^") .replaceAll("\\~", "\\\\~") .replaceAll("\\?", "\\\\?"); if(fieldName != null && !fieldName.isEmpty()) { if(lang != null && !lang.equals("none")) { if (!ASTERISK.equals(lang)) { fieldName = fieldName + UNDERSCORE + lang.replaceAll(DASH, UNDERSCORE); qs = fieldName + COLON + qs; } else { if(!qs.contains("\\*")) { fieldName = fieldName + ASTERISK; qs = fieldName + COLON + qs; } } } else { qs = fieldName + COLON + qs; } } return qs.replaceAll("\\*", "\\\\*"); }</code><technical_language>This a question of style, this read a bit a set of constant Patterns? (I enough usefully performance implications, I Patterns _least_ performant.)</technical_language>

Target:
private String parse(String fieldName, String qs, String lang) { qs = QueryParserBase.escape(qs); if(fieldName != null && !fieldName.isEmpty()) { if(lang != null && !lang.equals("none")) { if (!ASTERISK.equals(lang)) { fieldName = fieldName + UNDERSCORE + lang.replaceAll(DASH, UNDERSCORE); qs = fieldName + COLON + qs; } else { if(!qs.contains("\\*")) { fieldName = fieldName + ASTERISK; qs = fieldName + COLON + qs; } } } else { qs = fieldName + COLON + qs; } } return qs.replaceAll("\\*", "\\\\*"); }
Source:
<code>protected int getWorkersAlive() { int count = 0; for (int i = 0; i < requestWorkerThreads.size(); i++) { <START> if (asyncRequestWorkers.get(i).isRunning() && requestWorkerThreads.get(i).isAlive()) { <END> count++; } } return count; }</code><technical_language>ensure isRunning is in sync isAlive() check for both. Ideally, isAlive() check dropped</technical_language>

Target:
protected int getWorkersAlive() { int count = 0; for (int i = 0; i < asyncRequestWorkers.size(); i++) { if (asyncRequestWorkers.get(i).isRunning()) { count++; } } return count; }
Source:
<code><START> protected void syncSearch() { <END> if (getParentEntity() != null) { super.syncSearch(); AsyncQuery asyncQuery = new AsyncQuery(this, new INewAsyncCallback() { @Override public void onSuccess(Object model, Object returnValue) { AffinityGroupListModel<?> affinityGroupListModel = (AffinityGroupListModel<?>) model; ArrayList<AffinityGroup> list = (ArrayList<AffinityGroup>) ((VdcQueryReturnValue) returnValue).getReturnValue(); affinityGroupListModel.setItems(list); } }); VdcQueryParametersBase parameters = new IdQueryParameters(getParentEntity().getId()); parameters.setRefresh(getIsQueryFirstTime()); Frontend.getInstance().runQuery(getQueryType(), parameters, asyncQuery); setIsQueryFirstTime(false); } }</code><technical_language>Is good reason implement this call super.syncSearch() getQueryType() argument</technical_language>

Target:
protected void syncSearch() { if (getParentEntity() != null) { super.syncSearch(queryType, new IdQueryParameters(getParentEntity().getId())); } }
Source:
<code>protected void process(String tenantId, List<S> items, int retryCount) throws Exception { ProcessingUnit<S, T> pu = new ProcessingUnit<S, T>(); pu.setProcessor(getProcessor()); pu.setRetryCount(retryCount); <START> pu.setResultHandler(new Handler<T>() { <END> @Override public void handle(String tenantId, List<T> items) throws Exception { getPublisher().publish(tenantId, items, getPublisher().getInitialRetryCount(), getProcessor().getDeliveryDelay(items)); } }); pu.setRetryHandler(new Handler<S>() { @Override public void handle(String tenantId, List<S> items) throws Exception { getRetryPublisher().publish(tenantId, items, pu.getRetryCount() - 1, getProcessor().getRetryDelay(items)); } }); pu.handle(tenantId, items); }</code><technical_language>minimum Java version for this module? I more readable a lambda here</technical_language>

Target:
protected void process(String tenantId, List<S> items, int retryCount) throws Exception { ProcessingUnit<S, T> pu = new ProcessingUnit<S, T>(); pu.setProcessor(getProcessor()); pu.setRetryCount(retryCount); pu.setResultHandler( (tid, events) -> getPublisher().publish(tid, events, getPublisher().getInitialRetryCount(), getProcessor().getDeliveryDelay(events)) ); pu.setRetryHandler( (tid, events) -> getRetryPublisher().publish(tid, events, pu.getRetryCount() - 1, getProcessor().getRetryDelay(events)) ); pu.handle(tenantId, items); }
Source:
<code>private Object calculate(SimpleFeatureCollection featureCollection) { <START> FeatureCalc quantileVisit = getListVisitor(); <END> if (progress == null) progress = new NullProgressListener(); try { featureCollection.accepts(quantileVisit, progress); } catch (IOException e) { LOGGER.log( Level.SEVERE, "QuantileFunction calculate(SimpleFeatureCollection) failed", e); return null; } if (progress.isCanceled()) return null; CalcResult calcResult = quantileVisit.getResult(); if (calcResult == null || calcResult == CalcResult.NULL_RESULT) { return null; } List[] bin = (List[]) calcResult.getValue(); Comparable globalMin = (Comparable) bin[0].toArray()[0]; Object lastBin[] = bin[bin.length - 1].toArray(); if (lastBin.length == 0) { return null; } Comparable globalMax = (Comparable) lastBin[lastBin.length - 1]; if ((globalMin instanceof Number) && (globalMax instanceof Number)) { return calculateNumerical(bin, globalMin, globalMax); } else { return calculateNonNumerical(bin); } }</code><technical_language>quantityVisit here</technical_language>

Target:
private Object calculate(SimpleFeatureCollection featureCollection) { FeatureCalc quantityVisitor = getListVisitor(); if (progress == null) progress = new NullProgressListener(); try { featureCollection.accepts(quantityVisitor, progress); } catch (IOException e) { LOGGER.log( Level.SEVERE, "QuantileFunction calculate(SimpleFeatureCollection) failed", e); return null; } if (progress.isCanceled()) return null; CalcResult calcResult = quantityVisitor.getResult(); if (calcResult == null || calcResult == CalcResult.NULL_RESULT) { return null; } List[] bin = (List[]) calcResult.getValue(); Comparable globalMin = (Comparable) bin[0].toArray()[0]; Object lastBin[] = bin[bin.length - 1].toArray(); if (lastBin.length == 0) { return null; } Comparable globalMax = (Comparable) lastBin[lastBin.length - 1]; if ((globalMin instanceof Number) && (globalMax instanceof Number)) { return calculateNumerical(bin, globalMin, globalMax); } else { return calculateNonNumerical(bin); } }
Source:
<code>public String getIconFilePathPattern() { if (Jenkins.RESOURCE_PATH.isEmpty()) { return "images/:size/freestyleproject.png"; } else { <START> return Jenkins.RESOURCE_PATH.substring(1) + "/images/:size/freestyleproject.png"; <END> } }</code><technical_language>ant: e3b11aefa28a524fe739ce4361af7fba55fa858e explain anything, if switch overkill. original code java return Jenkins.RESOURCE_PATH + "images/:size/freestyleproject.png"; work returned /static/abc123images/:size/freestyleproject.png is clearer fix e.g. java return (Jenkins.RESOURCE_PATH + "/images/:size/freestyleproject.png").replaceFirst("^/", ""); simply caller of getIconFilePathPattern() tolerate a leading slash</technical_language>

Target:
public String getIconFilePathPattern() { return (Jenkins.RESOURCE_PATH + "/images/:size/freestyleproject.png").replaceFirst("^/", ""); }
Source:
<code>private HashMap<String, String> getContainerInfo(PID pid, int entry) { ObjectPath objPath = objectPathFactory.getPath(pid); String objAdminUnit = null; String objAdminUnitTitle = ""; String objContainer = ""; String objContainerTitle = ""; if (objPath != null) { List<ObjectPathEntry> objPathList = objPath.getEntries(); if (objPathList.size() > 1) { ObjectPathEntry destEntry = objPathList.get(1); objAdminUnit = destEntry.getPid(); objAdminUnitTitle = destEntry.getName(); ObjectPathEntry objContainerEntry = objPathList.get(objPathList.size() - entry); objContainer = objContainerEntry.getPid(); objContainerTitle = objContainerEntry.getName(); } } <START> HashMap<String, String> entryValues = new HashMap<String, String>(); <END> entryValues.put("adminUnit", objAdminUnit); entryValues.put("adminUnitTitle", objAdminUnitTitle); entryValues.put("container", objContainer); entryValues.put("containerTitle", objContainerTitle); return entryValues; }</code><technical_language>suggestion Map<String, String> entryValues = new HashMap<>();</technical_language>

Target:
private Map<String, String> getContainerInfo(PID pid, int entry) { ObjectPath objPath = objectPathFactory.getPath(pid); String objAdminUnit = null; String objAdminUnitTitle = ""; String objContainer = ""; String objContainerTitle = ""; if (objPath != null) { List<ObjectPathEntry> objPathList = objPath.getEntries(); if (objPathList.size() > 1) { ObjectPathEntry destEntry = objPathList.get(1); objAdminUnit = destEntry.getPid(); objAdminUnitTitle = destEntry.getName(); ObjectPathEntry objContainerEntry = objPathList.get(objPathList.size() - entry); objContainer = objContainerEntry.getPid(); objContainerTitle = objContainerEntry.getName(); } } Map<String, String> entryValues = new HashMap<>(); entryValues.put("adminUnit", objAdminUnit); entryValues.put("adminUnitTitle", objAdminUnitTitle); entryValues.put("container", objContainer); entryValues.put("containerTitle", objContainerTitle); return entryValues; }
Source:
<code>public static boolean isGranted(final Type type, @NonNull final String permissions[], @NonNull final int grantResults[]) { if (permissions.length != 1) { Lg.w("expected exactly one permission but got: ", TextUtils.join(", ", permissions)); } <START> <END> if (!Util.equalString(permissions[0], type.getPermission())) { Lg.w("expected permission: ", type.getPermission(), " but got: ", permissions[0]); return false; } if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { Lg.i("permission granted: ", permissions[0]); return true; } else { Lg.i("permission denied: ", permissions[0]); return false; } }</code><technical_language>final String permission = permissions[0];</technical_language>

Target:
public static boolean isGranted(final Type type, @NonNull final String permissions[], @NonNull final int grantResults[]) { if (permissions.length != 1) { Lg.w("expected exactly one permission but got: ", TextUtils.join(", ", permissions)); } final String permission = permissions[0]; if (!Util.equalString(permission, type.getPermission())) { Lg.w("expected permission: ", type.getPermission(), " but got: ", permission); return false; } if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { Lg.i("permission granted: ", permission); return true; } else { Lg.i("permission denied: ", permission); return false; } }
Source:
<code>protected Command getCommand(IEvaluationContext context) { TransactionalEditingDomain editingDomain = getEditingDomain(context); List<Table> tables = getSelectedTables(); if (editingDomain != null && tables.size() == 1) { final Table table = tables.get(0); final String tableLabel = LabelInternationalization.getInstance().getTableLabelWithoutName(table); if (null != tableLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(table)) { AbstractTransactionalCommand cmd = new <START> RenameTableLabelCommand( <END> editingDomain, "ChangeTableLabelCommand", table, tableLabel, "Rename table label...", "New label:"); return new GMFtoEMFCommandWrapper(cmd); } else { final String currentName = table.getName(); if (null != currentName) { return new RenameElementCommand( editingDomain, "RenameTableCommand", table, currentName, Messages.RenameTableHandler_RenameAnExistingTable, Messages.RenameTableHandler_NewName); } } } return UnexecutableCommand.INSTANCE; }</code><technical_language>discuss Nicolas, this class is useless. LabelInternationalizationUtils.getSetLabelCommand I</technical_language>

Target:
protected Command getCommand(IEvaluationContext context) { TransactionalEditingDomain editingDomain = getEditingDomain(context); List<Table> tables = getSelectedTables(); if (editingDomain != null && tables.size() == 1) { final Table table = tables.get(0); final String tableLabel = LabelInternationalization.getInstance().getTableLabelWithoutName(table); if (null != tableLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(table)) { AbstractTransactionalCommand cmd = new RenameTableLabelCommand(editingDomain, "ChangeTableLabelCommand", table, tableLabel, Messages.RenameTableHandler_Label_DialogTitle); return new GMFtoEMFCommandWrapper(cmd); } else { final String currentName = table.getName(); if (null != currentName) { EStructuralFeature nameFeature = table.eClass().getEStructuralFeature("name"); return new RenameElementCommand(editingDomain, "RenameTableCommand", table, currentName, nameFeature, Messages.RenameTableHandler_RenameAnExistingTable, Messages.RenameTableHandler_NewName); } } } return UnexecutableCommand.INSTANCE; }
Source:
<code>V get( long idx ) <START> { <END> if ( idx < 0 ) { throw new IllegalArgumentException( "Index must be >= 0" ); } if ( idx > endIndex || idx < firstIndex() ) { return null; } return circle.read( toIntExact( idx - firstIndex() ) ); }</code><technical_language>suggest Optional again</technical_language>

Target:
V get( long idx ) { if ( idx < 0 ) { throw new IllegalArgumentException( format( "Index must be >= 0 (was %d)", idx ) ); } if ( idx > endIndex || idx < firstIndex() ) { return null; } return circle.read( toIntExact( idx - firstIndex() ) ); }
Source:
<code>protected APIResult update(InputStream inputStream, String type, String entityName, String colo, Boolean skipDryRun) { checkColo(colo); try { EntityType entityType = EntityType.getEnum(type); Entity entity = deserializeEntity(inputStream, entityType); return update(entity, type, entityName, skipDryRun); } catch (IOException | FalconException e) { LOG.error("Update failed", e); <START> throw FalconWebException.newAPIException(e, Response.Status.BAD_REQUEST); <END> } }</code><technical_language>HTTP 400 Bad Request code is returned request understood server due malformed syntax. client repeat request modifications. I exceptions deserializeEntity return BAD_REQUEST exceptions of update return INTERNAL_SERVER_ERROR</technical_language>

Target:
protected APIResult update(InputStream inputStream, String type, String entityName, String colo, Boolean skipDryRun) { checkColo(colo); try { EntityType entityType = EntityType.getEnum(type); Entity entity = deserializeEntity(inputStream, entityType); return update(entity, type, entityName, skipDryRun); } catch (IOException | FalconException e) { LOG.error("Update failed", e); throw FalconWebException.newAPIException(e, Response.Status.INTERNAL_SERVER_ERROR); } }
Source:
<code>protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type) { <START> return runConnectionStorageToDomain(storageDomain, vdsId, type, null, Guid.Empty); <END> }</code><technical_language>need pass correct pool id</technical_language>

Target:
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type) { Guid poolId = Guid.Empty; if (storageDomain.getStoragePoolId() != null) { poolId = storageDomain.getStoragePoolId(); } return runConnectionStorageToDomain(storageDomain, vdsId, type, null, poolId); }
Source:
<code>public void testGetMany() { String key1 = "foo1"; String key2 = "foo2"; String key3 = "foo3"; Set<String> keys = new HashSet<>(Arrays.asList(key1, key2, key3)); <START> assertMapDeepEquals(new HashMap(0), store.get(keys)); <END> Map<String, String> kvMap = new HashMap<>(); kvMap.put(key1, BAR); kvMap.put(key2, GEE); kvMap.put(key3, MOO); store.put(key1, BAR); store.put(key2, GEE); store.put(key3, MOO); assertMapDeepEquals(kvMap, store.getStrings(keys)); store.put(key1, BAR_B); store.put(key2, GEE_B); store.put(key3, MOO_B); Map<String, byte[]> storeKVBMap = store.get(keys); assertArrayEquals(BAR_B, storeKVBMap.get(key1)); assertArrayEquals(GEE_B, storeKVBMap.get(key2)); assertArrayEquals(MOO_B, storeKVBMap.get(key3)); keys.add("foo4"); assertMapDeepEquals(kvMap, store.getStrings(keys)); }</code><technical_language>new HashMap(0) -> Collections.emptyMap()</technical_language>

Target:
public void testGetMany() { String key1 = "foo1"; String key2 = "foo2"; String key3 = "foo3"; String key4 = "foo4"; String key5 = "foo5"; Set<String> keys = new HashSet<>(Arrays.asList(key1, key2, key3, key4, key5)); assertEquals(Collections.emptyMap(), store.get(keys)); Map<String, String> map = new HashMap<>(); map.put(key1, BAR); map.put(key2, GEE); map.put(key3, MOO); store.put(key1, BAR); store.put(key2, GEE); store.put(key3, MOO); store.put(key4, (String) null); assertEquals(map, store.getStrings(keys)); store.put(key1, BAR_B); store.put(key2, GEE_B); store.put(key3, MOO_B); Map<String, byte[]> storeBMap = store.get(keys); assertArrayEquals(BAR_B, storeBMap.get(key1)); assertArrayEquals(GEE_B, storeBMap.get(key2)); assertArrayEquals(MOO_B, storeBMap.get(key3)); assertEquals(3, storeBMap.entrySet().size()); }
Source:
<code>public boolean hasResourceInstanceGroupTag() { <START> return _resourceInstanceGroupTag != null; <END> }</code><technical_language>nit, _resourceInstanceGroupTag != null && !_resourceInstanceGroupTag.isEmpty()</technical_language>

Target:
public boolean hasResourceInstanceGroupTag() { return _resourceInstanceGroupTag != null && !_resourceInstanceGroupTag.isEmpty(); }
Source:
<code>protected void compute(CoreSession session, List<String> ids, Map<String, Serializable> properties) { for (DocumentModel recordDoc : loadDocuments(session, ids)) { if (!recordDoc.hasFacet(RetentionConstants.RECORD_FACET)) { log.debug("Document is not a record, ignoring ...", recordDoc::getPathAsString); continue; } Record record = recordDoc.getAdapter(Record.class); if (!record.isRetentionIndeterminate()) { log.debug("Record has already a determinate retention date {}, ignoring ...", recordDoc::getPathAsString, () -> (recordDoc.getRetainUntil() == null ? null : recordDoc.getRetainUntil().toInstant())); continue; } RetentionRule rule = record.getRule(session); if (!rule.isEventBased()) { log.debug("Record does not have a event-based rule, ignoring ...", recordDoc::getPathAsString); <START> continue; <END> } session.setRetainUntil(recordDoc.getRef(), record.getRule(session).getRetainUntilDateFromNow(), null); } }</code><technical_language>a event-based -> event-based</technical_language>

Target:
protected void compute(CoreSession session, List<String> ids, Map<String, Serializable> properties) { for (DocumentModel recordDoc : loadDocuments(session, ids)) { if (!recordDoc.hasFacet(RetentionConstants.RECORD_FACET)) { log.debug("Document is not a record, ignoring ...", recordDoc::getPathAsString); continue; } Record record = recordDoc.getAdapter(Record.class); if (!record.isRetentionIndeterminate()) { log.debug("Record has already a determinate retention date {}, ignoring ...", recordDoc::getPathAsString, () -> (recordDoc.getRetainUntil() == null ? null : recordDoc.getRetainUntil().toInstant())); continue; } RetentionRule rule = record.getRule(session); if (!rule.isEventBased()) { log.debug("Record does not have an event-based rule, ignoring ...", recordDoc::getPathAsString); continue; } session.setRetainUntil(recordDoc.getRef(), record.getRule(session).getRetainUntilDateFromNow(), null); } }
Source:
<code>protected ProjectDataModelOracle getProjectDataModelOracle(final Path path ) { final ProjectDataModelOracle dmo = new ProjectDataModelOracleImpl(); dmo.addProjectModelFields( new HashMap<String, ModelField[]>() {{ <START> put( "org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant", <END> new ModelField[]{ new ModelField("age", "java.lang.Integer", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER ) } ); put( "org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Mortgage", new ModelField[]{ new ModelField( "amount", "java.lang.Integer", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER ), new ModelField( "applicant", "org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, "org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant" ) } ); }} ); return dmo; }</code><technical_language>@manstis string replaced Applicant.class.getCanonicalName(). point of view advantages: - refactored IDE class moves is renamed - shorter - DRY Please this a style recommendation/suggestion. I understand consistency other tests in this project is another concern leave decide if this is worth change</technical_language>

Target:
protected ProjectDataModelOracle getProjectDataModelOracle(final Path path) { final ProjectDataModelOracle dmo = new ProjectDataModelOracleImpl(); dmo.addProjectModelFields(new HashMap<String, ModelField[]>() {{ put(Applicant.class.getCanonicalName(), new ModelField[]{ new ModelField("age", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER)}); put(Mortgage.class.getCanonicalName(), new ModelField[]{ new ModelField("amount", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER), new ModelField("applicant", Applicant.class.getCanonicalName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, Applicant.class.getCanonicalName())}); }}); return dmo; }
Source:
<code>protected void pulsePhysics() { Location velLoc = location.clone().add(velocity); velocity.setY(airDrag * (velocity.getY() + getGravityAccel().getY())); velocity.setX(velocity.getX() * 0.95); velocity.setZ(velocity.getZ() * 0.95); setRawLocation(velLoc); if(!isTouchingMaterial(Material.AIR) && !isTouchingMaterial(Material.WATER) && !isTouchingMaterial(Material.LAVA) && !isTouchingMaterial(Material.STATIONARY_WATER) && !isTouchingMaterial(Material.STATIONARY_LAVA)) { System.out.println(world.getBlockTypeIdAt(location)); <START> ((GlowPlayer) shooter).teleport(location); <END> this.remove(); } }</code><technical_language>Debug + Player</technical_language>

Target:
protected void pulsePhysics() { Location velLoc = location.clone().add(velocity); velocity.setY(airDrag * (velocity.getY() + getGravityAccel().getY())); velocity.setX(velocity.getX() * 0.95); velocity.setZ(velocity.getZ() * 0.95); setRawLocation(velLoc); if(!location.getBlock().isLiquid() && !location.getBlock().isEmpty()){ ((Entity) shooter).teleport(location); this.remove(); } }
Source:
<code>private static PhongMaterial chooseMaterial() { double random = Math.random(); double alpha = 0.5; <START> double beta = 0.75; <END> if (random < alpha) { return Style.BRICK; } else if (random > alpha && random < beta) { return Style.CRACK; } else { return Style.MOSS; } }</code><technical_language>local fields final. <review</technical_language>

Target:
private static PhongMaterial chooseMaterial() { final double random = Math.random(); final double alpha = 0.5; final double beta = 0.75; if (random < alpha) { return Style.BRICK; } else if (random > alpha && random < beta) { return Style.CRACK; } else { return Style.MOSS; } }
Source:
<code>public static Iterable<Object[]> data() { Method[] methods = Look.class.getDeclaredMethods(); ArrayList<Object[]> parameterList = new ArrayList<>(); for (Method method : methods) { <START> if (method.getParameterCount() == 0 && method.getReturnType() != void.class <END> && !method.getName().equals("getCurrentCollisionPolygon")) { parameterList.add(new Object[]{method.getName(), method}); } } return parameterList; }</code><technical_language>Please exclude methods starting "$"</technical_language>

Target:
public static Iterable<Object[]> data() { Method[] methods = Look.class.getDeclaredMethods(); ArrayList<Object[]> parameterList = new ArrayList<>(); for (Method method : methods) { if (method.getParameterCount() == 0 && method.getReturnType() != void.class && !method.getName().equals("getCurrentCollisionPolygon") && !method.getName().startsWith("$")) { parameterList.add(new Object[]{method.getName(), method}); } } return parameterList; }
Source:
<code>protected boolean isValueNotSet(Descriptors.EnumValueDescriptor value) { <START> return value.getNumber() == 0; <END> }</code><technical_language>final boolean result field immediately return. This easier debug, needed</technical_language>

Target:
protected boolean isValueNotSet(Descriptors.EnumValueDescriptor value) { final int intValue = value.getNumber(); final boolean result = intValue == 0; return result; }
Source:
<code>private static void tryOverride(Config hzConfig, HazelcastProperty property, Consumer<String> setterFn, Supplier<String> getterFn, String configOverridden) { String propertyValue = hzConfig.getProperty(property.getName()); try { if (propertyValue != null) { setterFn.accept(propertyValue); <START> LOGGER.warning(String.format("Overridden metrics configuration with system property '%s'='%s' -> '%s'='%s'", <END> property, propertyValue, configOverridden, getterFn.get())); } } catch (Exception ex) { LOGGER.warning(String.format("Failed to override metrics configuration with system property '%s'='%s'. Kept " + "'%s'='%s'", property.getName(), propertyValue, configOverridden, getterFn.get()), ex); } }</code><technical_language>this log message need warn level? info level</technical_language>

Target:
private static void tryOverride(Config hzConfig, HazelcastProperty property, Consumer<String> setterFn, Supplier<String> getterFn, String configOverridden) { String propertyValue = hzConfig.getProperty(property.getName()); try { if (propertyValue != null) { setterFn.accept(propertyValue); LOGGER.info(String.format("Overridden metrics configuration with system property '%s'='%s' -> '%s'='%s'", property, propertyValue, configOverridden, getterFn.get())); } } catch (Exception ex) { LOGGER.warning(String.format("Failed to override metrics configuration with system property '%s'='%s'. Kept " + "'%s'='%s'", property.getName(), propertyValue, configOverridden, getterFn.get()), ex); } }
Source:
<code>public void runL1UpdateIfPossible(Object value, GetKeyValueCommand command) { try { InternalCacheEntry ice; if ((ice = command.getRemotelyFetchedValue()) != null) { Object key; if (sync.attemptUpdateToRunning() && !dc.containsKey((key = command.getKey()))) { stateTransferLock.acquireSharedTopologyLock(); try { <START> if (!dc.containsKey(key)) { <END> log.tracef("Caching remotely retrieved entry for key %s in L1", key); try { long lifespan = ice.getLifespan() < 0 ? l1Lifespan : Math.min(ice.getLifespan(), l1Lifespan); Metadata newMetadata = ice.getMetadata().builder() .lifespan(lifespan).maxIdle(-1).build(); dc.put(key, ice.getValue(), newMetadata); } catch (Exception e) { log.infof("Unable to store entry %s in L1 cache", command.getKey()); log.debug("Inability to store in L1 caused by", e); } } else { log.tracef("Data container contained value after rehash for key %s", key); } } finally { stateTransferLock.releaseSharedTopologyLock(); } } } } finally { sync.innerSet(value); } }</code><technical_language>check if local node is owner in write CH skip L1 update</technical_language>

Target:
public void runL1UpdateIfPossible(Object value, GetKeyValueCommand command) { try { InternalCacheEntry ice; if ((ice = command.getRemotelyFetchedValue()) != null) { Object key; if (sync.attemptUpdateToRunning() && !dc.containsKey((key = command.getKey()))) { stateTransferLock.acquireSharedTopologyLock(); try { if (!dc.containsKey(key) && !cdl.localNodeIsOwner(key)) { log.tracef("Caching remotely retrieved entry for key %s in L1", key); long lifespan = ice.getLifespan() < 0 ? l1Lifespan : Math.min(ice.getLifespan(), l1Lifespan); Metadata newMetadata = ice.getMetadata().builder() .lifespan(lifespan).maxIdle(-1).build(); dc.put(key, ice.getValue(), newMetadata); } else { log.tracef("Data container contained value after rehash for key %s", key); } } finally { stateTransferLock.releaseSharedTopologyLock(); } } } } finally { sync.innerSet(value); } }
Source:
<code>public void addToArchive( Path archiveDestination, DiagnosticsReporterProgressCallback monitor ) throws IOException { String message = messageSupplier.get(); <START> Files.write( archiveDestination, message.getBytes( Charset.forName( "UTF8" ) ), StandardOpenOption.CREATE, <END> StandardOpenOption.APPEND ); }</code><technical_language>StandardCharsets.UTF_8</technical_language>

Target:
public void addToArchive( Path archiveDestination, DiagnosticsReporterProgressCallback monitor ) throws IOException { String message = messageSupplier.get(); Files.write( archiveDestination, message.getBytes( StandardCharsets.UTF_8 ), StandardOpenOption.CREATE, StandardOpenOption.APPEND ); }
Source:
<code>public void testContextListenerIsSet() throws Exception { try (WizardCommandController tester = testHarness.createWizardController(MyFirstWizard.class)) { tester.initialize(); Assert.assertTrue("Wizard is not on a valid state", tester.isValid()); Assert.assertTrue("Listener is not set", listener.isContextInitialized()); tester.execute(); <START> Assert.assertFalse("Listener is still set", listener.isContextInitialized()); <END> } }</code><technical_language>This moved try block</technical_language>

Target:
public void testContextListenerIsSet() throws Exception { try (WizardCommandController tester = testHarness.createWizardController(MyFirstWizard.class)) { tester.initialize(); Assert.assertTrue("Wizard is not on a valid state", tester.isValid()); Assert.assertTrue("Listener is not set", listener.isContextInitialized()); tester.execute(); } Assert.assertFalse("Listener is still set", listener.isContextInitialized()); }
Source:
<code>public static Optional<ClassLoader> loadDependenciesClassloaderFromProject(String prjPath, String localRepo) { List<String> poms = new ArrayList<>(); MavenUtils.searchPoms(Paths.get(URI.create(FILE_URI + prjPath)), <START> poms); <END> List<URL> urls = getDependenciesURL(poms, localRepo); return buildResult(urls); }</code><technical_language>Personal preference here, I return poms list searchPoms append argument. I expect passed values change (in Java)</technical_language>

Target:
public static Optional<ClassLoader> loadDependenciesClassloaderFromProject(String prjPath, String localRepo) { List<String> poms = MavenUtils.searchPoms(Paths.get(URI.create(FILE_URI + prjPath))); List<URL> urls = getDependenciesURL(poms, localRepo); return buildResult(urls); }
Source:
<code>public BloomFilter union(BloomFilter bloomFilter) { if (bloomFilter instanceof BlockSplitBloomFilter) { BlockSplitBloomFilter that = (BlockSplitBloomFilter) bloomFilter; if (!checkCompatibility(that)) { <START> throw new RuntimeException("Bloom filters are not compatible! Please check" + "if they have the same maximum Bytes, hash strategy and algorithm."); <END> } for (int i = 0; i < this.bitset.length; i++) { this.bitset[i] |= that.bitset[i]; } return new BlockSplitBloomFilter(this.bitset); } else { throw new RuntimeException("Bloom filter should be BlockSplitFilter"); } }</code><technical_language>I suggest IllegalArgumentException instead. I think, message more useful if add actual values of max bytes, hash strategy etc. instead of suggesting check them. debugging log files this message help. Maybe, checkCompatibility throw specific exception is incorrect correct one</technical_language>

Target:
public BloomFilter union(BloomFilter bloomFilter) { if (bloomFilter instanceof BlockSplitBloomFilter) { BlockSplitBloomFilter that = (BlockSplitBloomFilter) bloomFilter; if (!checkCompatibility(that)) { throw new IllegalArgumentException("Bloom filter is not compatible! " + "Bitset size = " + that.getBitsetSize() + ", hash strategy = " + that.hashStrategy + ", algorithm = " + that.getAlgorithm()); } for (int i = 0; i < this.bitset.length; i++) { this.bitset[i] |= that.bitset[i]; } return new BlockSplitBloomFilter(this.bitset); } else { throw new IllegalArgumentException("Unsupported BloomFilter implementation to union with: " + bloomFilter.getClass()); } }
Source:
<code>public DocumentModel getThreadForComment(DocumentModel comment) { CoreSession session = comment.getCoreSession(); DocumentModel parent = session.getDocument(new IdRef((String) comment.getPropertyValue(COMMENT_PARENT_ID))); <START> if (!COMMENT_DOC_TYPE.equals(parent.getType())) { <END> return comment; } return getThreadForComment(parent); }</code><technical_language>reverse condition ? for clarity</technical_language>

Target:
public DocumentModel getThreadForComment(DocumentModel comment) { CoreSession session = comment.getCoreSession(); DocumentModel parent = session.getDocument(new IdRef((String) comment.getPropertyValue(COMMENT_PARENT_ID))); if (COMMENT_DOC_TYPE.equals(parent.getType())) { return getThreadForComment(parent); } return comment; }
Source:
<code><START> Move[] getMoves() { return null; } <END></code><technical_language>public</technical_language>

Target:
public Move[] getMoves() { return null; }
Source:
<code>public void addCertificate() { AddCertificates addCert = new AddCertificates(); Certificate certificate = new Certificate(); <START> if (certFile != null) { <END> certificate.setData(certFile.getContents()); } certificate.setStatus(EntityStatus.NEW); addCert.getCerts().add(certificate); directService.addCertificate(addCert); refreshCertificates(); }</code><technical_language>insert a cert data? add a cert error back. cert a required field</technical_language>

Target:
public void addCertificate() { if (certFile != null) { AddCertificates addCert = new AddCertificates(); Certificate certificate = new Certificate(); certificate.setData(certFile.getContents()); certificate.setStatus(EntityStatus.NEW); addCert.getCerts().add(certificate); directService.addCertificate(addCert); refreshCertificates(); } else { FacesContext.getCurrentInstance().addMessage("certificateAddError", new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR", "Choose and upload a certificate before submitting.")); } }
Source:
<code>private void visitAudioOpenAnswer(OpenAnswerDefinitionAudio audio, Builder builder) { <START> builder.mimeType("audio/webm"); <END> }</code><technical_language>CLSA: variable changed, data format changed = compatible</technical_language>

Target:
private void visitAudioOpenAnswer(OpenAnswerDefinitionAudio audio, Builder builder) { builder.mimeType("audio/x-wav"); }
Source:
<code><START> public Double percentile(String eventCollection, String targetProperty, Double percentile, Timeframe timeframe) throws IOException { <END> Query queryParams = new Query.QueryBuilder(QueryType.PERCENTILE_RESOURCE) .withEventCollection(eventCollection) .withTargetProperty(targetProperty) .withPercentile(percentile) .build(); QueryResult result = execute(queryParams, timeframe); return queryResultToDouble(result); }</code><technical_language>I changed simple query methods long double instead of Long Double</technical_language>

Target:
public double percentile(String eventCollection, String targetProperty, Double percentile, Timeframe timeframe) throws IOException { Query queryParams = new Query.Builder(QueryType.PERCENTILE) .withEventCollection(eventCollection) .withTargetProperty(targetProperty) .withPercentile(percentile) .withTimeframe(timeframe) .build(); QueryResult result = execute(queryParams); return queryResultToDouble(result); }
Source:
<code>private InputStream createInputStream() throws AudioException { String outputFile = generateOutputFilename(); String command = getCommand(outputFile); try { Process process = Runtime.getRuntime().exec(command); process.waitFor(); file = new File(outputFile); <START> if (file != null) { <END> this.length = file.length(); } return getFileInputStream(file); } catch (IOException e) { throw new AudioException("Error while executing '" + command + "'", e); } catch (InterruptedException e) { throw new AudioException("The '" + command + "' has been interrupted", e); } }</code><technical_language>new File(...) return null a reference (if exception is thrown construction). If file exist 0L is returned, I do need check all</technical_language>

Target:
private InputStream createInputStream() throws AudioException { String outputFile = generateOutputFilename(); String command = getCommand(outputFile); try { Process process = Runtime.getRuntime().exec(command); process.waitFor(); file = new File(outputFile); this.length = file.length(); return getFileInputStream(file); } catch (IOException e) { throw new AudioException("Error while executing '" + command + "'", e); } catch (InterruptedException e) { throw new AudioException("The '" + command + "' has been interrupted", e); } }
Source:
<code>protected Optional<Boolean> getVal(Entity entity) { <START> return Optional.of(!entity.getNBTTagCompound().getBoolean("NoGravity")); <END> }</code><technical_language>Actually, I do readEntityFromNbt similar in this method</technical_language>

Target:
protected Optional<Boolean> getVal(Entity entity) { return OptBool.of(!entity.hasNoGravity()); }
Source:
<code>public List<ActionEventRequest> buildActions() { List<ActionEventRequest> actions = new ArrayList<>(); for (Config config : configService.getConfigs().getConfigs()) { String configName = config.getName(); actions.add(buildCreateEncounterAction(configName)); actions.add(buildCreatePatientAction(configName)); actions.add(buildUpdatePatientAction(configName)); <START> if(config.getOpenMrsVersion().equals(OPENMRS_V1_12)) { <END> actions.add(buildCreateProgramEnrollmentAction(configName)); actions.add(buildChangeStateOfProgramEnrollmentAction(configName)); } actions.add(buildUpdatePatientIdentifiersAction(configName)); } return actions; }</code><technical_language>if compare strings, start raw one, prevents NPE. StringUtils. that, consider handle this, I suppose in future another openMRS version 1.11, 2.0 on. solution is compare 1.9 if equals 1.9 do add this actions. more readable if move this condition private method. Lastly, please move this lines end of adding actions code</technical_language>

Target:
public List<ActionEventRequest> buildActions() { List<ActionEventRequest> actions = new ArrayList<>(); for (Config config : configService.getConfigs().getConfigs()) { String configName = config.getName(); actions.add(buildCreateEncounterAction(configName)); actions.add(buildCreatePatientAction(configName)); actions.add(buildUpdatePatientAction(configName)); actions.add(buildUpdatePatientIdentifiersAction(configName)); buildActionsForVersionGreaterThan19(config, configName, actions); } return actions; }