auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected DefaultIndexBuilder fillIndexBuilder(Path path) throws Exception { <START> final KieProject project = getProject(path); <END> if (project == null) { logger.error("Unable to index " + path.toUri().toString() + ": project could not be resolved."); return null; } final Package pkg = getPackage(path); if (pkg == null) { logger.error("Unable to index " + path.toUri().toString() + ": package could not be resolved."); return null; } final DefaultIndexBuilder builder = new DefaultIndexBuilder(Paths.convert(path).getFileName(), project, pkg); String formContent = ioService.readAllString(path); FormDefinition formDefinition = formDefinitionSerializer.deserialize(formContent); if (formDefinition != null) { builder.setPackageName(pkg.getPackageName()); Resource resParts = new Resource(formDefinition.getName(), ResourceType.FORM); FormDefinitionVisitor visitor = new FormDefinitionVisitor(resParts); visitor.visit(formDefinition); addReferencedResourcesToIndexBuilder(builder, visitor); FormModel model = formDefinition.getModel(); if (model != null) { FormModelVisitorProvider provider = visitorProviders.get(model.getClass()); if (provider != null) { FormModelVisitor modelVisitor = provider.getVisitor(); modelVisitor.index(model); addReferencedResourcesToIndexBuilder(builder, modelVisitor); } } } else { logger.error("Unable to read FormDefinition on " + path.toUri().toString() + "."); return null; } return builder; }</code><technical_language>reused getIndexBuilder(Path) superclass. reason duplicate code lines 63-76? If reason is get package, call builder.setPackageName(pkg.getPackageName()) this package name setting is done automatically DefaultIndexBuilder#build()</technical_language>

Target:
protected DefaultIndexBuilder fillIndexBuilder(Path path) throws Exception { final DefaultIndexBuilder builder = getIndexBuilder(path); if (builder == null) { return null; } String formContent = ioService.readAllString(path); FormDefinition formDefinition = formDefinitionSerializer.deserialize(formContent); if (formDefinition != null) { Resource resParts = new Resource(formDefinition.getName(), ResourceType.FORM); FormDefinitionVisitor visitor = new FormDefinitionVisitor(resParts); visitor.visit(formDefinition); addReferencedResourcesToIndexBuilder(builder, visitor); FormModel model = formDefinition.getModel(); if (model != null) { FormModelVisitorProvider provider = visitorProviders.get(model.getClass()); if (provider != null) { FormModelVisitor modelVisitor = provider.getVisitor(); modelVisitor.index(model); addReferencedResourcesToIndexBuilder(builder, modelVisitor); } } } else { logger.error("Unable to read FormDefinition on " + path.toUri().toString() + "."); return null; } return builder; }
Source:
<code>public void registerCriticalComponent(CriticalComponent criticalComponent) { final CriticalComponentImpl component = new CriticalComponentImpl(criticalComponent); boolean existing = false; for (CriticalComponentImpl csi : this.criticalServiceList) { if (criticalComponent.equals(csi.getCriticalComponent())) { <START> existing = true; <END> } } if (!existing) { this.criticalServiceList.add(component); } logger.debug("Added " + criticalComponent.getCriticalComponentName() + ", with timeout = " + criticalComponent.getCriticalComponentTimeout() + ", list contains " + this.criticalServiceList.size() + " critical services"); }</code><technical_language>add break statement</technical_language>

Target:
public void registerCriticalComponent(CriticalComponent criticalComponent) { final CriticalComponentImpl component = new CriticalComponentImpl(criticalComponent); boolean existing = false; for (CriticalComponentImpl csi : this.criticalComponentList) { if (criticalComponent.equals(csi.getCriticalComponent())) { existing = true; break; } } if (!existing) { this.criticalComponentList.add(component); } logger.debug(new StringBuilder("Added ").append(criticalComponent.getCriticalComponentName()) .append(", with timeout = ").append(criticalComponent.getCriticalComponentTimeout()) .append(", list contains ").append(this.criticalComponentList.size()).append(" critical services") .toString()); }
Source:
<code>private synchronized void authorize(Instant expiry) { if(expiringSAMLAuth == null) <START> throw new MarkLogicInternalException("ExpiringSAMLAuth cannot be null"); <END> if(expiry!=null && expiry!=expiringSAMLAuth.getExpiry()) return; expiringSAMLAuth = authorizer.apply(expiringSAMLAuth); if(expiringSAMLAuth==null) throw new IllegalArgumentException("SAML Authentication cannot be null"); if(expiringSAMLAuth.getAuthorizationToken() == null) throw new IllegalArgumentException("SAML Authentication token cannot be null"); authorizationTokenValue = expiringSAMLAuth.getAuthorizationToken(); if(expiringSAMLAuth.getExpiry() == null) throw new IllegalArgumentException("SAML authentication does not have expiry value."); threshold = Instant.now().plusSeconds((expiringSAMLAuth.getExpiry().getEpochSecond())/2); }</code><technical_language>call, expiry param expiringSAMLAuth field null. So, I this test call fail. Instead, if expiry param is null expiringSAMLAuth field is null, some other thread updated expiringSAMLAuth field, authorize() method return</technical_language>

Target:
private synchronized void authorize(Instant expiry) { if(expiry == null && expiringSAMLAuth != null) { return; } if(expiry!=null && expiry!=expiringSAMLAuth.getExpiry()) { return; } expiringSAMLAuth = authorizer.apply(expiringSAMLAuth); if(expiringSAMLAuth==null) { throw new IllegalArgumentException("SAML Authentication cannot be null"); } if(expiringSAMLAuth.getAuthorizationToken() == null) { throw new IllegalArgumentException("SAML Authentication token cannot be null"); } authorizationTokenValue = expiringSAMLAuth.getAuthorizationToken(); if(expiringSAMLAuth.getExpiry() == null) { throw new IllegalArgumentException("SAML authentication does not have expiry value."); } if(expiringSAMLAuth.getExpiry().isBefore(Instant.now())) { throw new IllegalArgumentException("SAML authentication token has expired."); } long current = Instant.now().getEpochSecond(); threshold = current+ (expiringSAMLAuth.getExpiry().getEpochSecond() - current)/2; }
Source:
<code>public Optional<SanitizedSecret> getSanitizedSecretFor(Client client, String name, String version) { checkNotNull(client); checkArgument(!name.isEmpty()); checkNotNull(version); <START> return (Optional<SanitizedSecret>)dslContext.transactionResult(configuration -> { <END> Optional<SecretSeries> secretSeries = getSecretSeriesFor(client, name); if (!secretSeries.isPresent()) { return Optional.empty(); } Optional<SecretContent> secretContent = secretContentDAO.getSecretContentBySecretIdAndVersion( secretSeries.get().getId(), version); if (!secretContent.isPresent()) { return Optional.empty(); } SecretSeriesAndContent seriesAndContent = SecretSeriesAndContent.of( secretSeries.get(), secretContent.get()); return Optional.of(SanitizedSecret.fromSecretSeriesAndContent(seriesAndContent)); }); }</code><technical_language>show type problem tomorrow? curious hitting</technical_language>

Target:
public Optional<SanitizedSecret> getSanitizedSecretFor(Client client, String name, String version) { checkNotNull(client); checkArgument(!name.isEmpty()); checkNotNull(version); return dslContext.<Optional<SanitizedSecret>>transactionResult(configuration -> { Optional<SecretSeries> secretSeries = getSecretSeriesFor(client, name); if (!secretSeries.isPresent()) { return Optional.empty(); } Optional<SecretContent> secretContent = secretContentDAO.getSecretContentBySecretIdAndVersion( secretSeries.get().getId(), version); if (!secretContent.isPresent()) { return Optional.empty(); } SecretSeriesAndContent seriesAndContent = SecretSeriesAndContent.of( secretSeries.get(), secretContent.get()); return Optional.of(SanitizedSecret.fromSecretSeriesAndContent(seriesAndContent)); }); }
Source:
<code>public ValidationResult passthroughProfileIsSupported() { StoragePool dataCenter = dcDao.get(getNetwork().getDataCenterId()); Version <START> dcCompVer = <END> dataCenter.getCompatibilityVersion(); return ValidationResult.failWith(EngineMessage.ACTION_TYPE_FAILED_PASSTHROUGH_PROFILE_NOT_SUPPORTED) .when(vnicProfile.isPassthrough() && !FeatureSupported.sriov(dcCompVer)); }</code><technical_language>please do shorten variable names. please rename 'dcCompatibilityVersion' 'dcVersion'</technical_language>

Target:
public ValidationResult passthroughProfileIsSupported() { StoragePool dataCenter = dcDao.get(getNetwork().getDataCenterId()); Version dcCompatibilityVersion = dataCenter.getCompatibilityVersion(); return ValidationResult.failWith(EngineMessage.ACTION_TYPE_FAILED_PASSTHROUGH_PROFILE_NOT_SUPPORTED) .when(vnicProfile.isPassthrough() && !FeatureSupported.sriov(dcCompatibilityVersion)); }
Source:
<code>private org.apache.hadoop.conf.Configuration getHadoopConfiguration() { org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration(); for (Object entrySetObject : getConfig().entrySet()) { Map.Entry entrySet = (Map.Entry) entrySetObject; configuration.set("" + entrySet.getKey(), "" + entrySet.getValue()); } <START> String hadoopConfDir = getString(HADOOP_CONF_DIR, null); <END> if (hadoopConfDir != null) { LOGGER.info("hadoop conf dir", hadoopConfDir); File dir = new File(hadoopConfDir); if (dir.isDirectory()) { for (String xmlFilename : HADOOP_CONF_FILENAMES) { File file = new File(dir, xmlFilename); if (file.isFile()) { LOGGER.info("adding resource: %s to Hadoop configuration", file); try { ByteArrayInputStream in = new ByteArrayInputStream(FileUtils.readFileToByteArray(file)); configuration.addResource(in); } catch (Exception ex) { LOGGER.warn("error adding resource: " + xmlFilename + " to Hadoop configuration", ex); } } } StringBuilder sb = new StringBuilder(); SortedSet<String> keys = new TreeSet<>(); for (Map.Entry<String, String> entry : configuration) { keys.add(entry.getKey()); } LOGGER.debug("Hadoop configuration:%n%s", sb.toString()); } else { LOGGER.warn("configuration property %s is not a directory", HADOOP_CONF_DIR); } } return configuration; }</code><technical_language>move lines a method called load hadoop configuration something</technical_language>

Target:
private org.apache.hadoop.conf.Configuration getHadoopConfiguration() { org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration(); for (Object entrySetObject : getConfig().entrySet()) { Map.Entry entrySet = (Map.Entry) entrySetObject; configuration.set("" + entrySet.getKey(), "" + entrySet.getValue()); } loadHadoopConfigs(configuration); return configuration; }
Source:
<code>public void testListMembersWithRole() throws IOException { GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); List<GHUser> admins = org.listMembersWithRole("admin").asList(); <START> assertFalse(admins.isEmpty()); <END> }</code><technical_language>specific size is in list. A check for non-empty list is enough ensure this break in future</technical_language>

Target:
public void testListMembersWithRole() throws IOException { GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG); List<GHUser> admins = org.listMembersWithRole("admin").asList(); assertNotNull(admins); assertTrue(admins.size() >= 12); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("alexanderrtaylor"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("asthinasthi"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("bitwiseman"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("farmdawgnation"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("halkeye"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("jberglund-BSFT"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("kohsuke"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("kohsuke2"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("martinvanzijl"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("PauloMigAlmeida"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("Sage-Pierce"))); assertTrue(admins.stream().anyMatch(ghUser -> ghUser.getLogin().equals("timja"))); }
Source:
<code>public boolean isEnabled() { updateCurrentPage(); <START> Class<?> repositoryClass = null; <END> try { repositoryClass = Class.forName("org.eclipse.mylyn.internal.tasks.ui.search.RepositorySearchResultView"); } catch (ClassNotFoundException e) { e.printStackTrace(); } boolean enabled = true; if (page == null) { enabled = false; } else if (page.getClass() == repositoryClass) { enabled = false; } return enabled; }</code><technical_language>instead of checking class, check ID page? for task searh results ID matches classname</technical_language>

Target:
public boolean isEnabled() { ISearchResultPage page = getCurrentPage(); return page != null && !BLACKLISTED_IDS.contains(page.getID()); }
Source:
<code>private List<String> getAllFilePaths() { List<String> paths = new ArrayList<>(); for (RepositoryFileReference ref : RepositoryFactory.getRepository() .getContainedFiles(this.fileDir)) { <START> ref.getSubDirectory().ifPresent(path -> { <END> paths.add(path.toString()); }); if (!ref.getSubDirectory().isPresent()) { paths.add(""); } } return paths; }</code><technical_language>code work? ref.getSubDirectory().map(p -> p.toString()).orElse("")</technical_language>

Target:
private List<String> getAllFilePaths() { List<String> paths = new ArrayList<>(); for (RepositoryFileReference ref : RepositoryFactory.getRepository() .getContainedFiles(this.fileDir)) { if (!ref.getSubDirectory().isPresent()) { paths.add(ref.getSubDirectory().get().toString()); } else { paths.add(""); } } return paths; }
Source:
<code>private Display getDisplay() { Shell shell = <START> getSite().getShell(); <END> return shell != null ? shell.getDisplay() : Display.getDefault(); }</code><technical_language>null view disposal. PlatformUI.getWorkbench().getDisplay() is friend</technical_language>

Target:
private Display getDisplay() { return PlatformUI.getWorkbench().getDisplay(); }
Source:
<code>public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; <START> if (getClass() != obj.getClass()) <END> return false; PowerFailureDecorator other = (PowerFailureDecorator) obj; if (powerfailure == null) { if (other.powerfailure != null) return false; } else if (!powerfailure.equals(other.powerfailure)) return false; return true; }</code><technical_language>getClass() instead of instanceof</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (!(obj instanceof PowerFailureDecorator)) return false; PowerFailureDecorator other = (PowerFailureDecorator) obj; if (!this.hasPowerFailure() && other.hasPowerFailure()) return false; else if (!powerfailure.equals(other.powerfailure)) return false; return true; }
Source:
<code>private boolean isCaseSensitiveUsername(String username, int tenantId){ if (UserStoreMgtDSComponent.getRealmService() != null) { try { if (UserStoreMgtDSComponent.getRealmService().getTenantUserRealm(tenantId) != null) { UserStoreManager userStoreManager = (UserStoreManager) UserStoreMgtDSComponent.getRealmService() .getTenantUserRealm(tenantId).getUserStoreManager(); UserStoreManager userAvailableUserStoreManager = userStoreManager.getSecondaryUserStoreManager (UserCoreUtil.extractDomainFromName(username)); String isUsernameCaseInsensitiveString = userAvailableUserStoreManager.getRealmConfiguration() .getUserStoreProperty(CASE_INSENSITIVE_USERNAME); <START> if (isUsernameCaseInsensitiveString != null) { <END> return !Boolean.parseBoolean(isUsernameCaseInsensitiveString); } } } catch (org.wso2.carbon.user.api.UserStoreException e) { if (log.isDebugEnabled()) { log.debug("Error while reading user store property CaseInsensitiveUsername. Considering as false."); } } } return true; }</code><technical_language>need null check for Boolean.parseBoolean()</technical_language>

Target:
private boolean isCaseSensitiveUsername(String username, int tenantId) { if (UserStoreMgtDSComponent.getRealmService() != null) { try { if (UserStoreMgtDSComponent.getRealmService().getTenantUserRealm(tenantId) != null) { UserStoreManager userStoreManager = (UserStoreManager) UserStoreMgtDSComponent.getRealmService() .getTenantUserRealm(tenantId).getUserStoreManager(); UserStoreManager userAvailableUserStoreManager = userStoreManager.getSecondaryUserStoreManager (UserCoreUtil.extractDomainFromName(username)); String isUsernameCaseInsensitiveString = userAvailableUserStoreManager.getRealmConfiguration() .getUserStoreProperty(CASE_INSENSITIVE_USERNAME); return !Boolean.parseBoolean(isUsernameCaseInsensitiveString); } } catch (org.wso2.carbon.user.api.UserStoreException e) { if (log.isDebugEnabled()) { log.debug("Error while reading user store property CaseInsensitiveUsername. Considering as false."); } } } return true; }
Source:
<code>public CreateRequest process(CreateRequest request) throws PluginExecutionException, StopProcessingException { Subject ownerSubject = getSubject(); final String owner = subjectIdentity.getUniqueIdentifier(ownerSubject); List<ShareableMetacardImpl> shareableMetacards = request .getMetacards() .stream() <START> .filter(ShareableMetacardImpl::isShareableMetacard) <END> .map(ShareableMetacardImpl::from) .filter(shareableMC -> StringUtils.isEmpty(shareableMC.getOwner())) .collect(Collectors.toList()); if (!shareableMetacards.isEmpty() && isGuest(ownerSubject)) { throw new StopProcessingException("Guest user not allowed to create shareable resources"); } shareableMetacards.stream().forEach(shareableMC -> shareableMC.setOwner(owner)); return request; }</code><technical_language>realized email valid unique key for identifying users need a subsequent step. I if punt fulfilling requirement another ticket</technical_language>

Target:
public CreateRequest process(CreateRequest request) throws PluginExecutionException, StopProcessingException { Subject ownerSubject = getSubject(); final String owner = subjectIdentity.getUniqueIdentifier(ownerSubject); List<ShareableMetacardImpl> shareableMetacards = request .getMetacards() .stream() .filter(ShareableMetacardImpl::canShare) .map(ShareableMetacardImpl::createOrThrow) .filter(shareableMetacard -> StringUtils.isEmpty(shareableMetacard.getOwner())) .collect(Collectors.toList()); if (!shareableMetacards.isEmpty() && isGuest(ownerSubject)) { throw new StopProcessingException("Guest user not allowed to create shareable resources"); } shareableMetacards.stream().forEach(shareableMetacard -> shareableMetacard.setOwner(owner)); return request; }
Source:
<code>protected void afterTest() { logger.info("Cleaning up created key values."); client.listSettings(new SettingSelector().setKeys(keyPrefix + "*")) .flatMap(configurationSetting -> { Mono<Response<ConfigurationSetting>> unlock; if (configurationSetting.isLocked()) { <START> unlock = client.clearReadOnlyWithResponse(configurationSetting); <END> } else { unlock = Mono.empty(); } logger.info("Deleting key:label [{}:{}]. isLocked? {}", configurationSetting.getKey(), configurationSetting.getLabel(), configurationSetting.isLocked()); return unlock.then(client.deleteSetting(configurationSetting)); }) .blockLast(); logger.info("Finished cleaning up values."); }</code><technical_language>a ternary operator</technical_language>

Target:
protected void afterTest() { logger.info("Cleaning up created key values."); client.listSettings(new SettingSelector().setKeys(keyPrefix + "*")) .flatMap(configurationSetting -> { logger.info("Deleting key:label [{}:{}]. isLocked? {}", configurationSetting.getKey(), configurationSetting.getLabel(), configurationSetting.isLocked()); Mono<Response<ConfigurationSetting>> unlock = configurationSetting.isLocked() ? client.clearReadOnlyWithResponse(configurationSetting) : Mono.empty(); return unlock.then(client.deleteSettingWithResponse(configurationSetting, false)); }) .blockLast(); logger.info("Finished cleaning up values."); }
Source:
<code>private void sendNotification(List<MentionNotificationParameters> notificationParametersList) { for (MentionNotificationParameters mentionNotificationParameters : notificationParametersList) { for (String type : mentionNotificationParameters.getNewTypes()) { this.mentionNotificationServiceProvider.get(type) <START> .ifPresent(it -> { <END> try { it.sendNotifications(mentionNotificationParameters); } catch (Exception e) { this.logger .warn("Notification of with type failed. Cause: [{}]", mentionNotificationParameters, type, getRootCauseMessage(e)); } }); } } }</code><technical_language>sounds a debug log if service is found</technical_language>

Target:
private void sendNotification(List<MentionNotificationParameters> notificationParametersList) { for (MentionNotificationParameters mentionNotificationParameters : notificationParametersList) { Map<String, Set<MentionNotificationParameter>> newMentions = mentionNotificationParameters.getNewMentions(); if (!newMentions.isEmpty()) { this.observationManager .notify(new NewMentionsEvent(), mentionNotificationParameters.getAuthorReference(), mentionNotificationParameters); } } }
Source:
<code>public void addResponseToOMDB(OMMetadataManager omMetadataManager) throws IOException { String dbUserKey = omMetadataManager.getUserKey(owner); <START> VolumeList volumeList = updatedVolumeList; <END> if (updatedVolumeList.getVolumeNamesList().size() == 0) { omMetadataManager.getUserTable().delete(dbUserKey); } else { omMetadataManager.getUserTable().put(dbUserKey, volumeList); } omMetadataManager.getVolumeTable().delete( omMetadataManager.getVolumeKey(volume)); }</code><technical_language>updatedVolumeList instead of copying a local variable</technical_language>

Target:
public void addResponseToOMDB(OMMetadataManager omMetadataManager) throws IOException { String dbUserKey = omMetadataManager.getUserKey(owner); if (updatedVolumeList.getVolumeNamesList().size() == 0) { omMetadataManager.getUserTable().delete(dbUserKey); } else { omMetadataManager.getUserTable().put(dbUserKey, updatedVolumeList); } omMetadataManager.getVolumeTable().delete( omMetadataManager.getVolumeKey(volume)); }
Source:
<code>private List<Set<FieldId>> enumerateGroupingSets(Analysis.GroupingSetAnalysis groupingSetAnalysis) { List<List<Set<FieldId>>> partialSets = new ArrayList<>(); for (Set<FieldId> cube : groupingSetAnalysis.getCubes()) { partialSets.add(ImmutableList.copyOf(Sets.powerSet(cube))); } for (List<FieldId> rollup : groupingSetAnalysis.getRollups()) { List<Set<FieldId>> sets = IntStream.range(0, rollup.size() + 1) <START> .mapToObj(i -> ImmutableSet.copyOf(rollup.subList(0, i))) <END> .collect(toImmutableList()); partialSets.add(sets); } partialSets.addAll(groupingSetAnalysis.getOrdinarySets()); if (partialSets.isEmpty()) { return ImmutableList.of(ImmutableSet.of()); } List<Set<FieldId>> allSets = new ArrayList<>(); partialSets.get(0) .stream() .map(ImmutableSet::copyOf) .forEach(allSets::add); for (int i = 1; i < partialSets.size(); i++) { List<Set<FieldId>> groupingSets = partialSets.get(i); List<Set<FieldId>> oldGroupingSetsCrossProduct = ImmutableList.copyOf(allSets); allSets.clear(); for (Set<FieldId> existingSet : oldGroupingSetsCrossProduct) { for (Set<FieldId> groupingSet : groupingSets) { Set<FieldId> concatenatedSet = ImmutableSet.<FieldId>builder() .addAll(existingSet) .addAll(groupingSet) .build(); allSets.add(concatenatedSet); } } } return allSets; }</code><technical_language>rangeClosed</technical_language>

Target:
private List<Set<FieldId>> enumerateGroupingSets(Analysis.GroupingSetAnalysis groupingSetAnalysis) { List<List<Set<FieldId>>> partialSets = new ArrayList<>(); for (Set<FieldId> cube : groupingSetAnalysis.getCubes()) { partialSets.add(ImmutableList.copyOf(Sets.powerSet(cube))); } for (List<FieldId> rollup : groupingSetAnalysis.getRollups()) { List<Set<FieldId>> sets = IntStream.rangeClosed(0, rollup.size()) .mapToObj(i -> ImmutableSet.copyOf(rollup.subList(0, i))) .collect(toImmutableList()); partialSets.add(sets); } partialSets.addAll(groupingSetAnalysis.getOrdinarySets()); if (partialSets.isEmpty()) { return ImmutableList.of(ImmutableSet.of()); } List<Set<FieldId>> allSets = new ArrayList<>(); partialSets.get(0) .stream() .map(ImmutableSet::copyOf) .forEach(allSets::add); for (int i = 1; i < partialSets.size(); i++) { List<Set<FieldId>> groupingSets = partialSets.get(i); List<Set<FieldId>> oldGroupingSetsCrossProduct = ImmutableList.copyOf(allSets); allSets.clear(); for (Set<FieldId> existingSet : oldGroupingSetsCrossProduct) { for (Set<FieldId> groupingSet : groupingSets) { Set<FieldId> concatenatedSet = ImmutableSet.<FieldId>builder() .addAll(existingSet) .addAll(groupingSet) .build(); allSets.add(concatenatedSet); } } } return allSets; }
Source:
<code>private void epdqSetupWithStatusCheck(boolean require3ds) { try { new URL(url).openConnection().connect(); Map<String, String> validEpdqCredentials = ImmutableMap.of( "merchant_id", merchantId, "username", username, "password", password, "sha_in_passphrase", shaInPassphrase); GatewayAccountEntity validGatewayAccount = new GatewayAccountEntity(); validGatewayAccount.setId(123L); validGatewayAccount.setGatewayName("epdq"); validGatewayAccount.setCredentials(validEpdqCredentials); validGatewayAccount.setType(TEST); validGatewayAccount.setRequires3ds(require3ds); chargeEntity = aValidChargeEntity() .withGatewayAccountEntity(validGatewayAccount) .withTransactionId(randomUUID().toString()) .build(); mockMetricRegistry = mock(MetricRegistry.class); mockHistogram = mock(Histogram.class); mockCounter = mock(Counter.class); when(mockMetricRegistry.histogram(anyString())).thenReturn(mockHistogram); <START> mockEnvironment = mock(Environment.class); <END> when(mockEnvironment.metrics()).thenReturn(mockMetricRegistry); } catch (IOException ex) { Assume.assumeTrue(false); } }</code><technical_language>is mockEnvironment instantiated @Mock annotation field</technical_language>

Target:
private void epdqSetupWithStatusCheck(boolean require3ds) { try { new URL(url).openConnection().connect(); Map<String, String> validEpdqCredentials = ImmutableMap.of( "merchant_id", merchantId, "username", username, "password", password, "sha_in_passphrase", shaInPassphrase); GatewayAccountEntity validGatewayAccount = new GatewayAccountEntity(); validGatewayAccount.setId(123L); validGatewayAccount.setGatewayName("epdq"); validGatewayAccount.setCredentials(validEpdqCredentials); validGatewayAccount.setType(TEST); validGatewayAccount.setRequires3ds(require3ds); chargeEntity = aValidChargeEntity() .withGatewayAccountEntity(validGatewayAccount) .withTransactionId(randomUUID().toString()) .build(); } catch (IOException ex) { Assume.assumeTrue(false); } }
Source:
<code>public static String processPageSourceForFailureCase(String content) { return processPageSourceForGodMode(content) <START> .replace("&#x2f;js&#x2f;lib&#x2f;jquery.min.js", "{*}&#x2f;jquery.min.js") <END> .replace("https:&#x2f;&#x2f;ajax.googleapis.com&#x2f;ajax&#x2f;libs&#x2f;jquery&#x2f;1.11.3&#x2f;jquery.min.js", "{*}&#x2f;jquery.min.js") .replace("&#x2f;js&#x2f;lib&#x2f;jquery-ui.min.js", "{*}&#x2f;jquery-ui.min.js") .replace("https:&#x2f;&#x2f;ajax.googleapis.com&#x2f;ajax&#x2f;libs&#x2f;jqueryui&#x2f;1.10.4&#x2f;jquery-ui.min.js", "{*}&#x2f;jquery-ui.min.js"); }</code><technical_language>this more readable? a function encode url instead of writing url in encoded form here</technical_language>

Target:
public static String processPageSourceForFailureCase(String content) { Date now = new Date(); return processPageSourceForGodMode(content) .replace(Sanitizer.sanitizeForHtml("/js/lib/jquery-ui.min.js"), Sanitizer.sanitizeForHtml("{*}/jquery-ui.min.js")) .replace(Sanitizer.sanitizeForHtml("<LINK_1>"), Sanitizer.sanitizeForHtml("{*}/jquery.min.js")) .replace(Sanitizer.sanitizeForHtml("/js/lib/jquery-ui.min.js"), Sanitizer.sanitizeForHtml("{*}/jquery-ui.min.js")) .replace(Sanitizer.sanitizeForHtml("<LINK_0>"), Sanitizer.sanitizeForHtml("{*}/jquery-ui.min.js")) .replace(TimeHelper.formatDate(now), "{*}"); }
Source:
<code>public BranchId getBranchId(IAtsVersion version) { return BranchId.valueOf( <START> services.getAttributeResolver().getSoleAttributeValue(version, AtsAttributeTypes.BaselineBranchUuid, "-1")); <END> }</code><technical_language>BranchId.SENTINEL instead of "-1"</technical_language>

Target:
public BranchId getBranchId(IAtsVersion version) { return services.getAttributeResolver().getSoleAttributeValue(version, AtsAttributeTypes.BaselineBranchUuid, BranchId.SENTINEL); }
Source:
<code>void releaseView() { LOG.info("Releasing view of subpartition of {}.", getSubPartitionIndex(), parent.getPartitionId()); <START> readView = null; <END> isPartialBuffer = true; isBlockedByCheckpoint = false; sequenceNumber = 0; }</code><technical_language>writes in this method done a lock, right? execution paths do acquire this lock. add synchronized (buffers) checkState(Thread.holdsLock)</technical_language>

Target:
private void releaseView() { assert Thread.holdsLock(buffers); if (readView != null) { LOG.debug("Releasing view of subpartition of {}.", getSubPartitionIndex(), parent.getPartitionId()); readView.releaseAllResources(); readView = null; isPartialBufferCleanupRequired = true; isBlockedByCheckpoint = false; sequenceNumber = 0; } }
Source:
<code>public void updateLoggingPrefs() { final AdminSettingsManager settingsManager = new AdminSettingsManager(); final String enabled = settingsManager.getPref(SalesforceAnalyticsManager.ANALYTICS_ON_OFF_KEY, account); if (!TextUtils.isEmpty(enabled)) { <START> if (FALSE.equals(enabled.trim().toLowerCase())) { <END> disableOrEnableLogging(false); } else { disableOrEnableLogging(true); } } }</code><technical_language>Boolean.parseBolean(enabled)</technical_language>

Target:
public void updateLoggingPrefs() { final AdminSettingsManager settingsManager = new AdminSettingsManager(); final String enabled = settingsManager.getPref(SalesforceAnalyticsManager.ANALYTICS_ON_OFF_KEY, account); if (!TextUtils.isEmpty(enabled)) { if (!Boolean.parseBoolean(enabled)) { disableOrEnableLogging(false); } else { disableOrEnableLogging(true); } } }
Source:
<code>private boolean validate() { if (builderLedgerType == null) { LOG.error("invalid null builderLedgerType"); return false; } if (bk.getConf().getUseV2WireProtocol() && builderLedgerType != LedgerType.FORCE_ON_JOURNAL) { LOG.error("invalid builderLedgerType while using v2 wire protocol"); return false; } if (builderWriteQuorumSize > builderEnsembleSize) { LOG.error("invalid writeQuorumSize > ensembleSize {}", builderWriteQuorumSize, builderEnsembleSize); return false; } <START> if (builderLedgerType.equals(LedgerType.FORCE_DEFERRED_ON_JOURNAL) && builderWriteQuorumSize != builderEnsembleSize) { <END> LOG.error("invalid writeQuorumSize != ensembleSize for FORCE_DEFERRED_ON_JOURNAL ledger. Striping is not allowed", builderWriteQuorumSize, builderEnsembleSize); return false; } if (builderAckQuorumSize > builderWriteQuorumSize) { LOG.error("invalid ackQuorumSize > writeQuorumSize {}", builderAckQuorumSize, builderWriteQuorumSize); return false; } if (builderAckQuorumSize <= 0) { LOG.error("invalid ackQuorumSize <= 0", builderAckQuorumSize); return false; } if (builderPassword == null) { LOG.error("invalid null password"); return false; } if (builderDigestType == null) { LOG.error("invalid null digestType"); return false; } if (builderCustomMetadata == null) { LOG.error("invalid null customMetadata"); return false; } return true; }</code><technical_language>line 288 is != line 297 is equals. pattern</technical_language>

Target:
private boolean validate() { if (builderLedgerType == null) { LOG.error("invalid null builderLedgerType"); return false; } if (bk.getConf().getUseV2WireProtocol() && !builderLedgerType.equals(LedgerType.FORCE_ON_JOURNAL)) { LOG.error("invalid builderLedgerType while using v2 wire protocol"); return false; } if (builderWriteQuorumSize > builderEnsembleSize) { LOG.error("invalid writeQuorumSize > ensembleSize {}", builderWriteQuorumSize, builderEnsembleSize); return false; } if (builderAckQuorumSize > builderWriteQuorumSize) { LOG.error("invalid ackQuorumSize > writeQuorumSize {}", builderAckQuorumSize, builderWriteQuorumSize); return false; } if (builderAckQuorumSize <= 0) { LOG.error("invalid ackQuorumSize <= 0", builderAckQuorumSize); return false; } if (builderPassword == null) { LOG.error("invalid null password"); return false; } if (builderDigestType == null) { LOG.error("invalid null digestType"); return false; } if (builderCustomMetadata == null) { LOG.error("invalid null customMetadata"); return false; } return true; }
Source:
<code><START> public void setLocationInfo(IFrameDMData dmData) { <END> if (dmData == null) { this.m_locInfo = null; } else { StringBuilder label = new StringBuilder(); if (dmData.getFunction() != null && dmData.getFunction().length() != 0) { label.append(" "); label.append(dmData.getFunction()); label.append("()"); } boolean hasFileName = dmData.getFile() != null && dmData.getFile().length() != 0; if (hasFileName) { label.append(" at "); label.append(dmData.getFile()); } if (dmData.getLine() >= 0) { label.append(":"); label.append(dmData.getLine()); label.append(" "); } if (!hasFileName && (dmData.getModule() != null && dmData.getModule() .length() != 0)) { label.append(" "); label.append(dmData.getModule()); label.append(" "); } if (dmData.getAddress() != null) { label.append("- 0x" + dmData.getAddress().toString(16)); } this.m_locInfo = label.toString(); } }</code><technical_language>case good is if interrupt a thread interrupt button instead of a breakpoint. This end in some library line number. debug view show line number while show a 0, is wrong. try scenario</technical_language>

Target:
public void setLocationInfo(IFrameDMData dmData) { if (dmData == null) { this.m_locInfo = null; } else { StringBuilder label = new StringBuilder(); if (dmData.getFunction() != null && dmData.getFunction().length() != 0) { label.append(" "); label.append(dmData.getFunction()); label.append("()"); } boolean hasFileName = dmData.getFile() != null && dmData.getFile().length() != 0; if (hasFileName) { label.append(" at "); label.append(dmData.getFile()); if (dmData.getLine() >= 0) { label.append(":"); label.append(dmData.getLine()); label.append(" "); } } if (!hasFileName && (dmData.getModule() != null && dmData.getModule() .length() != 0)) { label.append(" "); label.append(dmData.getModule()); label.append(" "); } if (dmData.getAddress() != null) { label.append("- 0x" + dmData.getAddress().toString(16)); } this.m_locInfo = label.toString(); } }
Source:
<code>protected void configure() { TransactionSynchronizationManager.initSynchronization(); <START> TransactionSynchronizationManager.setActualTransactionActive(true); <END> install(new EngineInitModule()); }</code><technical_language>I do mock spring transactions in engine all</technical_language>

Target:
protected void configure() { requestInjection(transactionManager); bindInterceptor(any(), annotatedWith(Transactional.class), new TransactionInterceptor(transactionManager, new AnnotationTransactionAttributeSource())); install(new EngineInitModule()); }
Source:
<code>public void saveOrUpdateShouldBeUnsuccessfulWhenCandidateIdIsNotANumber() throws Exception { <START> <END> this.mockMvc.perform(post(REQUEST_URL_POST) .param("candidateId", TEXT) .param("position.id", STRING_VALUE_ONE).param("position.name", POSITION_NAME_DEVELOPER) .param("channel.id", STRING_VALUE_ONE).param("channel.name", CHANNEL_NAME_FACEBOOK) .param("description", DESCRIPTION)) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl(REDIRECT_URL_FOR_NON_EXISTING_CANDIDATE)); verifyZeroInteractions(applicationsService); then(this.candidateService).should().getCandidate(null); then(this.positionService).should().getPositionDtoById(1L); then(this.channelService).should().getChannelDtoById(1L); }</code><technical_language>is initialization for candidateService, positionService channelService</technical_language>

Target:
public void saveOrUpdateShouldBeUnsuccessfulWhenCandidateIdIsNotANumber() throws Exception { given(this.candidateService.getCandidate(null)).willThrow(new AssertionError()); given(this.positionService.getPositionDtoById(1L)).willReturn(positionDTO); given(this.channelService.getChannelDtoById(1L)).willReturn(channelDTO); this.mockMvc.perform(post(REQUEST_URL_POST) .param("candidateId", TEXT) .param("position.id", STRING_VALUE_ONE).param("position.name", POSITION_NAME_DEVELOPER) .param("channel.id", STRING_VALUE_ONE).param("channel.name", CHANNEL_NAME_FACEBOOK) .param("description", DESCRIPTION)) .andExpect(status().is3xxRedirection()) .andExpect(flash().attributeCount(1)) .andExpect(model().attributeDoesNotExist("candidateId")); verifyZeroInteractions(applicationsService); then(this.candidateService).should().getCandidate(null); then(this.positionService).should().getPositionDtoById(1L); then(this.channelService).should().getChannelDtoById(1L); }
Source:
<code>private List<URL> getResources() throws IOException { List<URL> result = cachedResourceList; <START> if(result == null) { <END> synchronized(this) { result = cachedResourceList; if(result == null) { final ClassLoader cl = getClassLoader(); if (cl != null) { result = cachedResourceList = Collections.list(cl.getResources(JARCACHE_JSON)); } else { result = cachedResourceList = Collections.list(ClassLoader.getSystemResources(JARCACHE_JSON)); } } } } return result; }</code><technical_language>If want preserve previous behavior of allowing switching of Thread.contextClassLoader(), add additional field ClassLoader loaderUsedToLoad, set ClassLoader loaded cachedResourceList previously, check: if (result == null || loaderUsedToLoad != getClassLoader()) {..</technical_language>

Target:
private List<URL> getResources() throws IOException { final ClassLoader cl = getClassLoader(); final Object key = cl == null ? NULL_CLASS_LOADER : cl; List<URL> newValue = cachedResourceList.get(key); if (newValue != null) { return newValue; } if (cl != null) { newValue = Collections .unmodifiableList(Collections.list(cl.getResources(JARCACHE_JSON))); } else { newValue = Collections.unmodifiableList( Collections.list(ClassLoader.getSystemResources(JARCACHE_JSON))); } final List<URL> oldValue = cachedResourceList.putIfAbsent(key, newValue); return oldValue != null ? oldValue : newValue; }
Source:
<code>private String getToggleTime(int toggleTime, boolean on) { long temp = (on ? 1 : 0) << 16; temp |= (toggleTime & 0x0001FFFF); temp <<= 15; String s = Long.toHexString(temp); <START> for (int i = s.length(); i < 2; i++) <END> s = "0" + s; return s; }</code><technical_language>Please add braces for loop, if is line (see line 82 in this file)</technical_language>

Target:
private String getToggleTime(int toggleTime, boolean on) { long temp = (on ? 1 : 0) << 16; temp |= (toggleTime & 0x0001FFFF); temp <<= 15; String s = Long.toHexString(temp); for (int i = s.length(); i < 2; i++) { s = "0" + s; } return s; }
Source:
<code>public IStatus validate(IValidationContext ctx) { IStatus result = ctx.createSuccessStatus(); final EObject eObj = ctx.getTarget(); if (eObj instanceof ContainerMapping) { if <START> (ctx.getCurrentConstraintId().equals(COMPARTMENT_CONTAINMENT_RULE_ID)) <END> { result = validateCompartmentContainment(ctx, eObj); } else if (ctx.getCurrentConstraintId().equals(CONTAINER_LIST_CONTAINMENT_RULE_ID)) { result = validateContainerListContainment(ctx, eObj); } else if (ctx.getCurrentConstraintId().equals(NODES_IN_REGION_CONTAINER_RULE_ID)) { result = validateSubNodesInRegionContainer(ctx, eObj); } else if (ctx.getCurrentConstraintId().equals(BORDERED_NODES_IN_REGION_CONTAINER_RULE_ID)) { result = validateBorderedNodesInRegion(ctx, eObj); } else if (ctx.getCurrentConstraintId().equals(REGION_MAPPING_STYLE_RULE_ID)) { result = validateRegionStyle(ctx, eObj); } } if (eObj instanceof MappingFilter && ctx.getCurrentConstraintId().equals(MAPPING_FILTER_ON_REGION_MAPPING_RULE_ID)) { result = validateMappingFilterOnRegions(ctx, eObj); } return result; }</code><technical_language>Safer type: COMPARTMENT_CONTAINMENT_RULE_ID.equals(ctx.getCurrentConstraintId())</technical_language>

Target:
public IStatus validate(IValidationContext ctx) { IStatus result = ctx.createSuccessStatus(); final EObject eObj = ctx.getTarget(); if (eObj instanceof ContainerMapping) { if (COMPARTMENT_CONTAINMENT_RULE_ID.equals(ctx.getCurrentConstraintId())) { result = validateCompartmentContainment(ctx, eObj); } else if (CONTAINER_LIST_CONTAINMENT_RULE_ID.equals(ctx.getCurrentConstraintId())) { result = validateContainerListContainment(ctx, eObj); } else if (NODES_IN_REGION_CONTAINER_RULE_ID.equals(ctx.getCurrentConstraintId())) { result = validateSubNodesInRegionContainer(ctx, eObj); } else if (BORDERED_NODES_IN_REGION_CONTAINER_RULE_ID.equals(ctx.getCurrentConstraintId())) { result = validateBorderedNodesInRegion(ctx, eObj); } else if (REGION_MAPPING_STYLE_RULE_ID.equals(ctx.getCurrentConstraintId())) { result = validateRegionStyle(ctx, eObj); } } if (eObj instanceof MappingFilter && MAPPING_FILTER_ON_REGION_MAPPING_RULE_ID.equals(ctx.getCurrentConstraintId())) { result = validateMappingFilterOnRegions(ctx, eObj); } return result; }
Source:
<code>public void should_load_resource_from_url_using_charset() { <START> assertEquals(expectedContent, URLs.contentOf(sampleResourceURL, Charset.forName("UTF-8"))); <END> }</code><technical_language>assertThat</technical_language>

Target:
public void should_load_resource_from_url_using_charset() { assertThat(URLs.contentOf(sampleResourceURL, Charset.forName("UTF-8"))).isEqualTo(expectedContent); }
Source:
<code>public boolean nextRaw(List<Cell> outResults, ScannerContext scannerContext) throws IOException { if (storeHeap == null) { throw new UnknownScannerException("Scanner was closed"); } boolean moreValues = false; if (outResults.isEmpty()) { moreValues = nextInternal(outResults, scannerContext); } else { List<Cell> tmpList = new ArrayList<>(); moreValues = nextInternal(tmpList, scannerContext); outResults.addAll(tmpList); } if (!outResults.isEmpty()) { readRequestsCount.increment(); if (metricsRegion != null) { metricsRegion.updateReadRequestCount(); } } if (rsServices != null && rsServices.getMetrics() != null) { rsServices.getMetrics().updateReadQueryMeter(getRegionInfo().getTable()); } <START> if(isFullRegionScan()) { <END> fullScanRequestsCount.increment(); } if (!scannerContext.mayHaveMoreCellsInRow()) { resetFilters(); } if (isFilterDoneInternal()) { moreValues = false; } return moreValues; }</code><technical_language>format if (isFullRegionScan()) {</technical_language>

Target:
public boolean nextRaw(List<Cell> outResults, ScannerContext scannerContext) throws IOException { if (storeHeap == null) { throw new UnknownScannerException("Scanner was closed"); } boolean moreValues = false; if (outResults.isEmpty()) { moreValues = nextInternal(outResults, scannerContext); } else { List<Cell> tmpList = new ArrayList<>(); moreValues = nextInternal(tmpList, scannerContext); outResults.addAll(tmpList); } if (!outResults.isEmpty()) { readRequestsCount.increment(); if (metricsRegion != null) { metricsRegion.updateReadRequestCount(); } } if (rsServices != null && rsServices.getMetrics() != null) { rsServices.getMetrics().updateReadQueryMeter(getRegionInfo().getTable()); } if (!scannerContext.mayHaveMoreCellsInRow()) { resetFilters(); } if (isFilterDoneInternal()) { moreValues = false; } return moreValues; }
Source:
<code>protected Object encodeCommand(Command command) { command.set(Command.KEY_DEVICE_PASSWORD, "000000"); <START> if (Context.getDeviceManager() != null) { <END> Device device = Context.getDeviceManager().getDeviceById(command.getDeviceId()); if (device != null && device.getAttributes().containsKey(Command.KEY_DEVICE_PASSWORD)) { command.set(Command.KEY_DEVICE_PASSWORD, device.getAttributes() .get(Command.KEY_DEVICE_PASSWORD).toString()); } } switch (command.getType()) { case Command.TYPE_ENGINE_STOP: return formatCommand(command, "*{%s},025,C,1#", Command.KEY_DEVICE_PASSWORD); case Command.TYPE_ENGINE_RESUME: return formatCommand(command, "*{%s},025,C,0#", Command.KEY_DEVICE_PASSWORD); default: Log.warning(new UnsupportedOperationException(command.getType())); break; } return null; }</code><technical_language>Do need null checks? I if get encoder stage, means device exists. Also, call toString() method. cast result string</technical_language>

Target:
protected Object encodeCommand(Command command) { command.set(Command.KEY_DEVICE_PASSWORD, "000000"); Device device = Context.getIdentityManager().getDeviceById(command.getDeviceId()); if (device.getAttributes().containsKey(Command.KEY_DEVICE_PASSWORD)) { command.set(Command.KEY_DEVICE_PASSWORD, (String) device.getAttributes() .get(Command.KEY_DEVICE_PASSWORD)); } switch (command.getType()) { case Command.TYPE_ENGINE_STOP: return formatCommand(command, "*{%s},025,C,1#", Command.KEY_DEVICE_PASSWORD); case Command.TYPE_ENGINE_RESUME: return formatCommand(command, "*{%s},025,C,0#", Command.KEY_DEVICE_PASSWORD); default: Log.warning(new UnsupportedOperationException(command.getType())); break; } return null; }
Source:
<code>public void setStatusLineManager(IStatusLineManager statusLineManager) { if (fStatusLineManager != null && statusLineManager == null) { <START> fStatusLineManager.setMessage(""); <END> } fStatusLineManager = statusLineManager; }</code><technical_language>docs, supposed pass null clear message</technical_language>

Target:
public void setStatusLineManager(IStatusLineManager statusLineManager) { if (fStatusLineManager != null && statusLineManager == null) { fStatusLineManager.setMessage(null); } fStatusLineManager = statusLineManager; }
Source:
<code>public KV<Object, Object> convertToSamzaMessage(SamzaSqlRelMessage relMessage) { Schema schema = computeSchema(streamName, relMessage); <START> GenericRecord record = new GenericData.Record(schema); <END> List<String> fieldNames = relMessage.getFieldNames(); List<Object> values = relMessage.getFieldValues(); for (int index = 0; index < fieldNames.size(); index++) { record.put(fieldNames.get(index), values.get(index)); } return new KV<>(relMessage.getKey(), record); }</code><technical_language>minor: schema is computed differently, rest of code is in super class. set super.avroSchema call super(relMessage) instead</technical_language>

Target:
public KV<Object, Object> convertToSamzaMessage(SamzaSqlRelMessage relMessage) { Schema schema = computeSchema(streamName, relMessage); return convertToSamzaMessage(relMessage, schema); }