auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public SortedSet<GeoServerRole> getRolesForUser(final String username) throws IOException { final SortedSet<GeoServerRole> roles = new TreeSet<GeoServerRole>(); final Set<String> userDn = new HashSet<String>(); userDn.add(username); if (lookupUserForDn && isNotEmpty(userFilter)) { authenticateIfNeeded(new AuthenticatedLdapEntryContextCallback() { @Override public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { try { String dn = LDAPUtils .getLdapTemplateInContext(ctx, template) .searchForSingleEntry("", userFilter, new String[] { username }).getNameInNamespace() <START> .toString(); <END> userDn.clear(); userDn.add(dn); } catch (Exception e) { } } }); } authenticateIfNeeded(new AuthenticatedLdapEntryContextCallback() { @Override public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { fillRolesForUser(ctx, username, userDn.iterator().next(), roles); } }); return Collections.unmodifiableSortedSet(roles); }</code><technical_language>Is this needed</technical_language>

Target:
public SortedSet<GeoServerRole> getRolesForUser(final String username) throws IOException { final SortedSet<GeoServerRole> roles = new TreeSet<GeoServerRole>(); final Set<String> userDn = new HashSet<String>(); userDn.add(username); if (lookupUserForDn && isNotEmpty(userFilter)) { authenticateIfNeeded(new AuthenticatedLdapEntryContextCallback() { @Override public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { try { String dn = LDAPUtils .getLdapTemplateInContext(ctx, template) .searchForSingleEntry("", userFilter, new String[] { username }).getDn() .toString(); userDn.clear(); userDn.add(dn); } catch (Exception e) { } } }); } authenticateIfNeeded(new AuthenticatedLdapEntryContextCallback() { @Override public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { fillRolesForUser(ctx, username, userDn.iterator().next(), roles); } }); return Collections.unmodifiableSortedSet(roles); }
Source:
<code>public RelNode go(RelNode replacement_) { <START> this.RULE_MAP.clear(); <END> return super.go(replacement_); }</code><technical_language>this map is private, static intended immutable. change it</technical_language>

Target:
public RelNode go(RelNode replacement_) { return super.go(replacement_); }
Source:
<code>private OAuth2AccessToken eagerFetchOAuth2AccessToken() { CompletableFuture<OAuth2AccessToken> completableFuture = CompletableFuture.supplyAsync(() -> { OAuth2AccessToken accessToken; try { accessToken = accessTokenRetrieverService.getOAuth2AccessToken(); } catch (IOException | InvalidKeyException e) { throw new IllegalArgumentException(e); } catch (HttpException e) { throw e; } return accessToken; }); OAuth2AccessToken oAuth2AccessTokenResult; try { <START> oAuth2AccessTokenResult = completableFuture.get(); <END> } catch (InterruptedException | ExecutionException e) { throw new IllegalStateException(e); } return oAuth2AccessTokenResult; }</code><technical_language>This blocks, async, remove future call code inline if want eager</technical_language>

Target:
private OAuth2AccessToken eagerFetchOAuth2AccessToken() { OAuth2AccessToken accessToken; try { accessToken = accessTokenRetrieverService.getOAuth2AccessToken(); } catch (IOException | InvalidKeyException e) { throw new OAuth2TokenRetrieverException("Failed to fetch OAuth2 access token eagerly", e); } if (accessToken == null) { throw new OAuth2TokenRetrieverException("Failed to fetch OAuth2 access token eagerly"); } return accessToken; }
Source:
<code>public Snapshot complete() { checkNotNull(file.temporaryFile(), "no temporary snapshot file to read from"); Buffer buffer = FileBuffer.allocate(file.temporaryFile(), SnapshotDescriptor.BYTES); try (SnapshotDescriptor descriptor = new SnapshotDescriptor(buffer)) { descriptor.lock(); } try { <START> Files.move(file.temporaryFile().toPath(), file.file().toPath()); <END> } catch (FileAlreadyExistsException e) { LOGGER.debug("Snapshot was already previously completed", this); } catch (IOException e) { throw new AtomixIOException(e); } file.clearTemporaryFile(); return super.complete(); }</code><technical_language>try StandardCopyOption.ATOMIC_MOVE fallback option</technical_language>

Target:
public Snapshot complete() { checkNotNull(file.temporaryFile(), "no temporary snapshot file to read from"); Buffer buffer = FileBuffer.allocate(file.temporaryFile(), SnapshotDescriptor.BYTES); try (SnapshotDescriptor descriptor = new SnapshotDescriptor(buffer)) { descriptor.lock(); } try { persistTemporaryFile(); } catch (IOException e) { throw new AtomixIOException(e); } file.clearTemporaryFile(); return super.complete(); }
Source:
<code>public void nothingIsIncludedInAnEmptyArray() { <START> List<Integer> emptyList = Collections.unmodifiableList(new ArrayList<Integer>(0)); <END> BinarySearch<Integer> sut = new BinarySearch<>(emptyList); assertEquals(-1, sut.indexOf(1)); }</code><technical_language>[Collections#emptyList](<LINK_0> here? > Returns empty list (immutable)</technical_language>

Target:
public void nothingIsIncludedInAnEmptyArray() { List<Integer> emptyList = Collections.emptyList(); BinarySearch<Integer> sut = new BinarySearch<>(emptyList); assertEquals(-1, sut.indexOf(1)); }
Source:
<code>public Set<I> dispatchEvent(EventEnvelope event) { checkNotNull(event); Set<I> targets = route(event); <START> for (I target : targets) { <END> inbox.send(event).toReactor(target); } return targets; }</code><technical_language>Do need run sequentially? stream API</technical_language>

Target:
public Set<I> dispatchEvent(EventEnvelope event) { checkNotNull(event); Set<I> targets = route(event); targets.forEach((id) -> inbox.send(event).toReactor(id)); return targets; }
Source:
<code><START> public void setLoggerSearchRequest(final LoggerSearchRequest loggerSearchRequest) { <END> this.loggerSearchRequest.setValue(loggerSearchRequest); }</code><technical_language>Add null-check for method parameter</technical_language>

Target:
public void setLoggerSearchRequest(final LoggerSearchRequest loggerSearchRequest) { Assert.requireNonNull(loggerSearchRequest, "loggerSearchRequest"); this.loggerSearchRequest.setValue(loggerSearchRequest); }
Source:
<code>public static IOException createIOException(OperationStatus[] batchOperationStatus) { IOException retriableException = null; for (int i = 0; i < batchOperationStatus.length; i++) { OperationStatus status = batchOperationStatus[i]; switch (status.getOperationStatusCode()) { case SUCCESS: break; case BAD_FAMILY: return new NoSuchColumnFamilyException(status.getExceptionMsg()); case SANITY_CHECK_FAILURE: return new FailedSanityCheckException(status.getExceptionMsg()); case STORE_TOO_BUSY: retriableException = new RegionTooBusyException(status.getExceptionMsg()); break; default: <START> return new DoNotRetryIOException(status.getExceptionMsg()); <END> } } return retriableException; }</code><technical_language>OperationStatus case FAILURE? other retriable exceptions other RegionTooBusyException, there</technical_language>

Target:
public static IOException createIOException(OperationStatus[] batchOperationStatus) { IOException retriableException = null; for (int i = 0; i < batchOperationStatus.length; i++) { OperationStatus status = batchOperationStatus[i]; switch (status.getOperationStatusCode()) { case SUCCESS: break; case BAD_FAMILY: return new NoSuchColumnFamilyException(status.getExceptionMsg()); case SANITY_CHECK_FAILURE: return new FailedSanityCheckException(status.getExceptionMsg()); case STORE_TOO_BUSY: retriableException = new RegionTooBusyException(status.getExceptionMsg()); break; case NOT_RUN: retriableException = new RetryImmediatelyException(status.getExceptionMsg()); break; default: return new DoNotRetryIOException(status.getExceptionMsg()); } } return retriableException; }
Source:
<code>public void testScrutinyOnRowsBeyondMaxLookBack() throws Exception { schema = generateUniqueName(); dataTableName = generateUniqueName(); <START> indexTableName = generateUniqueName(); <END> dataTableFullName = SchemaUtil.getTableName(schema, dataTableName); isViewIndex = false; String dataTableDDL = "CREATE TABLE %s (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR, " + "ZIP INTEGER) COLUMN_ENCODED_BYTES=0, VERSIONS=1"; String indexTableDDL = "CREATE INDEX %s ON %s (NAME) INCLUDE (ZIP)"; testClock = new ManualEnvironmentEdge(); try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(String.format(dataTableDDL, dataTableFullName)); conn.createStatement().execute(String.format(indexTableDDL, indexTableName, dataTableFullName)); conn.commit(); } upsertDataAndScrutinize(dataTableName, dataTableFullName, testClock); }</code><technical_language>nit: consider prepending "I_" "D_" names</technical_language>

Target:
public void testScrutinyOnRowsBeyondMaxLookBack() throws Exception { setupTables(); upsertDataAndScrutinize(dataTableName, dataTableFullName, testClock); assertBeyondMaxLookbackOutput(dataTableFullName, indexTableFullName); }
Source:
<code>public void parseFrom(String stringValue) { <START> context.getApplicationInfo(); <END> }</code><technical_language>this parse data</technical_language>

Target:
public void parseFrom(String stringValue) { BaseApplication app = BaseApplication.getApp(context); EnumDataStore<E> store = app.getEnumDataStore(getValueClass()); if (store != null) { setValue(store.lookupByName(stringValue)); } }
Source:
<code>protected boolean canPerformNicHotPlug() { <START> return osRepository.hasNicHotplugSupport(getVm().getOs(), getVm().getVdsGroupCompatibilityVersion()); <END> }</code><technical_language>Please add this method check for cluster feature compatibility: return isHotPlugSupported() && osRepository.hasNicHotplugSupport(getVm().getOs(), getVm().getVdsGroupCompatibilityVersion());</technical_language>

Target:
protected boolean canPerformNicHotPlug() { return isHotPlugSupported() && osRepository.hasNicHotplugSupport(getVm().getOs(), getVm().getVdsGroupCompatibilityVersion()); }
Source:
<code>private static List<String> getModulePaths(List<ErlangFileDescriptor> buildOrder) { return ContainerUtil.mapNotNull(buildOrder, new Function<ErlangFileDescriptor, String>() { @Override public String fun(ErlangFileDescriptor erlangDependencyTreeNode) { <START> return erlangDependencyTreeNode.myPath; <END> } }); }</code><technical_language>a tree node</technical_language>

Target:
private static List<String> getModulePaths(List<ErlangFileDescriptor> buildOrder) { return ContainerUtil.mapNotNull(buildOrder, new Function<ErlangFileDescriptor, String>() { @Override public String fun(ErlangFileDescriptor erlangFileDescriptor) { return erlangFileDescriptor.myPath; } }); }
Source:
<code>public void completePluginConfigurationUpdate(PluginConfigurationUpdate update) { ConfigurationUpdateResponse response = configurationManager.executePluginConfigurationUpdate(update); Resource resource = update.getResource(); resource.setAgentSynchronizationNeeded(); Configuration oldPluginConfig = resource.getPluginConfiguration(); resource.setPluginConfiguration(update.getConfiguration()); if (response.getStatus() == ConfigurationUpdateStatus.SUCCESS) { update.setStatus(ConfigurationUpdateStatus.SUCCESS); resource.setConnected(true); removeAnyExistingInvalidPluginConfigurationErrors(resource); entityManager.flush(); entityManager.merge(update); <START> entityManager.remove(oldPluginConfig); <END> } else { handlePluginConfiguratonUpdateRemoteException(resource, response.getStatus().toString(), response.getErrorMessage()); update.setStatus(response.getStatus()); update.setErrorMessage(response.getErrorMessage()); } }</code><technical_language>want plug-in configuration remain in plug-in config history page of resource? a configuration update/merge result in orphaned configuration object. Granted, if configuration object configuration parameters, I consider update strange/broken</technical_language>

Target:
public void completePluginConfigurationUpdate(PluginConfigurationUpdate update) { ConfigurationUpdateResponse response = configurationManager.executePluginConfigurationUpdate(update); Resource resource = update.getResource(); resource.setAgentSynchronizationNeeded(); entityManager.remove(resource.getPluginConfiguration()); resource.setPluginConfiguration(update.getConfiguration().deepCopyWithoutProxies()); if (response.getStatus() == ConfigurationUpdateStatus.SUCCESS) { update.setStatus(ConfigurationUpdateStatus.SUCCESS); resource.setConnected(true); removeAnyExistingInvalidPluginConfigurationErrors(resource); entityManager.flush(); entityManager.merge(update); } else { handlePluginConfiguratonUpdateRemoteException(resource, response.getStatus().toString(), response.getErrorMessage()); update.setStatus(response.getStatus()); update.setErrorMessage(response.getErrorMessage()); } }
Source:
<code><START> public ChargeEntity updateChargeAndEmitEventPostAuthorisation(String chargeExternalId, <END> ChargeStatus status, AuthCardDetails authCardDetails, Optional<String> transactionId, Optional<Auth3dsDetailsEntity> auth3dsDetails, Optional<String> sessionIdentifier, Optional<WalletType> walletType, Optional<String> emailAddress) { ChargeEntity chargeEntity = updateChargePostAuthorisation(chargeExternalId, status, authCardDetails, transactionId, auth3dsDetails, sessionIdentifier, walletType, emailAddress); emitEvent(PaymentDetailsEnteredEvent.from(chargeEntity)); return chargeEntity; }</code><technical_language>private, I this clearer interface is proxy methods</technical_language>

Target:
private ChargeEntity updateChargeAndEmitEventPostAuthorisation(String chargeExternalId, ChargeStatus status, AuthCardDetails authCardDetails, Optional<String> transactionId, Optional<Auth3dsDetailsEntity> auth3dsDetails, Optional<String> sessionIdentifier, Optional<WalletType> walletType, Optional<String> emailAddress) { ChargeEntity chargeEntity = updateChargePostAuthorisation(chargeExternalId, status, authCardDetails, transactionId, auth3dsDetails, sessionIdentifier, walletType, emailAddress); emitEvent(PaymentDetailsEnteredEvent.from(chargeEntity)); return chargeEntity; }
Source:
<code>public void alertWhenMalformedRefererContainsSensitiveInfo() throws HttpMalformedHeaderException, URIException { String testReferer = "<LINK_0>passWord=whatsup&hl=en"; HttpMessage msg = createHttpMessageWithRespBody(testReferer); rule.scanHttpRequestSend(msg, -1); <START> assertEquals(1, alertsRaised.size()); <END> }</code><technical_language>apply evidence/other info assertions in tests well</technical_language>

Target:
public void alertWhenMalformedRefererContainsSensitiveInfo() throws HttpMalformedHeaderException, URIException { String sensitiveParamName = "passWord"; String sensitiveValue = "whatsup"; String testReferer = "<LINK_0>" + sensitiveParamName + "=" + sensitiveValue + "&hl=en"; HttpMessage msg = createHttpMessageWithRespBody(testReferer); rule.scanHttpRequestSend(msg, -1); assertEquals(1, alertsRaised.size()); assertEquals(sensitiveParamName, alertsRaised.get(0).getEvidence()); assertEquals( Constant.messages.getString( InformationDisclosureReferrerScanner.MESSAGE_PREFIX + "otherinfo.sensitiveinfo"), alertsRaised.get(0).getOtherInfo()); }
Source:
<code>public Condition saveCondition(Condition condition) { Condition existingCondition = getConditionByUuid(condition.getUuid()); if (condition.equals(existingCondition)) { return existingCondition; } if (existingCondition == null) { <START> return conditionDAO.saveCondition(condition); <END> } condition.setPreviousVersion(existingCondition); if (existingCondition.getClinicalStatus().equals(condition.getClinicalStatus())) { existingCondition.setVoided(true); conditionDAO.saveCondition(existingCondition); return conditionDAO.saveCondition(condition); } Date onSetDate = condition.getOnsetDate() != null ? condition.getOnsetDate() : new Date(); existingCondition.setEndDate(onSetDate); conditionDAO.saveCondition(existingCondition); condition.setOnsetDate(onSetDate); return conditionDAO.saveCondition(condition); }</code><technical_language>@Arthur236 intentionally leave out lines in original save method of emrapi module</technical_language>

Target:
public Condition saveCondition(Condition condition) { Date endDate = condition.getEndDate() != null ? condition.getEndDate() : new Date(); if (condition.getEndReason() != null) { condition.setEndDate(endDate); } Condition existingCondition = getConditionByUuid(condition.getUuid()); if (condition.equals(existingCondition)) { return existingCondition; } if (existingCondition == null) { return conditionDAO.saveCondition(condition); } condition = Condition.newInstance(condition); condition.setPreviousVersion(existingCondition); if (existingCondition.getClinicalStatus().equals(condition.getClinicalStatus())) { existingCondition.setVoided(true); conditionDAO.saveCondition(existingCondition); return conditionDAO.saveCondition(condition); } Date onSetDate = condition.getOnsetDate() != null ? condition.getOnsetDate() : new Date(); existingCondition.setEndDate(onSetDate); conditionDAO.saveCondition(existingCondition); condition.setOnsetDate(onSetDate); return conditionDAO.saveCondition(condition); }
Source:
<code>public void testCreateContentWithCats_AnonymousUser_RESTAPICONTENTALLOWFRONTENDSAVINGfalse_shouldFail403() throws DotSecurityException, DotDataException, JSONException { <START> final String REST_API_CONTENT_ALLOW_FRONT_END_SAVING = "REST_API_CONTENT_ALLOW_FRONT_END_SAVING"; <END> boolean restAPIContentAllowFrontEndSavingValue = Config.getBooleanProperty(REST_API_CONTENT_ALLOW_FRONT_END_SAVING); try { long time = System.currentTimeMillis(); final String TITLE_FIELD_VARIABLE = "title"+time; final String CAT_FIELD_VARIABLE = "eventType"+time; ContentType type = createContentTypeWithCatAndTextField(TITLE_FIELD_VARIABLE, CAT_FIELD_VARIABLE); Config.setProperty(REST_API_CONTENT_ALLOW_FRONT_END_SAVING, false); Response response = webTarget.path("/save/1/").request() .put(Entity.entity(new JSONObject() .put("stInode", type.id()) .put("languageId", 1) .put(TITLE_FIELD_VARIABLE, "Test content from ContentResourceTest") .put(CAT_FIELD_VARIABLE, "seminars") .toString(), MediaType.APPLICATION_JSON_TYPE)); assertTrue(response.getStatus() == Response.Status.FORBIDDEN.getStatusCode()); } finally { Config.setProperty("REST_API_CONTENT_ALLOW_FRONT_END_SAVING", restAPIContentAllowFrontEndSavingValue); } }</code><technical_language>a constant</technical_language>

Target:
public void testCreateContentWithCats_AnonymousUser_RESTAPICONTENTALLOWFRONTENDSAVINGfalse_shouldFail403() throws DotSecurityException, DotDataException, JSONException { final boolean restAPIContentAllowFrontEndSavingValue = Config.getBooleanProperty(REST_API_CONTENT_ALLOW_FRONT_END_SAVING); try { final long time = System.currentTimeMillis(); final String TITLE_FIELD_VARIABLE = "title"+time; final String CAT_FIELD_VARIABLE = "eventType"+time; final ContentType type = createContentTypeWithCatAndTextField(TITLE_FIELD_VARIABLE, CAT_FIELD_VARIABLE); Config.setProperty(REST_API_CONTENT_ALLOW_FRONT_END_SAVING, false); final Response response = webTarget.path("/save/1/").request() .put(Entity.entity(new JSONObject() .put("stInode", type.id()) .put("languageId", 1) .put(TITLE_FIELD_VARIABLE, "Test content from ContentResourceTest") .put(CAT_FIELD_VARIABLE, "seminars") .toString(), MediaType.APPLICATION_JSON_TYPE)); assertTrue(response.getStatus() == Response.Status.FORBIDDEN.getStatusCode()); } finally { Config.setProperty(REST_API_CONTENT_ALLOW_FRONT_END_SAVING, restAPIContentAllowFrontEndSavingValue); } }
Source:
<code><START> public Map<Long, BaseEntityRef> getEntityStore() { <END> return entityStore; }</code><technical_language>care mutability of map</technical_language>

Target:
protected Map<Long, BaseEntityRef> getEntityStore() { return Collections.unmodifiableMap(entityStore); }
Source:
<code>public void close() { final MappedByteBuffer cncByteBuffer = this.cncByteBuffer; this.cncByteBuffer = null; <START> AeronCloseHelper.close(errorHandler, () -> IoUtil.unmap(cncByteBuffer)); <END> AeronCloseHelper.close(errorHandler, super::close); }</code><technical_language>Unmap generate error</technical_language>

Target:
public void close() { final MappedByteBuffer cncByteBuffer = this.cncByteBuffer; this.cncByteBuffer = null; IoUtil.unmap(cncByteBuffer); super.close(); }
Source:
<code>ServerStoreImpl(ServerStoreConfiguration storeConfiguration, PageSource pageSource) { this.storeConfiguration = storeConfiguration; this.pageSource = pageSource; <START> this.store = new OffHeapServerStore(pageSource, 16); <END> }</code><technical_language>a constant instead of hardcoded 16</technical_language>

Target:
ServerStoreImpl(ServerStoreConfiguration storeConfiguration, PageSource pageSource) { this.storeConfiguration = storeConfiguration; this.pageSource = pageSource; this.store = new OffHeapServerStore(pageSource, OFFHEAP_CHAIN_SEGMENTS); }
Source:
<code>StoredWorkflowDefinition convert(WorkflowDefinition<? extends WorkflowState> definition) { StoredWorkflowDefinition resp = new StoredWorkflowDefinition(); resp.type = definition.getType(); resp.description = definition.getDescription(); resp.onError = definition.getErrorState().name(); Map<String, StoredWorkflowDefinition.State> states = new LinkedHashMap<>(); for (WorkflowState state : definition.getStates()) { states.put(state.name(), new StoredWorkflowDefinition.State(state.name(), state.getType().name(), state.getDescription())); } for (Entry<String, List<String>> entry : definition.getAllowedTransitions().entrySet()) { StoredWorkflowDefinition.State state = states.get(entry.getKey()); for (String targetState : entry.getValue()) { state.transitions.add(targetState); } sort(state.transitions); } for (Entry<String, WorkflowState> entry : definition.getFailureTransitions().entrySet()) { StoredWorkflowDefinition.State state = states.get(entry.getKey()); state.onFailure = entry.getValue().name(); } List<StoredWorkflowDefinition.State> sortedStates = new ArrayList<>(states.values()); <START> sort(sortedStates, new Comparator<StoredWorkflowDefinition.State>() { <END> @Override public int compare(State state, State otherState) { return state.type.compareTo(otherState.type); } }); resp.states = sortedStates; return resp; }</code><technical_language>StoredWorkdlowDefinition.State implement Comparable</technical_language>

Target:
StoredWorkflowDefinition convert(WorkflowDefinition<? extends WorkflowState> definition) { StoredWorkflowDefinition resp = new StoredWorkflowDefinition(); resp.type = definition.getType(); resp.description = definition.getDescription(); resp.onError = definition.getErrorState().name(); Map<String, StoredWorkflowDefinition.State> states = new HashMap<>(); for (WorkflowState state : definition.getStates()) { states.put(state.name(), new StoredWorkflowDefinition.State(state.name(), state.getType().name(), state.getDescription())); } for (Entry<String, List<String>> entry : definition.getAllowedTransitions().entrySet()) { StoredWorkflowDefinition.State state = states.get(entry.getKey()); for (String targetState : entry.getValue()) { state.transitions.add(targetState); } sort(state.transitions); } for (Entry<String, WorkflowState> entry : definition.getFailureTransitions().entrySet()) { StoredWorkflowDefinition.State state = states.get(entry.getKey()); state.onFailure = entry.getValue().name(); } resp.states = new ArrayList<>(states.values()); sort(resp.states); return resp; }
Source:
<code>private void updateViewVisibilityIfCollaboratorsFound() { TextView noCollaborators = (TextView) findViewById(R.id.no_collaborators_text); <START> noCollaborators.setVisibility(GONE); <END> LinearLayout layout = (LinearLayout) findViewById(R.id.invite_collaborator_initials_list); layout.setVisibility(VISIBLE); }</code><technical_language>mInitialsListView others defined in init method</technical_language>

Target:
private void updateViewVisibilityIfCollaboratorsFound() { TextView noCollaborators = (TextView) findViewById(R.id.no_collaborators_text); noCollaborators.setVisibility(GONE); mInitialsListView.setVisibility(VISIBLE); }
Source:
<code>public OsiamLdapUserDetailsImpl synchronizeLdapData(DirContextOperations ldapUserData, OsiamLdapUserDetailsImpl ldapUser) { String userName = ldapUserData.getStringAttribute(scimLdapAttributes.get("userName")); User user = userDetailsService.getUserByUsername(userName); boolean userExists = user != null; if (userExists && (!user.isExtensionPresent(LdapConfiguration.AUTH_EXTENSION) || !user.getExtension(LdapConfiguration.AUTH_EXTENSION).isFieldPresent("origin") || !user.getExtension(LdapConfiguration.AUTH_EXTENSION).getFieldAsString("origin") <START> .equals(LdapConfiguration.LDAP_PROVIDER))) { <END> throw new LdapAuthenticationProcessException("Can't create the '" + LdapConfiguration.LDAP_PROVIDER + "' user with the username '" + userName + "'. An internal user with the same username exists."); } if (!userExists) { user = osiamLdapUserContextMapper.mapUser(ldapUserData); user = userDetailsService.createUser(user); } else if (syncUserData && userExists) { UpdateUser updateUser = osiamLdapUserContextMapper.mapUpdateUser(user, ldapUserData); user = userDetailsService.updateUser(user.getId(), updateUser); } ldapUser.setId(user.getId()); return ldapUser; }</code><technical_language>extract condition in a separate helper method</technical_language>

Target:
private OsiamLdapUserDetailsImpl synchronizeLdapData(DirContextOperations ldapUserData, OsiamLdapUserDetailsImpl ldapUser) { String userName = ldapUserData.getStringAttribute(scimLdapAttributes.get("userName")); User user = userDetailsService.getUserByUsername(userName); boolean userExists = user != null; if (userExists && !hasAuthServerExtension(user)) { throw new LdapAuthenticationProcessException("Can't create the '" + LdapConfiguration.LDAP_PROVIDER + "' user with the username '" + userName + "'. An internal user with the same username exists."); } if (!userExists) { user = osiamLdapUserContextMapper.mapUser(ldapUserData); user = userDetailsService.createUser(user); } else if (syncUserData && userExists) { UpdateUser updateUser = osiamLdapUserContextMapper.mapUpdateUser(user, ldapUserData); user = userDetailsService.updateUser(user.getId(), updateUser); } ldapUser.setId(user.getId()); return ldapUser; }
Source:
<code>private Collection<Policy> toPolicy(String tenant, Set<String> subjects) { Collection<Policy> policies = new ArrayList<Policy>(); for (String subject : subjects) { <START> LOGGER.debug("Getting policies for subject [" + subject + "]"); <END> policies.addAll(dao.getPolicies(tenant, subject)); } return policies; }</code><technical_language><LINK_0></technical_language>

Target:
private Collection<Policy> toPolicy(String tenant, Set<String> subjects) { Collection<Policy> policies = new ArrayList<Policy>(); for (String subject : subjects) { LOGGER.debug("Getting policies for subject [{}]", subject); policies.addAll(dao.getPolicies(tenant, subject)); } return policies; }
Source:
<code>public void findIndexMatches(Index index, IProgressMonitor monitor, final IIndexRequestor requestor) { final IPath path = index.getPath(); final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); List<QueryResult> list = index.query( new String[] { IQ7IndexConstants.WS_LINK_REF }, new IKeyQuery() { public boolean accept(String key, String value) { <START> if (linksFilterPaths == null) { <END> return true; } IPath path = new Path(value); return linksFilterPaths.contains(path) ? true : false; } }, monitor); for (QueryResult queryResult : list) { Path fullPath = new Path(queryResult.path); IResource res = root.findMember(path.append(fullPath)); if (res.exists()) { IQ7Element q7Element = RcpttCore.create(res); requestor.acceptMatch(q7Element, queryResult.key, queryResult.value); } } }</code><technical_language>Check for isEmpty instead</technical_language>

Target:
public void findIndexMatches(Index index, IProgressMonitor monitor, final IIndexRequestor requestor) { final IPath path = index.getPath(); final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); List<QueryResult> list = index.query( new String[] { IQ7IndexConstants.WS_LINK_REF }, new IKeyQuery() { public boolean accept(String key, String value) { if (linksFilterPaths.isEmpty()) { return true; } IPath path = new Path(value); return linksFilterPaths.contains(path) ? true : false; } }, monitor); for (QueryResult queryResult : list) { Path fullPath = new Path(queryResult.path); IResource res = root.findMember(path.append(fullPath)); if (res.exists()) { IQ7Element q7Element = RcpttCore.create(res); requestor.acceptMatch(q7Element, queryResult.key, queryResult.value); } } }
Source:
<code>public static void main(String[] args) { String connectionString = System.getenv("AZURE_SERVICEBUS_CONNECTION_STRING"); ServiceBusSenderAsyncClient senderAsyncClient = new ServiceBusClientBuilder() .connectionString(connectionString) .sender() .queueName("<< QUEUE NAME >>") .buildAsyncClient(); ServiceBusMessage message = new ServiceBusMessage("Hello World!!".getBytes(UTF_8)); senderAsyncClient.scheduleMessage(message, Instant.now().plusSeconds(1 * 60L)) .subscribe(aLong -> { <START> System.out.println("!! After schedule message sequence : " + aLong); <END> }); try { Thread.sleep(Duration.ofSeconds(20).toMillis()); } catch (InterruptedException ignored) { } }</code><technical_language>printed messages cleaned in samples</technical_language>

Target:
public static void main(String[] args) { String connectionString = System.getenv("AZURE_SERVICEBUS_CONNECTION_STRING"); ServiceBusSenderAsyncClient senderAsyncClient = new ServiceBusClientBuilder() .connectionString(connectionString) .sender() .queueName("<< QUEUE NAME >>") .buildAsyncClient(); ServiceBusMessage message = new ServiceBusMessage("Hello World!!".getBytes(UTF_8)); senderAsyncClient.scheduleMessage(message, Instant.now().plusSeconds(60)) .subscribe(); try { Thread.sleep(Duration.ofSeconds(20).toMillis()); } catch (InterruptedException ignored) { } }
Source:
<code>protected boolean isUnavailable(T size) { <START> return size == null || size.longValue() == -1; <END> }</code><technical_language>constant instead of -1, e.g. IsoDomainListSyncronizer.SIZE_IS_NOT_AVAILABLE? means constant live classes it</technical_language>

Target:
protected boolean isUnavailable(T size) { return size == null || size.longValue() == StorageConstants.SIZE_IS_NOT_AVAILABLE; }
Source:
<code>public ResponseEntity addOrUpdateRepository(@ApiParam(value = "The storageId", required = true) @PathVariable String storageId, @ApiParam(value = "The repositoryId", required = true) @PathVariable String repositoryId, @ApiParam(value = "The repository object", required = true) @RequestBody @Validated RepositoryForm repositoryForm, BindingResult bindingResult, @RequestHeader(HttpHeaders.ACCEPT) String accept) { if (bindingResult.hasErrors()) { throw new RequestBodyValidationException(FAILED_SAVE_REPOSITORY, bindingResult); } try { MutableRepository repository = conversionService.convert(repositoryForm, MutableRepository.class); logger.debug("Creating repository " + storageId + ":" + repositoryId + "..."); configurationManagementService.saveRepository(storageId, repository); if (repository != null && RepositoryTypeEnum.PROXY.getType().equals(repository.getType())) { <START> proxyRepositoryConnectionPoolConfigurationService.setMaxPerRepository( <END> repository.getRemoteRepository() .getUrl(), repository.getHttpConnectionPool().getAllocatedConnections()); } final RepositoryPath repositoryPath = repositoryPathResolver.resolve(new Repository(repository)); if (!Files.exists(repositoryPath)) { repositoryManagementService.createRepository(storageId, repository.getId()); } return getSuccessfulResponseEntity(SUCCESSFUL_REPOSITORY_SAVE, accept); } catch (IOException | ConfigurationException | RepositoryManagementStrategyException e) { logger.error(e.getMessage(), e); return getFailedResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR, FAILED_REPOSITORY_SAVE, accept); } }</code><technical_language>do org.carlspring.strongbox.services.impl.ConfigurationManagementServiceImpl#saveRepository modifyInLock block</technical_language>

Target:
public ResponseEntity addOrUpdateRepository(@ApiParam(value = "The storageId", required = true) @PathVariable String storageId, @ApiParam(value = "The repositoryId", required = true) @PathVariable String repositoryId, @ApiParam(value = "The repository object", required = true) @RequestBody @Validated RepositoryForm repositoryForm, BindingResult bindingResult, @RequestHeader(HttpHeaders.ACCEPT) String accept) { if (bindingResult.hasErrors()) { throw new RequestBodyValidationException(FAILED_SAVE_REPOSITORY, bindingResult); } try { MutableRepository repository = conversionService.convert(repositoryForm, MutableRepository.class); logger.debug("Creating repository " + storageId + ":" + repositoryId + "..."); configurationManagementService.saveRepository(storageId, repository); final RepositoryPath repositoryPath = repositoryPathResolver.resolve(new Repository(repository)); if (!Files.exists(repositoryPath)) { repositoryManagementService.createRepository(storageId, repository.getId()); } return getSuccessfulResponseEntity(SUCCESSFUL_REPOSITORY_SAVE, accept); } catch (IOException | ConfigurationException | RepositoryManagementStrategyException e) { logger.error(e.getMessage(), e); return getFailedResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR, FAILED_REPOSITORY_SAVE, accept); } }
Source:
<code>public VdcActionParametersBase getParameters(VM incoming, org.ovirt.engine.core.common.businessentities.VM entity) { VmStatic updated = getMapper(modelType, VmStatic.class).map(incoming, entity.getStaticData()); VmManagementParametersBase params = new VmManagementParametersBase(updated); if (incoming.isSetVmPayloads()) { if (incoming.getVmPayloads().getVmPayload().get(0).isSetType()) { VmDeviceType deviceType = VmDeviceType.fromValue(incoming.getVmPayloads().getVmPayload().get(0).getType()); if (deviceType != null) { org.ovirt.engine.core.common.businessentities.VmPayload vmPayload = new org.ovirt.engine.core.common.businessentities.VmPayload(org.ovirt.engine.api.restapi.types.VmMapper.map(deviceType, null), incoming.getVmPayloads().getVmPayload().get(0).getFile().getName(), incoming.getVmPayloads() .getVmPayload() .get(0) .getFile() .getContent()); params.setVmPayload(vmPayload); } } } <START> return params; <END> }</code><technical_language>add VmMapper a method maps: (restapi) VmPayloads--> (backend) VmPayload reference BackendVmsResource</technical_language>

Target:
public VdcActionParametersBase getParameters(VM incoming, org.ovirt.engine.core.common.businessentities.VM entity) { VmStatic updated = getMapper(modelType, VmStatic.class).map(incoming, entity.getStaticData()); VmManagementParametersBase params = new VmManagementParametersBase(updated); if (incoming.isSetVmPayloads()) { params.setVmPayload(getMapper(VmPayloads.class, org.ovirt.engine.core.common.businessentities.VmPayload.class).map(incoming.getVmPayloads(), new org.ovirt.engine.core.common.businessentities.VmPayload())); } return params; }
Source:
<code>public String replaceIllegalCharacters(String name) { if (generationConfig.isAllowNonLatinNames()) { <START> return name; <END> } else { return name.replaceAll(ILLEGAL_CHARACTER_REGEX, "_"); } }</code><technical_language>I bet add some restrictions * whitespace is allowed well</technical_language>

Target:
public String replaceIllegalCharacters(String name) { if (generationConfig.isAllowNonLatinNames()) { return validJavaIdentifierFrom(name); } else { return name.replaceAll(ILLEGAL_CHARACTER_REGEX, "_"); } }
Source:
<code>public String getDocumentPartitioning() { if(fReconcilers.size() == 0) return null; String firstPartitioning = ((IReconcilerExtension)fReconcilers.get(0)).getDocumentPartitioning(); if(!(firstPartitioning == null || firstPartitioning.equals(IDocumentExtension3.DEFAULT_PARTITIONING))){ return firstPartitioning; } for (IReconciler iReconciler : fReconcilers) { if(iReconciler instanceof IReconcilerExtension) { String partitioning = ((IReconcilerExtension)iReconciler).getDocumentPartitioning(); <START> if(partitioning != firstPartitioning) { <END> return partitioning; } } } return firstPartitioning; }</code><technical_language>partitioning null, 2nd DEFAULT_PARTITIONING, I need check values returning</technical_language>

Target:
public String getDocumentPartitioning() { if(fReconcilers.size() == 0) return null; String firstPartitioning = ((IReconcilerExtension)fReconcilers.get(0)).getDocumentPartitioning(); if(!(firstPartitioning == null || firstPartitioning.equals(IDocumentExtension3.DEFAULT_PARTITIONING))){ return firstPartitioning; } boolean allSame = true; for (IReconciler iReconciler : fReconcilers) { if(iReconciler instanceof IReconcilerExtension) { String partitioning = ((IReconcilerExtension)iReconciler).getDocumentPartitioning(); if(allSame && partitioning != firstPartitioning) { allSame = false; } if(!allSame && !(partitioning == null || partitioning.equals(IDocumentExtension3.DEFAULT_PARTITIONING))){ return partitioning; } } } return firstPartitioning; }
Source:
<code><START> public void testAddNewRelationship_noIndex() throws Exception { <END> final Node diagram = createNode(CaseManagementDiagram.class); final Node start = createNode(StartNoneEvent.class); final Node end = createNode(EndNoneEvent.class); final Node stage = createNode(AdHocSubprocess.class); final Node candidate = createNode(AdHocSubprocess.class); createChildEdge(diagram, start); createChildEdge(diagram, stage); createChildEdge(diagram, end); createSequenceFlow(start, stage); final Edge edge = createSequenceFlow(stage, end); final CaseManagementSetChildNodeGraphCommand command = new CaseManagementSetChildNodeGraphCommand(diagram, candidate, OptionalInt.empty(), Optional.of(diagram), originalIndex); command.addNewRelationship(context); assertTrue(command.in.isPresent()); assertEquals(stage, command.in.get()); assertTrue(command.out.isPresent()); assertEquals(end, command.out.get()); assertTrue(command.edge.isPresent()); assertEquals(edge, command.edge.get()); assertEquals(candidate, ((Edge) diagram.getOutEdges().get(2)).getTargetNode()); assertEquals(candidate, ((Edge) stage.getOutEdges().get(0)).getTargetNode()); assertEquals(1, end.getInEdges().stream().filter(sequencePredicate()).count()); assertEquals(candidate, ((List) end.getInEdges().stream().filter(sequencePredicate()) .map(e -> ((Edge) e).getSourceNode()).collect(Collectors.toList())).get(0)); }</code><technical_language>Exception is thrown</technical_language>

Target:
public void testAddNewRelationship_noIndex() { final Node diagram = createNode(CaseManagementDiagram.class); final Node start = createNode(StartNoneEvent.class); final Node end = createNode(EndNoneEvent.class); final Node stage = createNode(AdHocSubprocess.class); final Node candidate = createNode(AdHocSubprocess.class); createChildEdge(diagram, start); createChildEdge(diagram, stage); createChildEdge(diagram, end); createSequenceFlow(start, stage); final Edge edge = createSequenceFlow(stage, end); final CaseManagementSetChildNodeGraphCommand command = new CaseManagementSetChildNodeGraphCommand(diagram, candidate, OptionalInt.empty(), Optional.of(diagram), originalIndex); command.addNewRelationship(context); assertTrue(command.in.isPresent()); assertEquals(stage, command.in.get()); assertTrue(command.out.isPresent()); assertEquals(end, command.out.get()); assertTrue(command.edge.isPresent()); assertEquals(edge, command.edge.get()); assertEquals(candidate, ((Edge) diagram.getOutEdges().get(2)).getTargetNode()); assertEquals(candidate, ((Edge) stage.getOutEdges().get(0)).getTargetNode()); assertEquals(1, end.getInEdges().stream().filter(sequencePredicate()).count()); assertEquals(candidate, ((List) end.getInEdges().stream().filter(sequencePredicate()) .map(e -> ((Edge) e).getSourceNode()).collect(Collectors.toList())).get(0)); }
Source:
<code>public void deleteCacheStorageTest() { <START> CacheStorageImpl cache = new CacheStorageImpl(); <END> final Map<Identifier, OperatorState> queryState1= new HashMap<>(); queryState1.put(oid1, value1); cache.create(qid1, queryState1); Assert.assertEquals(value1, cache.read(qid1, oid1)); Assert.assertEquals(true, cache.delete(qid1)); Assert.assertSame(null, cache.read(qid1, oid1)); Assert.assertEquals(false, cache.delete(qid1)); Assert.assertEquals(false, cache.delete(qid2)); }</code><technical_language>final . CacheStorageImpl cache -> CacheStorage</technical_language>

Target:
public void deleteCacheStorageTest() { final CacheStorage cache = new CacheStorageImpl(); final Map<Identifier, OperatorState> queryState1 = new HashMap<>(); queryState1.put(oid1, value1); cache.create(qid1, queryState1); Assert.assertEquals(value1, cache.read(qid1, oid1)); Assert.assertTrue(cache.delete(qid1)); Assert.assertSame(null, cache.read(qid1, oid1)); Assert.assertFalse(cache.delete(qid1)); Assert.assertFalse(cache.delete(qid2)); }
Source:
<code>protected void checkPermission(ProjectControl ctl) throws AuthException { if (!ctl.controlForRef(REF_CONFIG).canSubmit()) { throw new AuthException("You are not allowed to perform this operation." + " To push into this reference you need 'Submit' rights."); <START> } <END> }</code><technical_language>message confusing talks pushing submitting. for this class use: " submit changes need 'Submit' rights " + REF_CONFIG"."</technical_language>

Target:
protected void checkPermission(ProjectControl ctl) throws AuthException { if (!ctl.controlForRef(REF_CONFIG).canSubmit()) { throw new AuthException("You are not allowed to perform this operation." + " To submit changes you need 'Submit' rights on " + REF_CONFIG + "."); } }
Source:
<code>private static ValidationResult checkForStructuresWithoutMedia(Workpiece workpiece, Map<String, String> translations) { boolean error = false; boolean warning = false; Collection<String> messages = new HashSet<>(); Collection<String> structuresWithoutMedia = treeStream(workpiece.getRootElement()) .filter(IncludedStructuralElement.class::isInstance).map(IncludedStructuralElement.class::cast) .filter(structure -> structure.getViews().isEmpty()) .map(structure -> translations.get(MESSAGE_STRUCTURE_WITHOUT_MEDIA) + ' ' + structure) .collect(Collectors.toSet()); if (!structuresWithoutMedia.isEmpty()) { messages.addAll(structuresWithoutMedia); warning = true; } if (treeStream(workpiece.getRootElement()).filter(IncludedStructuralElement.class::isInstance) .map(IncludedStructuralElement.class::cast) .flatMap(structure -> structure.getViews().stream()).map(View::getMediaUnit) <START> .filter(workpiece.getMediaUnits()::contains).findAny().isPresent()) { <END> messages.add(translations.get(MESSAGE_MEDIA_MISSING)); error = true; } return new ValidationResult(error ? State.ERROR : warning ? State.WARNING : State.SUCCESS, messages); }</code><technical_language>filter().findAny().isPresent() chain replaced 'anyMatch' avoids creating redundant temporary objects traversing a collection</technical_language>

Target:
private static ValidationResult checkForStructuresWithoutMedia(Workpiece workpiece, Map<String, String> translations) { boolean error = false; boolean warning = false; Collection<String> messages = new HashSet<>(); Collection<String> structuresWithoutMedia = treeStream(workpiece.getRootElement()) .filter(IncludedStructuralElement.class::isInstance).map(IncludedStructuralElement.class::cast) .filter(structure -> structure.getViews().isEmpty()) .map(structure -> translations.get(MESSAGE_STRUCTURE_WITHOUT_MEDIA) + ' ' + structure) .collect(Collectors.toSet()); if (!structuresWithoutMedia.isEmpty()) { messages.addAll(structuresWithoutMedia); warning = true; } if (treeStream(workpiece.getRootElement()).filter(IncludedStructuralElement.class::isInstance) .map(IncludedStructuralElement.class::cast) .flatMap(structure -> structure.getViews().stream()).map(View::getMediaUnit) .anyMatch(workpiece.getMediaUnits()::contains)) { messages.add(translations.get(MESSAGE_MEDIA_MISSING)); error = true; } return new ValidationResult(error ? State.ERROR : warning ? State.WARNING : State.SUCCESS, messages); }
Source:
<code>private void parseGraphPrintData(Entity entity, DetailField field, int fieldIndex) { try { Object evaluatedField = entity.getField(fieldIndex); String graphTitle = field.getHeader().evaluate(); if ("".equals(graphTitle) || graphTitle == null) { graphTitle = " "; } String fullGraphHtml = ((GraphData)evaluatedField).getGraphHTML(graphTitle); this.valueString = fullGraphHtml; } catch (GraphException e) { <START> this.valueString = ""; <END> } }</code><technical_language>This this pretty hard debug if issues</technical_language>

Target:
private void parseGraphPrintData(Entity entity, DetailField field, int fieldIndex) { try { Object evaluatedField = entity.getField(fieldIndex); String graphTitle = field.getHeader().evaluate(); if ("".equals(graphTitle) || graphTitle == null) { graphTitle = " "; } String fullGraphHtml = ((GraphData)evaluatedField).getGraphHTML(graphTitle); this.valueString = fullGraphHtml; } catch (GraphException e) { this.valueString = String.format("<p>AN ERROR OCCURRED: %s</p>", e.getMessage()); } }
Source:
<code>public Long getGenEndTimeAsLong() { <START> return (genEndTime == null) ? null : genEndTime.atZone(ZoneId.systemDefault()).toEpochSecond(); <END> }</code><technical_language>need this return epoch in milliseconds (java Date interpretation) unix epoch (in seconds), GUI interpret this correctly. Try this: genEndTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); getters</technical_language>

Target:
public Long getGenEndTimeAsLong() { return (genEndTime == null) ? null : genEndTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); }
Source:
<code>protected void setDefaultSwitchTypeIfNeeded() { Cluster cluster = getCluster(); <START> if (cluster.isSetRequiredSwitchType()) { <END> SwitchType defaultSwitchType = DefaultSwitchType.getDefaultSwitchType(cluster.getCompatibilityVersion()); cluster.setRequiredSwitchTypeForCluster(defaultSwitchType); } }</code><technical_language>Negation missing? if (!cluster.isSetRequiredSwitchType()) {</technical_language>

Target:
protected void setDefaultSwitchTypeIfNeeded() { Cluster cluster = getCluster(); if (!cluster.isSetRequiredSwitchType()) { SwitchType defaultSwitchType = DefaultSwitchType.getDefaultSwitchType(cluster.getCompatibilityVersion()); cluster.setRequiredSwitchTypeForCluster(defaultSwitchType); } }
Source:
<code>public void onResponse(okhttp3.Call call, okhttp3.Response response) { HttpResponse azureResponse = new OkHttpResponse(response, request); <START> sink.success(new OkHttpResponse(response, request)); <END> sink.onDispose(azureResponse::close); }</code><technical_language>this azureResponse instead of creating another response instance inline</technical_language>

Target:
public void onResponse(okhttp3.Call call, okhttp3.Response response) { HttpResponse azureResponse = new OkHttpResponse(response, request); OkHttpResponseCloser.trackResponse(azureResponse); sink.success(azureResponse); }