auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void idle() { if (lastSendInterval++ >= sendIntervals) { lastSendInterval = 0; Iterator<DispatchAttempt> iterator = sendQueue.iterator(); while (iterator.hasNext()) { DispatchAttempt attempt = iterator.next(); try { EventMessageContent message = new EventMessageContent(); message.prepareMessage(hostName, attempt.event, isBodyHtml); log.info("Send email to [{}]\n subject:\n [{}]", attempt.address, message.getMessageSubject()); if (log.isDebugEnabled()) { <START> log.debug("body:\n [{}]", <END> message.getMessageBody()); } sendMail(attempt.address, message.getMessageSubject(), message.getMessageBody()); notifyObservers(DispatchResult.success(attempt.event, attempt.address, EventNotificationMethod.SMTP)); iterator.remove(); } catch (Exception ex) { attempt.retries++; if (attempt.retries >= retries) { notifyObservers(DispatchResult.failure(attempt.event, attempt.address, EventNotificationMethod.SMTP, ex.getMessage())); iterator.remove(); } } } } }</code><technical_language>I add multiple logs instead of newline within</technical_language>

Target:
public void idle() { if (lastSendInterval++ >= sendIntervals) { lastSendInterval = 0; Iterator<DispatchAttempt> iterator = sendQueue.iterator(); while (iterator.hasNext()) { DispatchAttempt attempt = iterator.next(); try { EventMessageContent message = new EventMessageContent(); message.prepareMessage(hostName, attempt.event, isBodyHtml); log.info("Send mail subject='{}' to='{}'", message.getMessageSubject(), attempt.address); log.debug("Send mail body='{}'", message.getMessageBody()); sendMail(attempt.address, message.getMessageSubject(), message.getMessageBody()); notifyObservers(DispatchResult.success(attempt.event, attempt.address, EventNotificationMethod.SMTP)); iterator.remove(); } catch (Exception ex) { attempt.retries++; if (attempt.retries >= retries) { notifyObservers(DispatchResult.failure(attempt.event, attempt.address, EventNotificationMethod.SMTP, ex.getMessage())); iterator.remove(); } } } } }
Source:
<code>protected ResourceMetadata(Resource resource, ResourceResource self, boolean isDir) { <START> if (!"".equals(resource.path())) { <END> parent = new ResourceReference("/" + resource.parent().path(), new AtomLink(self.href(resource.parent().path(), true), "alternate", self.getFormatGet(false).getMediaType().getName())); } lastModified = new Date(resource.lastmodified()); type = isDir ? null : resource.getType().toString().toLowerCase(); name = resource.name(); }</code><technical_language>@NielsCharlier this is a strange idiom. intent differ !resource.path().isEmpty()? resource.path() return null</technical_language>

Target:
protected ResourceMetadata(Resource resource, ResourceResource self, boolean isDir) { if (!resource.path().isEmpty()) { parent = new ResourceReference("/" + resource.parent().path(), new AtomLink(self.href(resource.parent().path(), true), "alternate", self.getFormatGet(false).getMediaType().getName())); } lastModified = new Date(resource.lastmodified()); type = isDir ? null : resource.getType().toString().toLowerCase(); name = resource.name(); }
Source:
<code>public long getEntityOwnerId() { VMSnapshot vmsnapshot = _entityMgr.findById(VMSnapshot.class, getVMSnapshotId()); if (vmsnapshot == null) { <START> throw new InvalidParameterValueException("Unable to find vmsnapshot by id=" + getVMSnapshotId()); <END> } Account account = _accountService.getAccount(vmsnapshot.getAccountId()); if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) { Project project = _projectService.findByProjectAccountId(vmsnapshot.getAccountId()); if (project.getState() != Project.State.Active) { throw new PermissionDeniedException("Can't add resources to the project id=" + project.getId() + " in state=" + project.getState() + " as it's no longer active"); } } else if (account.getState() == Account.State.disabled) { throw new PermissionDeniedException("The owner of template is disabled: " + account); } return vmsnapshot.getAccountId(); }</code><technical_language>Uuid</technical_language>

Target:
public long getEntityOwnerId() { VMSnapshot vmsnapshot = _entityMgr.findById(VMSnapshot.class, getVMSnapshotId()); if (vmsnapshot == null) { throw new InvalidParameterValueException("Unable to find vmsnapshot by id=" + getVMSnapshotId()); } Account account = _accountService.getAccount(vmsnapshot.getAccountId()); if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) { Project project = _projectService.findByProjectAccountId(vmsnapshot.getAccountId()); if (project == null) { throw new InvalidParameterValueException("Unable to find project by account id=" + account.getUuid()); } if (project.getState() != Project.State.Active) { throw new PermissionDeniedException("Can't add resources to the project id=" + project.getUuid() + " in state=" + project.getState() + " as it's no longer active"); } } else if (account.getState() == Account.State.disabled) { throw new PermissionDeniedException("The owner of template is disabled: " + account); } return vmsnapshot.getAccountId(); }
Source:
<code>protected void populateBlocks() { long blockID = 1000; for (int i = 0; i < FILE_CONTENTS.length; i++) { int blockIndex = 1; AbstractFileSplitter.FileMetadata fileMetadata = new AbstractFileSplitter.FileMetadata(outputPath); fileMetadata.setRelativePath("file" + i); <START> int noOfBlocks = (int)((FILE_CONTENTS[i].length() / BLOCK_SIZE) + (((FILE_CONTENTS[i].length() % BLOCK_SIZE) == 0) ? 0 : 1)); <END> long[] blockIds = new long[noOfBlocks]; for (int offset = 0; offset < FILE_CONTENTS[i].length(); offset += BLOCK_SIZE, blockID++) { String blockContents; if (offset + BLOCK_SIZE < FILE_CONTENTS[i].length()) { blockContents = FILE_CONTENTS[i].substring(offset, offset + BLOCK_SIZE); } else { blockContents = FILE_CONTENTS[i].substring(offset); } AbstractBlockReader.ReaderRecord<Slice> readerRecord = new AbstractBlockReader.ReaderRecord<Slice>(blockID, new Slice(blockContents.getBytes())); blockIds[blockIndex - 1] = blockID; blockIndex++; blockIdToExpectedContent.put(blockID, blockContents); blockDataList.add(readerRecord); } fileMetadata.setBlockIds(blockIds); fileMetadata.setNumberOfBlocks(noOfBlocks); fileMetadatas.add(fileMetadata); } }</code><technical_language>FILE_CONTENTS[i] FILE_CONTENTS[i].length repeatedly, pull out variables</technical_language>

Target:
protected void populateBlocks() { long blockId = 1000; for (int i = 0; i < FILE_CONTENTS.length; i++) { int blockIndex = 0; List<AbstractBlockReader.ReaderRecord<Slice>> blockList = new ArrayList<>(); AbstractFileSplitter.FileMetadata fileMetadata = new AbstractFileSplitter.FileMetadata(outputPath); fileMetadata.setRelativePath(FILE_NAME + i); String fileContents = FILE_CONTENTS[i]; int fileLength = fileContents.length(); int noOfBlocks = ((fileLength / BLOCK_SIZE) + (((fileLength % BLOCK_SIZE) == 0) ? 0 : 1)); long[] blockIds = new long[noOfBlocks]; for (int offset = 0; offset < fileLength; offset += BLOCK_SIZE, blockId++) { String blockContents; if (offset + BLOCK_SIZE < fileLength) { blockContents = fileContents.substring(offset, offset + BLOCK_SIZE); } else { blockContents = fileContents.substring(offset); } AbstractBlockReader.ReaderRecord<Slice> readerRecord = new AbstractBlockReader.ReaderRecord<Slice>(blockId, new Slice(blockContents.getBytes())); blockIds[blockIndex] = blockId; blockIndex++; blockIdToExpectedContent.put(blockId, blockContents); blockList.add(readerRecord); } blockDataList.add(blockList); fileMetadata.setBlockIds(blockIds); fileMetadata.setNumberOfBlocks(noOfBlocks); fileMetadatas.add(fileMetadata); } }
Source:
<code>public List<VendorDetail> getVendors(List<String> vendorNumbers) throws BadRequestException { Criteria criteria = new Criteria(); for (String vendorNumber : vendorNumbers) { Criteria criteriaVendorPk = new Criteria(); criteriaVendorPk.addEqualTo(CUPurapConstants.Einvoice.VENDOR_GENERATED_HEADER_ID, getVendorHeaderId(vendorNumber)); criteriaVendorPk.addEqualTo(CUPurapConstants.Einvoice.VENDOR_DETAIL_ASSIGNED_ID, getVendorDetailId(vendorNumber)); <START> criteria.addOrCriteria(criteriaVendorPk); <END> } Query query = QueryFactory.newQuery(VendorDetail.class, criteria); return (List<VendorDetail>) getPersistenceBrokerTemplate().getCollectionByQuery(query); }</code><technical_language>volume of vendor numbers expecting this method receive? For smaller volumes, current setup fine. For larger volumes, though, more efficient build a query (but in OJB Criteria form instead): (VNDR_DTL_ASND_ID = VAL1 VNDR_HDR_GNRTD_ID IN (VAL1A, VAL1B, ...)) (VNDR_DTL_ASND_ID = VAL2 VNDR_HDR_GNRTD_ID IN (VAL2A, VAL2B, ...)) ...</technical_language>

Target:
public List<VendorDetail> getVendors(List<String> vendorNumbers) throws BadRequestException { HashMap<Integer, List<Integer>> vendorDetailToHeaderMap = buildVendorDetailMap(vendorNumbers); Criteria criteria = buildQueryCriteria(vendorDetailToHeaderMap); Query query = QueryFactory.newQuery(VendorDetail.class, criteria); return (List<VendorDetail>) getPersistenceBrokerTemplate().getCollectionByQuery(query); }
Source:
<code>DebugMenu(final TripleAFrame frame) { super("Debug"); setMnemonic(KeyEvent.VK_D); final Set<Player> players = frame.getLocalPlayers().getLocalPlayers(); final boolean areThereProAIs = players.stream().anyMatch(AbstractProAi.class::isInstance); if (areThereProAIs) { AbstractProAi.initialize(frame); add(SwingAction.of("Show Hard AI Logs", AbstractProAi::showSettingsWindow)) .setMnemonic(KeyEvent.VK_X); } players.stream() <START> .filter(PlayerDebug.class::isInstance) <END> .forEach( player -> { final JMenu playerDebugMenu = new JMenu(player.getName()); add(playerDebugMenu); ((PlayerDebug) player).addDebugMenuItems(frame, playerDebugMenu::add); }); add(SwingAction.of("Show Console", () -> ClientSetting.showConsole.setValueAndFlush(true))) .setMnemonic(KeyEvent.VK_C); }</code><technical_language>I prefer avoid class types infer properties of object. get odd in terms of nesting interfaces. Second, menus suffer a lot of side effect calls methods "addMenu(menu)", this code a lot harder follow. adding a method Player type, List<JMenuItem> getDebugMenutItems(). in this method, iterating player, need filter is debug menus items is non-null, add menu times. This avoid 'void' return method instanceOf check</technical_language>

Target:
DebugMenu(final TripleAFrame frame) { super("Debug"); setMnemonic(KeyEvent.VK_D); menuItemsAndFactories.forEach( (name, factory) -> { final JMenu playerDebugMenu = new JMenu(name); add(playerDebugMenu); factory.apply(frame).forEach(playerDebugMenu::add); }); }
Source:
<code>public void testTargetsCanAddExecutionPlatformConstraints_notEnabled() throws Exception { StarlarkSemantics semantics = StarlarkSemantics.DEFAULT_SEMANTICS.toBuilder() .incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(false) .build(); ev = createEvaluationTestCase(semantics); ev.initialize(); scratch.file("test/BUILD", "toolchain_type(name = 'my_toolchain_type')"); evalAndExport( "def impl():", <START> " return 0", <END> "r1 = rule(impl, ", " toolchains=[' " execution_platform_constraints_allowed=False,", ")"); RuleClass c = ((SkylarkRuleFunction) lookup("r1")).getRuleClass(); assertThat(c.executionPlatformConstraintsAllowed()) .isEqualTo(ExecutionPlatformConstraintsAllowed.PER_RULE); }</code><technical_language>Nit: AFAIK creating a target rules in tests fail a error return int a rule implementation. return instead pass for other new tests</technical_language>

Target:
public void testTargetsCanAddExecutionPlatformConstraints_notEnabled() throws Exception { StarlarkSemantics semantics = StarlarkSemantics.DEFAULT_SEMANTICS.toBuilder() .incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(false) .build(); ev = createEvaluationTestCase(semantics); ev.initialize(); registerDummyUserDefinedFunction(); scratch.file("test/BUILD", "toolchain_type(name = 'my_toolchain_type')"); evalAndExport( "r1 = rule(impl, ", " toolchains=[' " execution_platform_constraints_allowed=False,", ")"); RuleClass c = ((SkylarkRuleFunction) lookup("r1")).getRuleClass(); assertThat(c.executionPlatformConstraintsAllowed()) .isEqualTo(ExecutionPlatformConstraintsAllowed.PER_RULE); }
Source:
<code>public Point2D inverseTransform(VisualizationServer<N, E> vv, Point2D p) { MultiLayerTransformer multiLayerTransformer = vv.getRenderContext().getMultiLayerTransformer(); MutableTransformer viewTransformer = multiLayerTransformer.getTransformer(Layer.VIEW); MutableTransformer layoutTransformer = multiLayerTransformer.getTransformer(Layer.LAYOUT); if (viewTransformer instanceof LensTransformer) { LensTransformer lensTransformer = (LensTransformer) viewTransformer; MutableTransformer delegateTransformer = lensTransformer.getDelegate(); if (viewTransformer instanceof MagnifyShapeTransformer) { MagnifyTransformer ht = new MagnifyTransformer(lensTransformer.getLens(), layoutTransformer); p = delegateTransformer.inverseTransform(p); p = ht.inverseTransform(p); } else if (viewTransformer instanceof HyperbolicShapeTransformer) { HyperbolicTransformer ht = new HyperbolicTransformer(lensTransformer.getLens(), layoutTransformer); p = delegateTransformer.inverseTransform(p); p = ht.inverseTransform(p); <START> } <END> } else if (layoutTransformer instanceof LensTransformer) { p = multiLayerTransformer.inverseTransform(p); } else { p = multiLayerTransformer.inverseTransform(p); } return p; }</code><technical_language>consider throwing in this case (unidentified LensTransformer subtype)</technical_language>

Target:
public Point2D inverseTransform(VisualizationServer<N, E> vv, Point2D p) { MultiLayerTransformer multiLayerTransformer = vv.getRenderContext().getMultiLayerTransformer(); MutableTransformer viewTransformer = multiLayerTransformer.getTransformer(Layer.VIEW); MutableTransformer layoutTransformer = multiLayerTransformer.getTransformer(Layer.LAYOUT); if (viewTransformer instanceof LensTransformer) { LensTransformer lensTransformer = (LensTransformer) viewTransformer; MutableTransformer delegateTransformer = lensTransformer.getDelegate(); if (viewTransformer instanceof MagnifyShapeTransformer) { MagnifyTransformer ht = new MagnifyTransformer(lensTransformer.getLens(), layoutTransformer); p = delegateTransformer.inverseTransform(p); p = ht.inverseTransform(p); } else if (viewTransformer instanceof HyperbolicShapeTransformer) { HyperbolicTransformer ht = new HyperbolicTransformer(lensTransformer.getLens(), layoutTransformer); p = delegateTransformer.inverseTransform(p); p = ht.inverseTransform(p); } } else { p = multiLayerTransformer.inverseTransform(p); } return p; }
Source:
<code>private void logRenamedEntity() { try { <START> if (this instanceof RenamedEntityInfoProvider) { <END> String oldEntityName; String newEntityName; RenamedEntityInfoProvider renameable = (RenamedEntityInfoProvider) this; String entityType = renameable.getEntityType(); oldEntityName = renameable.getEntityOldName(); newEntityName = renameable.getEntityNewName(); if (!oldEntityName.equals(newEntityName)) { AuditLogableBase logable = new AuditLogableBase(); logable.AddCustomValue("EntityType", entityType); logable.AddCustomValue("OldEntityName", oldEntityName); logable.AddCustomValue("NewEntityName", newEntityName); renameable.setEntityId(logable); AuditLogDirector.log(logable, AuditLogType.ENTITY_RENAMED); } } } catch (Exception e) { log.error(e.getMessage()); log.debug("Failed to log entity rename operation.", e); } }</code><technical_language>please merge variable declaration initialization</technical_language>

Target:
private void logRenamedEntity() { try { if (this instanceof RenamedEntityInfoProvider) { RenamedEntityInfoProvider renameable = (RenamedEntityInfoProvider) this; String entityType = renameable.getEntityType(); String oldEntityName = renameable.getEntityOldName(); String newEntityName = renameable.getEntityNewName(); if (!oldEntityName.equals(newEntityName)) { AuditLogableBase logable = new AuditLogableBase(); logable.AddCustomValue("EntityType", entityType); logable.AddCustomValue("OldEntityName", oldEntityName); logable.AddCustomValue("NewEntityName", newEntityName); renameable.setEntityId(logable); AuditLogDirector.log(logable, AuditLogType.ENTITY_RENAMED); } } } catch (Exception e) { log.error(e.getMessage()); log.debug("Failed to log entity rename operation.", e); } }
Source:
<code>private PlanNode rewriteToDefaultAggregation(ApplyNode parent, Context context) { Symbol count = context.getSymbolAllocator().newSymbol(COUNT, BIGINT); Symbol exists = getOnlyElement(parent.getSubqueryAssignments().getSymbols()); return new LateralJoinNode( parent.getId(), parent.getInput(), new ProjectNode( context.getIdAllocator().getNextId(), new AggregationNode( context.getIdAllocator().getNextId(), parent.getSubquery(), ImmutableMap.of(count, new Aggregation( functionManager.lookupFunction(COUNT, ImmutableList.of()), <START> ImmutableList.of(), Optional.empty(), Optional.empty(), false, Optional.empty())), <END> globalAggregation(), ImmutableList.of(), AggregationNode.Step.SINGLE, Optional.empty(), Optional.empty()), Assignments.of(exists, new ComparisonExpression(GREATER_THAN, count.toSymbolReference(), new Cast(new LongLiteral("0"), BIGINT.toString())))), parent.getCorrelation(), INNER, parent.getOriginSubqueryError()); }</code><technical_language>variable line</technical_language>

Target:
private PlanNode rewriteToDefaultAggregation(ApplyNode parent, Context context) { VariableReferenceExpression count = context.getSymbolAllocator().newVariable("count", BIGINT); VariableReferenceExpression exists = getOnlyElement(parent.getSubqueryAssignments().getVariables()); return new LateralJoinNode( parent.getId(), parent.getInput(), new ProjectNode( context.getIdAllocator().getNextId(), new AggregationNode( context.getIdAllocator().getNextId(), parent.getSubquery(), ImmutableMap.of(count, new Aggregation( new CallExpression( "count", functionResolution.countFunction(), BIGINT, ImmutableList.of()), Optional.empty(), Optional.empty(), false, Optional.empty())), globalAggregation(), ImmutableList.of(), AggregationNode.Step.SINGLE, Optional.empty(), Optional.empty()), Assignments.of(exists, new ComparisonExpression(GREATER_THAN, asSymbolReference(count), new Cast(new LongLiteral("0"), BIGINT.toString())))), parent.getCorrelation(), INNER, parent.getOriginSubqueryError()); }
Source:
<code><START> public Button getDuplicateButton() { <END> return duplicateButton; }</code><technical_language>I this private</technical_language>

Target:
protected Button getDuplicateButton() { return duplicateButton; }
Source:
<code><START> public ZKClientConfig getClientConfig() { <END> if (clientConfig == null) { clientConfig = new ZKClientConfig(); } return clientConfig; }</code><technical_language>synchronize here. sounds check in constructor config is null instantiate default object new ZKClientConfig() in constructor, in case remove this if block here, assert clientConfigis null. If do it, clientConfig final</technical_language>

Target:
public ZKClientConfig getClientConfig() { return clientConfig; }
Source:
<code>public static void testGetViewport() { final boolean excludeMine = Settings.isExcludeMyCaches(); final CacheType cacheType = Settings.getCacheType(); try { TestSettings.setExcludeMine(false); Settings.setCacheType(CacheType.ALL); GCLogin.getInstance().login(); final MapTokens tokens = GCLogin.getInstance().getMapTokens(); { final Viewport viewport = new Viewport(new Geopoint("N 52° 25.369 E 9° 35.499"), new Geopoint("N 52° 25.600 E 9° 36.200")); final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens); assertThat(searchResult).isNotNull(); <START> assertThat(searchResult.getGeocodes()).doesNotContain("GC4ER5H"); <END> } { final Viewport viewport = new Viewport(new Geopoint("N 52° 24.000 E 9° 34.500"), new Geopoint("N 52° 26.000 E 9° 38.500")); final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens); assertThat(searchResult).isNotNull(); assertThat(searchResult.isEmpty()).isFalse(); assertThat(searchResult.getGeocodes()).contains("GC4ER5H"); } } finally { TestSettings.setExcludeMine(excludeMine); Settings.setCacheType(cacheType); } }</code><technical_language>I assume isEmpty().isFalse() intentional here, check result contains caches (general function OK) contains mentioned geocode. pass if result is empty (false positive result). I leave in this testcase moving positive case, check for mentioned cache is enough verify result contains caches</technical_language>

Target:
public static void testGetViewport() { final boolean excludeMine = Settings.isExcludeMyCaches(); final CacheType cacheType = Settings.getCacheType(); try { TestSettings.setExcludeMine(false); Settings.setCacheType(CacheType.ALL); GCLogin.getInstance().login(); final MapTokens tokens = GCLogin.getInstance().getMapTokens(); { final Viewport viewport = new Viewport(new Geopoint("N 52° 25.369 E 9° 35.499"), new Geopoint("N 52° 25.600 E 9° 36.200")); final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens); assertThat(searchResult).isNotNull(); assertThat(searchResult.isEmpty()).isFalse(); assertThat(searchResult.getGeocodes()).doesNotContain("GC4ER5H"); } { final Viewport viewport = new Viewport(new Geopoint("N 52° 24.000 E 9° 34.500"), new Geopoint("N 52° 26.000 E 9° 38.500")); final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens); assertThat(searchResult).isNotNull(); assertThat(searchResult.getGeocodes()).contains("GC4ER5H"); } } finally { TestSettings.setExcludeMine(excludeMine); Settings.setCacheType(cacheType); } }
Source:
<code>public void testCall() { SetReviewCommand setReviewcommand = fGerrit.setReview(change_id, commit_id); ReviewInput reviewInput = new ReviewInput(); reviewInput.setMessage("This review is NOW ready to go ..."); Map obj = new HashMap(); obj.put("Code-Review", "2"); reviewInput.setLabels(obj); setReviewcommand.setCommandInput(reviewInput); try { setReviewcommand.call(); } catch (EGerritException e) { fail(e.getMessage()); } SubmitCommand submitCmd = fGerrit.submit(change_id); SubmitInput submitInput = new SubmitInput(); submitInput.setWait_for_merge(true); submitCmd.setCommandInput(submitInput); ChangeInfo submitCmdResult = null; try { submitCmdResult = submitCmd.call(); assertEquals(submitCmdResult.getId(), change_id); } catch (EGerritException e) { fail(e.getMessage()); } RevertCommand revertCmd = fGerrit.revert(change_id); RevertInput revertInput = new RevertInput(); revertInput.setMessage("Change must be reverted !"); revertCmd.setCommandInput(revertInput); ChangeInfo revertCmdResult = null; try { revertCmdResult = revertCmd.call(); assertNotEquals(revertCmdResult.getId(), change_id); } catch (EGerritException e) { fail(e.getMessage()); <START> } <END> }</code><technical_language>try open new review thas reverted</technical_language>

Target:
public void testCall() { SetReviewCommand setReviewcommand = fGerrit.setReview(change_id, commit_id); ReviewInput reviewInput = new ReviewInput(); reviewInput.setMessage("This review is NOW ready to go ..."); Map obj = new HashMap(); obj.put("Code-Review", "2"); reviewInput.setLabels(obj); setReviewcommand.setCommandInput(reviewInput); try { setReviewcommand.call(); } catch (EGerritException e) { fail(e.getMessage()); } SubmitCommand submitCmd = fGerrit.submit(change_id); SubmitInput submitInput = new SubmitInput(); submitInput.setWait_for_merge(true); submitCmd.setCommandInput(submitInput); ChangeInfo submitCmdResult = null; try { submitCmdResult = submitCmd.call(); assertEquals(submitCmdResult.getId(), change_id); } catch (EGerritException e) { fail(e.getMessage()); } RevertCommand revertCmd = fGerrit.revert(change_id); RevertInput revertInput = new RevertInput(); revertInput.setMessage("Change must be reverted !"); revertCmd.setCommandInput(revertInput); ChangeInfo revertCmdResult = null; try { revertCmdResult = revertCmd.call(); assertNotEquals(revertCmdResult.getId(), change_id); assertEquals(revertCmdResult.getStatus(), "NEW"); } catch (EGerritException e) { fail(e.getMessage()); } }
Source:
<code>private void deleteRemovedElements(BreakpointContainer container, BreakpointContainer refContainer, ModelDelta containerDelta) { Object[] refChildren = refContainer.getChildren(); for (Object <START> element2 : <END> container.getChildren()) { Object element = getElement(refChildren, element2); if (element == null) { if (element2 instanceof BreakpointContainer) { BreakpointContainer.removeAll((BreakpointContainer) element2, containerDelta); } else { BreakpointContainer.removeBreakpoint(container, (IBreakpoint) element2, containerDelta); } } else if (element instanceof BreakpointContainer){ ModelDelta childDelta = containerDelta.addNode(element2, IModelDelta.STATE); deleteRemovedElements((BreakpointContainer) element2, (BreakpointContainer) element, childDelta); } } }</code><technical_language>rename child childElement</technical_language>

Target:
private void deleteRemovedElements(BreakpointContainer container, BreakpointContainer refContainer, ModelDelta containerDelta) { Object[] refChildren = refContainer.getChildren(); for (Object childElement : container.getChildren()) { Object element = getElement(refChildren, childElement); if (element == null) { if (childElement instanceof BreakpointContainer) { BreakpointContainer.removeAll((BreakpointContainer) childElement, containerDelta); } else { BreakpointContainer.removeBreakpoint(container, (IBreakpoint) childElement, containerDelta); } } else if (element instanceof BreakpointContainer){ ModelDelta childDelta = containerDelta.addNode(childElement, IModelDelta.STATE); deleteRemovedElements((BreakpointContainer) childElement, (BreakpointContainer) element, childDelta); } } }
Source:
<code>public Set<TypeClass> getSupers() { <START> return supers; <END> }</code><technical_language>Is caller of this method allowed modify set afterwards</technical_language>

Target:
protected Set<TypeClass> getSupers() { return this.supers; }
Source:
<code><START> public void createRoles(DynamicSchema dynamicSchema) { <END> List<String> roles = (List<String>) CollectionUtils.toList(CollectionUtils.getNestedValue(dynamicSchema.getData(), "fields", "roles")); for (String role: roles) { create().insertInto(DYNAMIC_SCHEMA_ROLE, DYNAMIC_SCHEMA_ROLE.DYNAMIC_SCHEMA_ID, DYNAMIC_SCHEMA_ROLE.ROLE) .values(dynamicSchema.getId(), role).execute(); } }</code><technical_language>For this delete, executing more a single query. need wrap in a transaction</technical_language>

Target:
public void createRoles(DynamicSchema dynamicSchema) { List<String> roles = (List<String>) CollectionUtils.toList(CollectionUtils.getNestedValue(dynamicSchema.getData(), "fields", "roles")); InsertValuesStep2<DynamicSchemaRoleRecord, Long, String> insertStart = create() .insertInto(DYNAMIC_SCHEMA_ROLE, DYNAMIC_SCHEMA_ROLE.DYNAMIC_SCHEMA_ID, DYNAMIC_SCHEMA_ROLE.ROLE); for (String role: roles) { insertStart = insertStart.values(dynamicSchema.getId(), role); } insertStart.execute(); }
Source:
<code>public InstrumentedExecutorService(ExecutorService delegate) { <START> this(delegate, "instrumented_delegate_" + NAME_COUNTER.incrementAndGet()); <END> }</code><technical_language>unknown_... better. point in making longer be</technical_language>

Target:
public InstrumentedExecutorService(ExecutorService delegate) { this(delegate, "unknown_" + NAME_COUNTER.incrementAndGet()); }
Source:
<code>protected void deactivate() { active.set(false); <START> extendedDiscoveryServices.clear(); <END> discoveryServiceCallback = null; }</code><technical_language>Hm, is allowed extended discovery services callback if this component deactivated (e.g. a mandatory reference lost)? unset callback</technical_language>

Target:
protected void deactivate() { extendedDiscoveryServices.clear(); discoveryServiceCallback.inbox = null; discoveryServiceCallback.thingRegistry = null; discoveryServiceCallback = null; }
Source:
<code>public void browse() { running = true; QueueBrowser consumer = null; String threadName = Thread.currentThread().getName(); System.out.println(threadName + " trying to browse " + messageCount + " messages"); try { if (filter != null) { consumer = session.createBrowser((Queue) destination, filter); } else { consumer = session.createBrowser((Queue) destination); } Enumeration<Message> enumBrowse = consumer.getEnumeration(); while (enumBrowse.hasMoreElements()) { Message msg = enumBrowse.nextElement(); if (msg != null) { System.out.println(threadName + " Browsing " + (msg instanceof TextMessage ? ((TextMessage) msg).getText() : msg.getJMSMessageID())); if (verbose) { System.out.println("..." + msg); } if (bytesAsText && (msg instanceof BytesMessage)) { long length = ((BytesMessage) msg).getBodyLength(); byte[] bytes = new byte[(int) length]; ((BytesMessage) msg).readBytes(bytes); System.out.println("Message:" + msg); } received++; if (received >= messageCount) { break; } } else { break; } if (sleep > 0) { Thread.sleep(sleep); } } consumer.close(); } catch (Exception e) { e.printStackTrace(); } finally { if (finished != null) { finished.countDown(); } if (consumer != null) { System.out.println(threadName + " browsed: " + this.getReceived() + " messages"); try { consumer.close(); } catch (JMSException e) { e.printStackTrace(); } } } <START> System.out.println(threadName + " thread finished"); <END> }</code><technical_language>Browser thread finished</technical_language>

Target:
public void browse() { running = true; QueueBrowser consumer = null; String threadName = Thread.currentThread().getName(); System.out.println(threadName + " trying to browse " + messageCount + " messages"); try { if (filter != null) { consumer = session.createBrowser((Queue) destination, filter); } else { consumer = session.createBrowser((Queue) destination); } Enumeration<Message> enumBrowse = consumer.getEnumeration(); while (enumBrowse.hasMoreElements()) { Message msg = enumBrowse.nextElement(); if (msg != null) { System.out.println(threadName + " browsing " + (msg instanceof TextMessage ? ((TextMessage) msg).getText() : msg.getJMSMessageID())); if (verbose) { System.out.println("..." + msg); } if (bytesAsText && (msg instanceof BytesMessage)) { long length = ((BytesMessage) msg).getBodyLength(); byte[] bytes = new byte[(int) length]; ((BytesMessage) msg).readBytes(bytes); System.out.println("Message:" + msg); } received++; if (received >= messageCount) { break; } } else { break; } if (sleep > 0) { Thread.sleep(sleep); } } consumer.close(); } catch (Exception e) { e.printStackTrace(); } finally { if (finished != null) { finished.countDown(); } if (consumer != null) { System.out.println(threadName + " browsed: " + this.getReceived() + " messages"); try { consumer.close(); } catch (JMSException e) { e.printStackTrace(); } } } System.out.println(threadName + " Browser thread finished"); }
Source:
<code>public Channel handleUnknownChannelCommand( ConnectionService service, byte cmd, int channelId, Buffer buffer) throws IOException { Session session = service.getSession(); if (log.isDebugEnabled()) { log.debug("handleUnknownChannelCommand({}) received command for unknown channel: {}", session, SshConstants.getCommandMessageName(cmd), channelId); } boolean wantReply = false; switch (cmd) { case SshConstants.SSH_MSG_CHANNEL_REQUEST: { String req = buffer.getString(); wantReply = buffer.getBoolean(); if (log.isDebugEnabled()) { log.debug("handleUnknownChannelCommand({}) Received SSH_MSG_CHANNEL_REQUEST={} (wantReply={}) for unknown channel: {}", session, req, wantReply, channelId); } break; } case SshConstants.SSH_MSG_CHANNEL_DATA: case SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA: wantReply = false; <START> break; <END> default: } if (wantReply) { sendFailureResponse(service, cmd, channelId); } return null; }</code><technical_language>This is part of SSHD-800 part of this patch</technical_language>

Target:
public Channel handleUnknownChannelCommand( ConnectionService service, byte cmd, int channelId, Buffer buffer) throws IOException { Session session = service.getSession(); if (log.isDebugEnabled()) { log.debug("handleUnknownChannelCommand({}) received command for unknown channel: {}", session, SshConstants.getCommandMessageName(cmd), channelId); } boolean wantReply = false; switch (cmd) { case SshConstants.SSH_MSG_CHANNEL_REQUEST: { String req = buffer.getString(); wantReply = buffer.getBoolean(); if (log.isDebugEnabled()) { log.debug("handleUnknownChannelCommand({}) Received SSH_MSG_CHANNEL_REQUEST={} (wantReply={}) for unknown channel: {}", session, req, wantReply, channelId); } break; } case SshConstants.SSH_MSG_CHANNEL_DATA: case SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA: wantReply = true; break; default: } if (wantReply) { sendFailureResponse(service, cmd, channelId); } return null; }
Source:
<code>private GroupDefinition initGroupDef(IPersonAttributesGroupDefinition group) { GroupDefinition groupDef = new GroupDefinition(); groupDef.setKey(group.getName()); groupDef.setName(group.getName()); groupDef.setDescription(group.getDescription()); addMemberKeys(groupDef, group.getMembers()); Set<IPersonAttributesGroupTestGroupDefinition> testGroups = group.getTestGroups(); for(IPersonAttributesGroupTestGroupDefinition testGroup : testGroups) { TestGroup tg = new TestGroup(); Set<IPersonAttributesGroupTestDefinition> tests = testGroup.getTests(); for(IPersonAttributesGroupTestDefinition test : tests) { IPersonTester testerInst = initializeTester(test); <START> tg.addTest(testerInst); <END> } groupDef.addTestGroup(tg); } return groupDef; }</code><technical_language>portal operate all. Eeep. Please no. Shrill logging horribly wrong, sure, means. Causing portal fail, aggressively unfriendly. Seldom is a production outage preferable uptime of a gracefully degraded service</technical_language>

Target:
private GroupDefinition initGroupDef(IPersonAttributesGroupDefinition group) { GroupDefinition groupDef = new GroupDefinition(); groupDef.setKey(group.getName()); groupDef.setName(group.getName()); groupDef.setDescription(group.getDescription()); addMemberKeys(groupDef, group.getMembers()); Set<IPersonAttributesGroupTestGroupDefinition> testGroups = group.getTestGroups(); for(IPersonAttributesGroupTestGroupDefinition testGroup : testGroups) { TestGroup tg = new TestGroup(); Set<IPersonAttributesGroupTestDefinition> tests = testGroup.getTests(); for(IPersonAttributesGroupTestDefinition test : tests) { IPersonTester testerInst = initializeTester(test); if (testerInst == null) { return null; } tg.addTest(testerInst); } groupDef.addTestGroup(tg); } return groupDef; }
Source:
<code>public FieldSetFilteringRecordSet(FunctionManager functionManager, RecordSet delegate, List<Set<Integer>> fieldSets) { requireNonNull(functionManager, "functionManager is null"); this.delegate = requireNonNull(delegate, "delegate is null"); ImmutableList.Builder<Set<Field>> fieldSetsBuilder = ImmutableList.builder(); List<Type> columnTypes = delegate.getColumnTypes(); for (Set<Integer> fieldSet : requireNonNull(fieldSets, "fieldSets is null")) { ImmutableSet.Builder<Field> fieldSetBuilder = ImmutableSet.builder(); for (int field : fieldSet) { fieldSetBuilder.add(new Field( field, functionManager.getScalarFunctionImplementation( <START> functionManager.resolveOperator(OperatorType.EQUAL, TypeSignatureProvider.fromTypes(ImmutableList.of(columnTypes.get(field), columnTypes.get(field))))).getMethodHandle())); <END> } fieldSetsBuilder.add(fieldSetBuilder.build()); } this.fieldSets = fieldSetsBuilder.build(); }</code><technical_language>Static import fromTypes</technical_language>

Target:
public FieldSetFilteringRecordSet(FunctionManager functionManager, RecordSet delegate, List<Set<Integer>> fieldSets) { requireNonNull(functionManager, "functionManager is null"); this.delegate = requireNonNull(delegate, "delegate is null"); ImmutableList.Builder<Set<Field>> fieldSetsBuilder = ImmutableList.builder(); List<Type> columnTypes = delegate.getColumnTypes(); for (Set<Integer> fieldSet : requireNonNull(fieldSets, "fieldSets is null")) { ImmutableSet.Builder<Field> fieldSetBuilder = ImmutableSet.builder(); for (int field : fieldSet) { fieldSetBuilder.add(new Field( field, functionManager.getScalarFunctionImplementation( functionManager.resolveOperator(OperatorType.EQUAL, fromTypes(ImmutableList.of(columnTypes.get(field), columnTypes.get(field))))).getMethodHandle())); } fieldSetsBuilder.add(fieldSetBuilder.build()); } this.fieldSets = fieldSetsBuilder.build(); }
Source:
<code><START> public static <T> CompletableFuture<T> getIfDoneOrCancel(Future<T> future, Duration after) throws NullArgumentException { <END> if (future == null) { throw new NullArgumentException("future"); } CompletableFuture<T> result = new CompletableFuture<>(); SCHEDULED_EXECUTOR_SERVICE.schedule(() -> { if (future.isDone()) { try { T t = future.get(); result.complete(t); } catch (InterruptedException e) { result.completeExceptionally(e); } catch (ExecutionException e) { result.completeExceptionally(e.getCause()); } catch (CancellationException e) { result.cancel(false); } } else { future.cancel(true); result.cancel(false); } }, after.toMillis(), TimeUnit.MILLISECONDS); return result; }</code><technical_language>declare throws for runtime exceptions</technical_language>

Target:
public static <T> CompletableFuture<T> getIfDoneOrCancel(Future<T> future, Duration after) { Validate.notNull(future); Validate.notNull(after); CompletableFuture<T> result = new CompletableFuture<>(); SCHEDULED_EXECUTOR_SERVICE.schedule(() -> { if (future.isDone()) { try { T t = future.get(); result.complete(t); } catch (InterruptedException e) { result.completeExceptionally(e); } catch (ExecutionException e) { result.completeExceptionally(e.getCause()); } catch (CancellationException e) { result.cancel(false); } } else { future.cancel(true); result.cancel(false); } }, after.toMillis(), TimeUnit.MILLISECONDS); return result; }
Source:
<code>static <T extends BusinessEntity<Guid>> void check(final AutoRecoverDAO<T> dao, final VdcActionType actionType, final DoWithClosure<T, VdcActionParametersBase> paramsCallback, final String logMsg) { log.info("Checking autorecoverable " + logMsg); final List<T> fails = dao.listFailedAutorecoverables(); final BackendInternal backend = Backend.getInstance(); for (final T fail : fails) { final VdcActionParametersBase actionParams = paramsCallback.doWith(fail); <START> actionParams.setParentCommand(VdcActionType.Unknown); <END> actionParams.setShouldBeLogged(true); backend.runInternalAction(actionType, actionParams); } log.info("Checking autorecoverable " + logMsg + " done"); }</code><technical_language>set this default in VdcActionParametersBase</technical_language>

Target:
static <T extends BusinessEntity<Guid>> void check(final AutoRecoverDAO<T> dao, final VdcActionType actionType, final DoWithClosure<T, VdcActionParametersBase> paramsCallback, final String logMsg) { log.info("Checking autorecoverable " + logMsg); final List<T> fails = dao.listFailedAutorecoverables(); final BackendInternal backend = Backend.getInstance(); for (final T fail : fails) { final VdcActionParametersBase actionParams = paramsCallback.doWith(fail); actionParams.setShouldBeLogged(true); backend.runInternalAction(actionType, actionParams); } log.info("Checking autorecoverable " + logMsg + " done"); }
Source:
<code>public void sendingButNotReceivingClientShouldBeKilledWhenWriteThrottleMaxDurationIsReached() throws Exception { int numberOfRunDiscardPairs = 10_000; String largeString = StringUtils.repeat( " ", 8 * 1024 ); connection.connect( address ) .send( TransportTestUtil.acceptedVersions( 1, 0, 0, 0 ) ) .send( TransportTestUtil.chunk( init( "TestClient/1.1", emptyMap() ) ) ); assertThat( connection, eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); assertThat( connection, eventuallyReceives( msgSuccess() ) ); Future sender = otherThread.execute( state -> { for ( int i = 0; i < numberOfRunDiscardPairs; i++ ) { connection.send( TransportTestUtil.chunk( run( "RETURN $data as data", ValueUtils.asMapValue( singletonMap( "data", largeString ) ) ), pullAll() ) ); } return null; } ); try { <START> otherThread.get().awaitFuture( sender ); <END> } catch ( ExecutionException e ) { assertThat( e.getCause(), Matchers.instanceOf( SocketException.class ) ); } logProvider.assertAtLeastOnce( AssertableLogProvider.inLog( Matchers.containsString( WorkerFactory.class.getPackage().getName() ) ).error( containsString( "crashed" ), matchesExceptionMessage( containsString( "will be closed because the client did not consume outgoing buffers for " ) ) ) ); }</code><technical_language>Assert#fail() call this line</technical_language>

Target:
public void sendingButNotReceivingClientShouldBeKilledWhenWriteThrottleMaxDurationIsReached() throws Exception { int numberOfRunDiscardPairs = 10_000; String largeString = StringUtils.repeat( " ", 8 * 1024 ); client.connect( address ) .send( TransportTestUtil.acceptedVersions( 1, 0, 0, 0 ) ) .send( TransportTestUtil.chunk( init( "TestClient/1.1", emptyMap() ) ) ); assertThat( client, eventuallyReceives( new byte[]{0, 0, 0, 1} ) ); assertThat( client, eventuallyReceives( msgSuccess() ) ); Future sender = otherThread.execute( state -> { for ( int i = 0; i < numberOfRunDiscardPairs; i++ ) { client.send( TransportTestUtil.chunk( run( "RETURN $data as data", ValueUtils.asMapValue( singletonMap( "data", largeString ) ) ), pullAll() ) ); } return null; } ); try { otherThread.get().awaitFuture( sender ); fail( "should throw ExecutionException instead" ); } catch ( ExecutionException e ) { assertThat( e.getCause(), Matchers.instanceOf( SocketException.class ) ); } logProvider.assertAtLeastOnce( AssertableLogProvider.inLog( Matchers.containsString( WorkerFactory.class.getPackage().getName() ) ).error( containsString( "crashed" ), matchesExceptionMessage( containsString( "will be closed because the client did not consume outgoing buffers for " ) ) ) ); }
Source:
<code>public <T> T evaluate(Object obj, Class<T> target) { PropertyAccessor accessor = getLastPropertyAccessor(); Object value = false; boolean success = false; Exception lastException = null; if (accessor != null && accessor.canHandle(obj, attPath, target)) { try { value = accessor.get(obj, attPath, target); success = true; } catch (Exception e) { } } if (!success) { if (namespaceSupport != null && hints == null) { hints = new Hints(PropertyAccessorFactory.NAMESPACE_CONTEXT, namespaceSupport); } List<PropertyAccessor> accessors = PropertyAccessors.findPropertyAccessors(obj, attPath, target, hints); if (accessors != null) { Iterator<PropertyAccessor> it = accessors.iterator(); while (!success && it.hasNext()) { accessor = it.next(); try { value = accessor.get(obj, attPath, target); success = true; } catch (Exception e) { lastException = e; } } } if (!success) { if (lenient) return null; else throw new IllegalArgumentException( "Could not find working property accessor for attribute (" + attPath + ") in object (" + obj + ")", <START> lastException); <END> } else { setLastPropertyAccessor(accessor); } } if (target == null) { return (T) value; } return Converters.convert(value, target); }</code><technical_language>instead of tracking exception, worthwhile track add .addSuppressed()? provide more info, some of exceptions expected and/or helpful</technical_language>

Target:
public <T> T evaluate(Object obj, Class<T> target) { PropertyAccessor accessor = getLastPropertyAccessor(); Object value = false; boolean success = false; if (accessor != null && accessor.canHandle(obj, attPath, target)) { try { value = accessor.get(obj, attPath, target); success = true; } catch (Exception e) { } } if (!success) { if (namespaceSupport != null && hints == null) { hints = new Hints(PropertyAccessorFactory.NAMESPACE_CONTEXT, namespaceSupport); } List<PropertyAccessor> accessors = PropertyAccessors.findPropertyAccessors(obj, attPath, target, hints); List<Exception> exceptions = null; if (accessors != null) { Iterator<PropertyAccessor> it = accessors.iterator(); while (!success && it.hasNext()) { accessor = it.next(); try { value = accessor.get(obj, attPath, target); success = true; } catch (Exception e) { if (exceptions == null) { exceptions = new ArrayList<>(); } exceptions.add(e); } } } if (!success) { if (lenient) return null; else { IllegalArgumentException exception = new IllegalArgumentException( "Could not find working property accessor for attribute (" + attPath + ") in object (" + obj + ")"); if (exceptions != null) { exceptions.forEach(e -> exception.addSuppressed(exception)); } throw exception; } } else { setLastPropertyAccessor(accessor); } } if (target == null) { return (T) value; } return Converters.convert(value, target); }
Source:
<code>public void testDebugDraw() { drawable.debugDraw(graphicsContext, collisionArea); Mockito.verify(graphicsContext).fillText("angle: 42.0", 69D, 1003D); Mockito.verify(graphicsContext).fillText("size: 33.0", 69D, 988D); Mockito.verify(graphicsContext).fillOval(0, 0, 1, 1); Mockito.verify(graphicsContext).fillOval(100, 100, 1, 1); Mockito.verify(graphicsContext).fillOval(200, 200, 1, 1); Mockito.verify(graphicsContext).fillOval(69D, 1024D, 2, 2); Mockito.verify(graphicsContext).fillOval(1D, 1D, 2, 2); Mockito.verify(graphicsContext).fillOval(2D, 2D, 2, 2); Mockito.verify(graphicsContext).fillOval(3D, 3D, 2, 2); <START> Mockito.verify(graphicsContext).fillOval(4D, 4D, 2, 2); <END> }</code><technical_language>verify <layout</technical_language>

Target:
public void testDebugDraw() { drawable.debugDraw(graphicsContext, collisionArea); verify(graphicsContext).fillText("angle: 42.0", 69D, 1003D); verify(graphicsContext).fillText("size: 33.0", 69D, 988D); verify(graphicsContext).fillOval(0, 0, 1, 1); verify(graphicsContext).fillOval(100, 100, 1, 1); verify(graphicsContext).fillOval(200, 200, 1, 1); verify(graphicsContext).fillOval(69D, 1024D, 2, 2); verify(graphicsContext).fillOval(1D, 1D, 2, 2); verify(graphicsContext).fillOval(2D, 2D, 2, 2); verify(graphicsContext).fillOval(3D, 3D, 2, 2); verify(graphicsContext).fillOval(4D, 4D, 2, 2); }
Source:
<code>public boolean install(Resource r, ResourceLocation location, Reference ref, ResourceTable table, AndroidCommCarePlatform platform, boolean upgrade) throws UnresolvedResourceException, UnfullfilledRequirementsException { super.install(r, location, ref, table, platform, upgrade); try { Reference local = ReferenceManager.instance().DeriveReference(localLocation); ProfileParser parser = new ProfileParser(local.getStream(), platform, table, r.getRecordGuid(), Resource.RESOURCE_STATUS_UNINITIALIZED, false); Profile p = parser.parse(); if (!upgrade) { initProperties(p); checkDuplicate(p); } <START> checkAppTarget(); <END> table.commitCompoundResource(r, upgrade ? Resource.RESOURCE_STATUS_UPGRADE : Resource.RESOURCE_STATUS_INSTALLED, p.getVersion()); return true; } catch (XmlPullParserException | InvalidReferenceException | IOException e) { e.printStackTrace(); } catch (InvalidStructureException e) { throw new UnresolvedResourceException(r, "Invalid content in the Profile Definition: " + e.getMessage(), true); } return false; }</code><technical_language>This call if (!upgrade) clause well. building in mechanism for update ref mobile request version of profile target package ID, this relevant for updates</technical_language>

Target:
public boolean install(Resource r, ResourceLocation location, Reference ref, ResourceTable table, AndroidCommCarePlatform platform, boolean upgrade) throws UnresolvedResourceException, UnfullfilledRequirementsException { super.install(r, location, ref, table, platform, upgrade); try { Reference local = ReferenceManager.instance().DeriveReference(localLocation); ProfileParser parser = new ProfileParser(local.getStream(), platform, table, r.getRecordGuid(), Resource.RESOURCE_STATUS_UNINITIALIZED, false); Profile p = parser.parse(); if (!upgrade) { initProperties(p); checkDuplicate(p); checkAppTarget(); } table.commitCompoundResource(r, upgrade ? Resource.RESOURCE_STATUS_UPGRADE : Resource.RESOURCE_STATUS_INSTALLED, p.getVersion()); return true; } catch (XmlPullParserException | InvalidReferenceException | IOException e) { e.printStackTrace(); } catch (InvalidStructureException e) { throw new UnresolvedResourceException(r, "Invalid content in the Profile Definition: " + e.getMessage(), true); } return false; }