auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void loadAllLookupsAndInitStateRef() { if (!lookupConfig.getDisableLookupSyncOnStartup()) { String tier = lookupListeningAnnouncerConfig.getLookupTier(); List<LookupBean> lookupBeanList = getLookupListFromCoordinator(tier); if (lookupBeanList == null) { LOG.info("Coordinator is unavailable. Loading saved snapshot instead"); lookupBeanList = getLookupListFromSnapshot(); } if (lookupBeanList != null) { ImmutableMap.Builder<String, LookupExtractorFactoryContainer> builder = ImmutableMap.builder(); ListeningScheduledExecutorService executorService = MoreExecutors.listeningDecorator( Executors.newScheduledThreadPool( lookupConfig.getNumLookupLoadingThreads(), Execs.makeThreadFactory("LookupReferencesManager-Startup-%s") ) ); try { List<ListenableFuture<Map.Entry>> futures = new ArrayList<>(); LOG.info("Starting lookup loading process"); for (LookupBean lookupBean : lookupBeanList) { futures.add( executorService.submit( () -> { LookupExtractorFactoryContainer container = lookupBean.getContainer(); LOG.info( <START> "Started lookup [%s]:[%s]", <END> lookupBean.getName(), container ); if (container.getLookupExtractorFactory().start()) { return new AbstractMap.SimpleImmutableEntry<>(lookupBean.getName(), container); } else { LOG.error( "Failed to start lookup [%s]:[%s]", lookupBean.getName(), container ); return null; } } ) ); } final ListenableFuture<List<Map.Entry>> futureList = Futures.allAsList(futures); try { futureList.get() .stream() .filter(Objects::nonNull) .forEach(builder::put); } catch (Exception ex) { futureList.cancel(true); throw ex; } stateRef.set(new LookupUpdateState(builder.build(), ImmutableList.of(), ImmutableList.of())); } catch (Exception e) { LOG.error(e, "Failed to finish lookup load process."); } executorService.shutdownNow(); } else { LOG.info("No lookups to be loaded at this point"); stateRef.set(new LookupUpdateState(ImmutableMap.of(), ImmutableList.of(), ImmutableList.of())); } } else { LOG.info("Lookup loading on startup is disabled"); stateRef.set(new LookupUpdateState(ImmutableMap.of(), ImmutableList.of(), ImmutableList.of())); } }</code><technical_language>s/Started/Starting</technical_language>

Target:
private void loadAllLookupsAndInitStateRef() { List<LookupBean> lookupBeanList = getLookupsListFromLookupConfig(); if (lookupBeanList != null) { startLookups(lookupBeanList); } else { LOG.info("No lookups to be loaded at this point"); stateRef.set(new LookupUpdateState(ImmutableMap.of(), ImmutableList.of(), ImmutableList.of())); } }
Source:
<code>public void testInitialClone_WithAuthenticationNoCredentials() throws Exception { Repository dst = createBareRepository(); assertFalse(dst.hasObject(A_txt)); try (Transport t = Transport.open(dst, authURI)) { t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); fail("Should not have succeeded -- no authentication"); } catch (TransportException e) { String msg = e.getMessage(); assertTrue("Unexpected exception message: " + msg, msg.contains("no CredentialsProvider")); } List<AccessEvent> requests = getRequests(); assertEquals(1, requests.size()); AccessEvent info = requests.get(0); assertEquals("GET", info.getMethod()); assertEquals(401, info.getStatus()); assertNotNull(info.getResponseHeader(HDR_WWW_AUTHENTICATE)); assertTrue(info.getResponseHeader(HDR_WWW_AUTHENTICATE).toLowerCase().startsWith("basic realm=")); <START> <END> }</code><technical_language>remove unnecessary blank line</technical_language>

Target:
public void testInitialClone_WithAuthenticationNoCredentials() throws Exception { Repository dst = createBareRepository(); assertFalse(dst.hasObject(A_txt)); try (Transport t = Transport.open(dst, authURI)) { t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); fail("Should not have succeeded -- no authentication"); } catch (TransportException e) { String msg = e.getMessage(); assertTrue("Unexpected exception message: " + msg, msg.contains("no CredentialsProvider")); } List<AccessEvent> requests = getRequests(); assertEquals(1, requests.size()); AccessEvent info = requests.get(0); assertEquals("GET", info.getMethod()); assertEquals(401, info.getStatus()); assertStartsWithIgnoreCase(info.getResponseHeader(HDR_WWW_AUTHENTICATE), "basic realm="); }
Source:
<code>public boolean createPdpFeedFile(PdpFeedFileBaseEntry pdpFeedFileBaseEntry, String fullyQualifiedPdpFileName) { boolean success = true; try { <START> File pdpFeedFile = getCuMarshalService().marshalObjectToXML(pdpFeedFileBaseEntry, fullyQualifiedPdpFileName); <END> LOG.info("Created PDP Feed file: " + fullyQualifiedPdpFileName); success = true; } catch (JAXBException | IOException e) { LOG.error("createPdpFeedFile.marshalObjectToXML: There was an error marshalling the PDP feed file: " + fullyQualifiedPdpFileName, e); success = false; } return success; }</code><technical_language>If returned File object, avoid assignment this line do marshalObjectToXML() call</technical_language>

Target:
public boolean createPdpFeedFile(PdpFeedFileBaseEntry pdpFeedFileBaseEntry, String fullyQualifiedPdpFileName) { boolean success = true; try { getCuMarshalService().marshalObjectToXML(pdpFeedFileBaseEntry, fullyQualifiedPdpFileName); LOG.info("createPdpFeedFile: Created PDP Feed file: " + fullyQualifiedPdpFileName); success = true; } catch (JAXBException | IOException e) { LOG.error("createPdpFeedFile.marshalObjectToXML: There was an error marshalling the PDP feed file: " + fullyQualifiedPdpFileName, e); success = false; } return success; }
Source:
<code>public static List<String> getAPISecurity(String security){ List<String> apiSecurityList = new ArrayList<>(); if (security != null) { String[] securityList = security.split(","); <START> for (String s : securityList) { <END> if (APIConstants.APPLICATION_LEVEL_SECURITY.contains(s)) { apiSecurityList.add(s); } } } return apiSecurityList; }</code><technical_language>a meaningful name for s? ex: security</technical_language>

Target:
public static List<String> getAPISecurity(String security) { List<String> apiSecurityList = new ArrayList<>(); if (security != null) { String[] securityList = security.split(","); for (String securityType : securityList) { if (APIConstants.APPLICATION_LEVEL_SECURITY.contains(securityType)) { apiSecurityList.add(securityType); } } } return apiSecurityList; }
Source:
<code>private void removeRecentTaskLocked(int userId) { if(userId <= 0) { Slog.i(TAG, "Can't remove recent task on user " + userId); return; } <START> int N = mRecentTasks.size(); for (int i = 0; i < N; i++) { <END> TaskRecord tr = mRecentTasks.get(i); if (tr.userId == userId) { tr.disposeThumbnail(); mRecentTasks.remove(i); Slog.i(TAG, "remove RecentTask " + userId); i--; N--; } } }</code><technical_language>order of mRecentTasks matter please change pattern: for (int i = mRecentTasks.size() - 1; i >= 0; --i) { ... } advantage is need N need adjustments i N removing entry</technical_language>

Target:
private void removeRecentTaskLocked(int userId) { if(userId <= 0) { Slog.i(TAG, "Can't remove recent task on user " + userId); return; } for (int i = mRecentTasks.size() - 1; i >= 0; --i) { TaskRecord tr = mRecentTasks.get(i); if (tr.userId == userId) { if(DEBUG_TASKS) Slog.i(TAG, "remove RecentTask " + tr + " when finishing user" + userId); tr.disposeThumbnail(); mRecentTasks.remove(i); } } }
Source:
<code>private SearchResponse getScrollResponse(ElasticsearchQueryBuilder queryBuilder, String scrollId) { try { return retry() .maxAttempts(maxAttempts) .exponentialBackoff(maxRetryTime, 2.0) .run("scrollRequest", () -> { return queryBuilder.prepareSearchScroll(scrollId) .execute() .actionGet(requestTimeout.toMillis()); }); } <START> catch (InterruptedException e) { <END> Thread.currentThread().interrupt(); throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } }</code><technical_language>ditto InterruptedException</technical_language>

Target:
private SearchResponse getScrollResponse(ElasticsearchQueryBuilder queryBuilder, String scrollId) { try { return retry() .maxAttempts(maxAttempts) .exponentialBackoff(maxRetryTime) .run("scrollRequest", () -> queryBuilder.prepareSearchScroll(scrollId) .execute() .actionGet(requestTimeout.toMillis())); } catch (Exception e) { throw new RuntimeException(e); } }
Source:
<code>public ConfigurationClientBuilder httpClient(HttpClient client) { <START> this.httpClient = client; <END> return this; }</code><technical_language>reason of removing null checking</technical_language>

Target:
public ConfigurationClientBuilder httpClient(HttpClient client) { if (this.httpClient != null && client == null) { logger.info("HttpClient is being set to 'null' when it was previously configured."); } this.httpClient = client; return this; }
Source:
<code><START> public ReadOnlyDictionaryInterface getDictionary(int index) { <END> return (ReadOnlyDictionaryInterface) fleeceValueToObject(index); }</code><technical_language>return ReadOnlyDictionary ReadOnlyDictionaryInterface. IIRC, ReadOnlyDictionaryInterface is internal for Java</technical_language>

Target:
public ReadOnlyDictionary getDictionary(int index) { return (ReadOnlyDictionary) fleeceValueToObject(index); }
Source:
<code>public void deleteBucketAcl() throws IOException, SignatureException { PutBucketAclForUserSpectraS3Response putBucketAclForUserSpectraS3Response = null; <START> putBucketAclForUserSpectraS3Response = client.putBucketAclForUserSpectraS3( <END> new PutBucketAclForUserSpectraS3Request(BUCKET_NAME, BucketAclPermission.DELETE, spectraUUID)); final DeleteBucketAclSpectraS3Response deleteBucketAclSpectraS3Response = client .deleteBucketAclSpectraS3(new DeleteBucketAclSpectraS3Request( putBucketAclForUserSpectraS3Response.getBucketAclResult().getId().toString())); assertThat(deleteBucketAclSpectraS3Response.getStatusCode(), is(204)); }</code><technical_language>is need for null initialization. lines combined, variable putBucketAclForUserSpectraS3Response final</technical_language>

Target:
public void deleteBucketAcl() throws IOException, SignatureException { final PutBucketAclForUserSpectraS3Response putBucketAclForUserSpectraS3Response = client.putBucketAclForUserSpectraS3( new PutBucketAclForUserSpectraS3Request(BUCKET_NAME, BucketAclPermission.DELETE, spectraUUID)); final DeleteBucketAclSpectraS3Response deleteBucketAclSpectraS3Response = client .deleteBucketAclSpectraS3(new DeleteBucketAclSpectraS3Request( putBucketAclForUserSpectraS3Response.getBucketAclResult().getId().toString())); assertThat(deleteBucketAclSpectraS3Response.getStatusCode(), is(204)); }
Source:
<code>public void sendNotification(URL resetUrl, ILocalAccountPerson account, Locale locale) { <START> log.debug("Sending password reset instructions to user with url " + resetUrl.toString()); <END> List<String> recipients = getRecipientAddresses(account); String subject = formatSubject(account, locale); String body = formatBody(resetUrl, account, locale); try { MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); for (String recipient : recipients) { helper.addTo(recipient); } helper.setText(body, true); helper.setSubject(subject); helper.setFrom(portalEmailAddress, messageSource.getMessage("portal.name", new Object[]{}, locale)); log.debug("Sending message to " + recipients + " from " + Arrays.toString(message.getFrom()) + " subject " + message.getSubject()); this.mailSender.send(helper.getMimeMessage()); } catch(MailException | MessagingException | UnsupportedEncodingException e) { log.error("Unable to send password reset email ", e); } }</code><technical_language>slf4j this logger.debug("Sending password reset instructions user url {}.", resetUrl);</technical_language>

Target:
public void sendNotification(URL resetUrl, ILocalAccountPerson account, Locale locale) { log.debug("Sending password reset instructions to user with url {}", resetUrl.toString()); try { MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); String email = (String)account.getAttributeValue(ILocalAccountPerson.ATTR_MAIL); String subject = messageSource.getMessage(subjectMessageKey, new Object[]{}, locale); String body = formatBody(resetUrl, account, locale); helper.addTo(email); helper.setText(body, true); helper.setSubject(subject); helper.setFrom(portalEmailAddress, messageSource.getMessage("portal.name", new Object[]{}, locale)); log.debug("Sending message to from subject {}", email, Arrays.toString(message.getFrom()), message.getSubject()); this.mailSender.send(helper.getMimeMessage()); } catch(Exception e) { log.error("Unable to send password reset email", e); } }
Source:
<code>protected void emit(String tuple) { output.emit(tuple); byte[] bytes = tuple.getBytes(); byteOutput.emit(bytes); <START> } <END></code><technical_language>byteOutput.emit(tuple.getBytes())</technical_language>

Target:
protected void emit(String tuple) { output.emit(tuple); byteOutput.emit(tuple.getBytes()); }
Source:
<code>private Collection<ResourceLocator> getRatesCurvesResources() { return getAllResources(CURVES_DIR).stream() <START> .filter(res -> <END> !res.getLocator().endsWith(CURVES_GROUPS_FILE) && !res.getLocator().endsWith(CURVES_SETTINGS_FILE)) .collect(Collectors.toList()); }</code><technical_language>split filter calls for readabilty: .filter(res -> !res.getLocator().endsWith(CURVES_GROUPS_FILE)) .filter(res -> !res.getLocator().endsWith(CURVES_SETTINGS_FILE))</technical_language>

Target:
private Collection<ResourceLocator> getRatesCurvesResources() { return getAllResources(CURVES_DIR).stream() .filter(res -> !res.getLocator().endsWith(CURVES_GROUPS_FILE)) .filter(res -> !res.getLocator().endsWith(CURVES_SETTINGS_FILE)) .collect(toImmutableList()); }
Source:
<code>public static String doRequestGet(String url, Bundle params) { String newUrl = null; if (params != null) { StringBuilder sb = new StringBuilder(); sb.append(url).append('?'); boolean first = true; for (String key : params.keySet()) { if (!first) { sb.append('&'); } else { first = false; } sb.append(URLEncoder.encode(key)).append('=').append(URLEncoder.encode(params.getString(key))); } newUrl = sb.toString(); } HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, CONNECTION_TIME_OUT); HttpConnectionParams.setSoTimeout(httpParameters, SOCKET_TIME_OUT); try { <START> HttpGet httpRequest = new HttpGet(newUrl); <END> HttpResponse httpResponse = new DefaultHttpClient(httpParameters).execute(httpRequest); if (httpResponse.getStatusLine().getStatusCode() == SUCCESS_STATUS) { return EntityUtils.toString(httpResponse.getEntity()); } else { LogUtils.logD("Http response error when do get operation!"); } } catch (Exception e) { LogUtils.logE(e.getMessage()); } return null; }</code><technical_language>If params is null, newUrl null. If params is empty, newUrl "url?". ok</technical_language>

Target:
public static String doRequestGet(String url, Bundle params) { String newUrl = url; if (params != null && !params.isEmpty()) { StringBuilder sb = new StringBuilder(); sb.append(url).append('?'); boolean first = true; for (String key : params.keySet()) { if (!first) { sb.append('&'); } else { first = false; } sb.append(URLEncoder.encode(key)).append('=').append(URLEncoder.encode(params.getString(key))); } newUrl = sb.toString(); } HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, CONNECTION_TIME_OUT); HttpConnectionParams.setSoTimeout(httpParameters, SOCKET_TIME_OUT); try { HttpGet httpRequest = new HttpGet(newUrl); HttpResponse httpResponse = new DefaultHttpClient(httpParameters).execute(httpRequest); if (httpResponse.getStatusLine().getStatusCode() == SUCCESS_STATUS) { return EntityUtils.toString(httpResponse.getEntity()); } else { LogUtils.logD("Http response error when do get operation!"); } } catch (Exception e) { LogUtils.logE(e.getMessage()); } return null; }
Source:
<code>private List<Ability> cardPlayableAbilities(Game game, Card card, boolean setControllerId) { List<Ability> playable = new ArrayList(); if (card != null) { for (ActivatedAbility ability : card.getAbilities().getActivatedAbilities(Zone.HAND)) { if (setControllerId) { ability.setControllerId(getId()); } if (ability instanceof SpellAbility && null != game.getContinuousEffects().asThough(card.getId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, ability, getId(), game)) { playable.add(ability); } else if (ability instanceof PlayLandAbility && null != game.getContinuousEffects().asThough(card.getId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, card.getSpellAbility(), getId(), game)) { playable.add(ability); } if (setControllerId) { ability.setControllerId(card.getOwnerId()); <START> } <END> } } return playable; }</code><technical_language>Yes, restore controllerId value, ownerId</technical_language>

Target:
private List<Ability> cardPlayableAbilities(Game game, Card card, boolean setControllerId) { List<Ability> playable = new ArrayList(); if (card != null) { for (ActivatedAbility ability : card.getAbilities().getActivatedAbilities(Zone.HAND)) { if (!ability.canActivate(playerId, game).canActivate()) { continue; } UUID savedControllerId = null; if (setControllerId) { savedControllerId = getId(); ability.setControllerId(getId()); } if (ability instanceof SpellAbility && null != game.getContinuousEffects().asThough(card.getId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, ability, getId(), game)) { playable.add(ability); } else if (ability instanceof PlayLandAbility && null != game.getContinuousEffects().asThough(card.getId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, card.getSpellAbility(), getId(), game)) { playable.add(ability); } if (setControllerId) { ability.setControllerId(savedControllerId); } } } return playable; }
Source:
<code>public void apply(String endpointId, GitCheckoutEventDto dto) { final Type type = dto.getType(); final String name = dto.getName(); switch (type) { case BRANCH: { Log.debug(getClass(), "Received git branch checkout event: " + name); final NotificationManager notificationManager = notificationManagerProvider.get(); if (notificationManager != null) { notificationManager.notify("Git operation", "Branch '" + name + "' is checked out", SUCCESS, EMERGE_MODE); } break; } case REVISION: { Log.debug(getClass(), "Received git revision checkout event: " + name); final NotificationManager notificationManager = notificationManagerProvider.get(); if (notificationManager != null) { notificationManager.notify("Git operation", "Revision '" + name + "' is checked out", SUCCESS, EMERGE_MODE); } break; } } <START> resourceManagerFactory.newResourceManager(appContext.getDevMachine()).getWorkspaceProjects(); <END> }</code><technical_language>appContext.getWorkspaceRoot().synchronize(); instead of this construction. org.eclipse.che.ide.resources.impl.ResourceManager.ResourceManagerFactory internal factory create a new instance of Resource Manager update existing state</technical_language>

Target:
public void apply(String endpointId, GitCheckoutEventDto dto) { final Type type = dto.getType(); final String name = dto.getName(); switch (type) { case BRANCH: { Log.debug(getClass(), "Received git branch checkout event: " + name); final NotificationManager notificationManager = notificationManagerProvider.get(); if (notificationManager != null) { notificationManager.notify("Git operation", "Branch '" + name + "' is checked out", SUCCESS, EMERGE_MODE); } break; } case REVISION: { Log.debug(getClass(), "Received git revision checkout event: " + name); final NotificationManager notificationManager = notificationManagerProvider.get(); if (notificationManager != null) { notificationManager.notify("Git operation", "Revision '" + name + "' is checked out", SUCCESS, EMERGE_MODE); } break; } } appContext.getWorkspaceRoot().synchronize(); }
Source:
<code>public int compareTo(CohortMembership o) { if (Objects.equals(this.getPatient().getPatientId(), o.getPatient().getPatientId()) && Objects.equals(this.getCohort().getCohortId(), o.getCohort().getCohortId()) && this.getStartDate().equals(o.getStartDate()) && ((this.getEndDate() != null && o.getEndDate() != null && this.getEndDate().equals(o.getEndDate())) || (this.getEndDate() == null && o.getEndDate() == null))) { return 0; } else if ((this.isMembershipActive() && !o.isMembershipActive()) <START> || (!this.isMembershipActive() && o.isMembershipActive())) { <END> return 1; } else { return -1; } }</code><technical_language>need push voided memberships end of list, i.e. if this membership is active other is inactive, return -1</technical_language>

Target:
public int compareTo(CohortMembership o) { int ret = -1; if (Objects.equals(this.getPatientId(), o.getPatientId()) && Objects.equals(this.getCohort().getCohortId(), o.getCohort().getCohortId()) && this.getStartDate().equals(o.getStartDate()) && OpenmrsUtil.compare(this.getStartDate(), o.getStartDate()) == 0 && ((this.getEndDate() != null && o.getEndDate() != null && OpenmrsUtil.compare(this.getEndDate(), o.getEndDate()) == 0) || (this.getEndDate() == null && o.getEndDate() == null))) { ret = 0; } else if (this.isActive() && !o.isActive()) { ret = -1; } else if (!this.isActive() && o.isActive()) { ret = 1; } return ret; }
Source:
<code>public APIResult submitExtensionJob(final String extensionName, final String jobName, final String configPath, final String doAsUser) { InputStream configStream = getServletInputStream(configPath); <START> if (!validateExtension(extensionName, jobName, configStream)) { <END> return null; } ClientResponse clientResponse = new ResourceBuilder() .path(ExtensionOperations.SUBMIT.path, extensionName) .addQueryParam(DO_AS_OPT, doAsUser) .call(ExtensionOperations.SUBMIT, configStream); return getResponse(APIResult.class, clientResponse); }</code><technical_language>validation is done client server end. Client need call it. server side validations suffice</technical_language>

Target:
public APIResult submitExtensionJob(final String extensionName, final String jobName, final String configPath, final String doAsUser) { FormDataMultiPart entitiesForm = getEntitiesForm(extensionName, jobName, configPath); ClientResponse clientResponse = new ResourceBuilder() .path(ExtensionOperations.SUBMIT.path, extensionName) .addQueryParam(DO_AS_OPT, doAsUser) .addQueryParam(JOB_NAME_OPT, jobName) .call(ExtensionOperations.SUBMIT, entitiesForm); return getResponse(APIResult.class, clientResponse); }
Source:
<code>public void scanFile(XmlCheckContext context) { try { NodeList interceptorBindings = context.evaluateXPathExpression("ejb-jar/assembly-descriptor/interceptor-binding"); for (int i = 0; i < interceptorBindings.getLength(); i++) { Node interceptorBinding = interceptorBindings.item(i); if (!isDefaultInterceptor(context, interceptorBinding)) { checkExclusions(context, interceptorBinding); } } } catch (XPathExpressionException e) { <START> throw new IllegalArgumentException("[S3282] Unable evaluate xpath expression for file " + context.getFile().getAbsolutePath(), e); <END> } }</code><technical_language>illegal argument ??</technical_language>

Target:
public void scanFile(XmlCheckContext context) { try { NodeList interceptorBindings = context.evaluateXPathExpression("ejb-jar/assembly-descriptor/interceptor-binding"); for (int i = 0; i < interceptorBindings.getLength(); i++) { Node interceptorBinding = interceptorBindings.item(i); if (!isDefaultInterceptor(context, interceptorBinding)) { checkExclusions(context, interceptorBinding); } } } catch (XPathExpressionException e) { throw new AnalysisException("[S3282] Unable evaluate xpath expression for file " + context.getFile().getAbsolutePath(), e); } }
Source:
<code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.login_site_address_screen, container, false); mSiteAddressEditText = (EditText) rootView.findViewById(R.id.login_site_address); mSiteAddressEditText.addTextChangedListener(this); mSiteAddressTextLayout = (TextInputLayout) rootView.findViewById(R.id.login_site_address_layout); mNextButton = (Button) rootView.findViewById(R.id.login_next_button); mNextButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { discover(); } }); mSiteAddressEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event != null && event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { discover(); } return true; } }); rootView.findViewById(R.id.login_site_address_help).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { <START> if (mLoginListener != null) { <END> showSiteAddressHelp(); } } }); return rootView; }</code><technical_language>is mLoginListener checked here</technical_language>

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.login_site_address_screen, container, false); mSiteAddressEditText = (EditText) rootView.findViewById(R.id.login_site_address); mSiteAddressEditText.addTextChangedListener(this); mSiteAddressTextLayout = (TextInputLayout) rootView.findViewById(R.id.login_site_address_layout); mNextButton = (Button) rootView.findViewById(R.id.login_next_button); mNextButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { discover(); } }); mSiteAddressEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event != null && event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { discover(); } return true; } }); rootView.findViewById(R.id.login_site_address_help).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showSiteAddressHelp(); } }); return rootView; }
Source:
<code>public boolean checkMoment(Date date) { if (calendar != null) { <START> Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 1)); <END> Rule<Component> periodRule = new PeriodRule<Component>(period); Filter<CalendarComponent> filter = new Filter<CalendarComponent>(new Rule[] {periodRule}, Filter.MATCH_ANY); Collection<CalendarComponent> events = filter.filter(calendar.getComponents(Component.VEVENT)); if (events != null && !events.isEmpty()) { return true; } } return false; }</code><technical_language>If understanding correctly, this check a period, right? Is a check a single point in time</technical_language>

Target:
public boolean checkMoment(Date date) { if (calendar != null) { Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0)); Rule<Component> periodRule = new PeriodRule<Component>(period); Filter<CalendarComponent> filter = new Filter<CalendarComponent>(new Rule[] {periodRule}, Filter.MATCH_ANY); Collection<CalendarComponent> events = filter.filter(calendar.getComponents(Component.VEVENT)); if (events != null && !events.isEmpty()) { return true; } } return false; }
Source:
<code>public void customRotators_correctlyIgnored() throws IOException, InterruptedException { FreeStyleProject project = j.createFreeStyleProject(); project.setBuildDiscarder( mockCustomRotator1 ); LogRotatorConfiguration config = GlobalConfiguration.all().get( LogRotatorConfiguration.class ); assertNotNull( config ); config.setPolicyForJobsWithCustomLogRotator( LogRotationPolicy.NONE ); <START> config.setGlobalLogRotators(Arrays.asList( new LogRotatorMapping[] { <END> catchallGlobalMapping })); task.execute( listener ); verify( mockCustomRotator1, never() ) .perform( project ); verify( mockCatchallGlobalRotator, never() ) .perform( project ); }</code><technical_language>IIRC need construct array Arrays.asList is variadic</technical_language>

Target:
public void customRotators_correctlyIgnored() throws IOException, InterruptedException { FreeStyleProject project = j.createFreeStyleProject(); project.setBuildDiscarder( mockCustomRotator1 ); LogRotatorConfiguration config = GlobalConfiguration.all().get( LogRotatorConfiguration.class ); assertNotNull( config ); config.setPolicyForJobsWithCustomLogRotator( LogRotationPolicy.NONE ); config.setGlobalLogRotators(Arrays.asList( catchallGlobalMapping )); task.execute( listener ); verify( mockCustomRotator1, never() ) .perform( project ); verify( mockCatchallGlobalRotator, never() ) .perform( project ); }
Source:
<code>public static boolean isTestModeEnabled(Context context, Network network) { ConnectivityManager connectManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkCapabilities networkCapabilities = connectManager.getNetworkCapabilities(network); <START> if (networkCapabilities == null) { return false; } return networkCapabilities.hasCapability(NETWORK_CAPABILITY_TRANSPORT_TEST); <END> }</code><technical_language>This simplified to: return networkCapabilities != null && networkCapabilities.hasCapability(...)</technical_language>

Target:
public static boolean isTestModeEnabled(Context context, Network network) { ConnectivityManager connectManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkCapabilities networkCapabilities = connectManager.getNetworkCapabilities(network); return networkCapabilities != null && networkCapabilities.hasCapability(NETWORK_CAPABILITY_TRANSPORT_TEST); }
Source:
<code>public String getAddress( final double latitude, final double longitude, final ReverseGeocoderCallback callback) { if (cache != null) { String cachedAddress = cache.get(new AbstractMap.SimpleImmutableEntry<>(latitude, longitude)); if (cachedAddress != null) { if (callback != null) { callback.onSuccess(cachedAddress); } return cachedAddress; } } String urlFormat = String.format(url, latitude, longitude); boolean isAutoNavi = url.contains("restapi.amap.com/v3/geocode/regeo"); if (isAutoNavi){ <START> urlFormat = String.format(url, longitude, latitude); <END> } Invocation.Builder request = Context.getClient().target(urlFormat).request(); if (callback != null) { request.async().get(new InvocationCallback<JsonObject>() { @Override public void completed(JsonObject json) { handleResponse(latitude, longitude, json, callback); } @Override public void failed(Throwable throwable) { callback.onFailure(throwable); } }); } else { try { return handleResponse(latitude, longitude, request.get(JsonObject.class), null); } catch (ClientErrorException e) { LOGGER.warn("Geocoder network error", e); } } return null; }</code><technical_language>I see, solution is generic. need better</technical_language>

Target:
public String getAddress( final double latitude, final double longitude, final ReverseGeocoderCallback callback) { if (cache != null) { String cachedAddress = cache.get(new AbstractMap.SimpleImmutableEntry<>(latitude, longitude)); if (cachedAddress != null) { if (callback != null) { callback.onSuccess(cachedAddress); } return cachedAddress; } } String urlFormat = String.format(url, latitude, longitude); if (requestLocationReverse){ urlFormat = String.format(url, longitude, latitude); } Invocation.Builder request = Context.getClient().target(urlFormat).request(); if (callback != null) { request.async().get(new InvocationCallback<JsonObject>() { @Override public void completed(JsonObject json) { handleResponse(latitude, longitude, json, callback); } @Override public void failed(Throwable throwable) { callback.onFailure(throwable); } }); } else { try { return handleResponse(latitude, longitude, request.get(JsonObject.class), null); } catch (ClientErrorException e) { LOGGER.warn("Geocoder network error", e); } } return null; }
Source:
<code>void print(PropertyInfo prop, Printer printer) throws Exception { if (prop.isCustomMapped()) { for (PPath p : prop.locations) { p.replaceBy(new APath(new TId(prop.object.customMappingAlias + "." + prop.name))); } } else { String className = prop.getType(); if (className != null) { prop.alias = printer.getContext().getAliasGenerator().generate(prop.object.alias + "_" + prop.name); printer.from.append(", ").append(className).append(" as ").append(prop.alias); if (className.endsWith("DBStringListProperty")) { printer.from.append(" join ").append(prop.alias).append(".").append(prop.getValueField()) .append(" ").append(prop.alias + prop.getValueField()); } printer.where.append(" and ").append(prop.alias).append(".id.id=").append(prop.object.alias) .append(".id").append(" and ").append(prop.alias).append(".id.name").append("='").append(prop.name) .append("'"); for (PPath p : prop.locations) { String s = prop.alias + "." + prop.getValueField(); if (className.endsWith("DBStringListProperty") && ( p.parent() instanceof PSelectExpression || <START> p.parent().parent() instanceof POrderbyItem || <END> p.parent().parent() instanceof PGroupbyItem)) { s = prop.alias + prop.getValueField(); } p.replaceBy(new APath(new TId(s))); } } } }</code><technical_language>this lead a NPE? is p.parent() p.parent().parent() is null</technical_language>

Target:
void print(PropertyInfo prop, Printer printer) throws Exception { if (prop.isCustomMapped()) { for (PPath p : prop.locations) { p.replaceBy(new APath(new TId(prop.object.customMappingAlias + "." + prop.name))); } } else { String className = prop.getType(); if (className != null) { prop.alias = printer.getContext().getAliasGenerator().generate(prop.object.alias + "_" + prop.name); printer.from.append(", ").append(className).append(" as ").append(prop.alias); if (className.endsWith("DBStringListProperty")) { printer.from.append(" join ").append(prop.alias).append(".").append(prop.getValueField()) .append(" ").append(prop.alias + prop.getValueField()); } printer.where.append(" and ").append(prop.alias).append(".id.id=").append(prop.object.alias) .append(".id").append(" and ").append(prop.alias).append(".id.name").append("='").append(prop.name) .append("'"); for (PPath p : prop.locations) { String s = prop.alias + "." + prop.getValueField(); if (className.endsWith("DBStringListProperty") && p.parent() != null && ( p.parent() instanceof PSelectExpression || p.parent().parent() instanceof POrderbyItem || p.parent().parent() instanceof PGroupbyItem)) { s = prop.alias + prop.getValueField(); } p.replaceBy(new APath(new TId(s))); } } } }
Source:
<code>public CircuitBreakerRegistry circuitBreakerRegistry(EventConsumerRegistry<CircuitBreakerEvent> eventConsumerRegistry) { CircuitBreakerRegistry circuitBreakerRegistry = CircuitBreakerRegistry.ofDefaults(); circuitBreakerConfiguration.registerPostCreationEventConsumer(circuitBreakerRegistry, eventConsumerRegistry); circuitBreakerRegistry.registerPostCreationConsumer((circuitBreaker, config) -> createHeathIndicatorForCircuitBreaker(circuitBreaker, config)); <START> <END> circuitBreakerConfiguration.initializeBackends(circuitBreakerRegistry, eventConsumerRegistry); return circuitBreakerRegistry; }</code><technical_language>method reference this::createHeathIndicatorForCircuitBreaker</technical_language>

Target:
public CircuitBreakerRegistry circuitBreakerRegistry(EventConsumerRegistry<CircuitBreakerEvent> eventConsumerRegistry) { CircuitBreakerRegistry circuitBreakerRegistry = CircuitBreakerRegistry.ofDefaults(); circuitBreakerConfiguration.registerPostCreationEventConsumer(circuitBreakerRegistry, eventConsumerRegistry); circuitBreakerRegistry.registerPostCreationConsumer(this::createHeathIndicatorForCircuitBreaker); circuitBreakerConfiguration.initializeBackends(circuitBreakerRegistry); return circuitBreakerRegistry; }
Source:
<code>public static String getNewUniqueName(DataSource original) { String uniqueName; int index = 0; SourceManager sm = Services.getService(DataManager.class) .getSourceManager(); uniqueName = original.getName() + "_selection"; while (sm.getSource(uniqueName) != null) { index++; <START> uniqueName = original.getName() + "_selection_" + index; <END> } return uniqueName; }</code><technical_language>translate _selection_</technical_language>

Target:
private static String getNewUniqueName(DataSource original) { String uniqueName; int index = 0; SourceManager sm = Services.getService(DataManager.class) .getSourceManager(); uniqueName = I18N.tr("{0}_selection", original.getName()); while (sm.getSource(uniqueName) != null) { index++; uniqueName = I18N.tr("{0}_selection_{1}", original.getName(), index); } return uniqueName; }
Source:
<code>private List<Class<? extends Vfs.UrlType>> findExtensions() { final List<Class<? extends Vfs.UrlType>> extensions = new ArrayList<>(); for (final URL url : getErraiAppPropertiesFilesUrls()) { InputStream inputStream = null; try { inputStream = url.openStream(); final ResourceBundle props = new PropertyResourceBundle(inputStream); for (final Object o : props.keySet()) { final String key = (String) o; if (key.equals(EXTENSION_KEY)) { final String clsName = props.getString(key); try { final Class<?> aClass = Thread.currentThread().getContextClassLoader().loadClass(clsName); extensions.add(aClass.asSubclass(Vfs.UrlType.class)); } catch (final Throwable t) { <START> throw new RuntimeException("could not load class scanning extension: " + clsName, t); <END> } } } } catch (final IOException e) { throw new RuntimeException("error reading ErraiApp.properties", e); } finally { if (inputStream != null) { try { inputStream.close(); } catch (final IOException e) { } } } } return extensions; }</code><technical_language>This change caught eye unrelated. motivation here</technical_language>

Target:
private List<Class<? extends Vfs.UrlType>> findExtensions() { final List<Class<? extends Vfs.UrlType>> extensions = new ArrayList<>(); for (final URL url : getErraiAppPropertiesFilesUrls()) { InputStream inputStream = null; try { inputStream = url.openStream(); final ResourceBundle props = new PropertyResourceBundle(inputStream); for (final Object o : props.keySet()) { final String key = (String) o; if (key.equals(EXTENSION_KEY)) { final String clsName = props.getString(key); try { final Class<?> aClass = Thread.currentThread().getContextClassLoader().loadClass(clsName); extensions.add(aClass.asSubclass(Vfs.UrlType.class)); } catch (final Throwable t) { log.warn("could not load class scanning extension: " + clsName, t); } } } } catch (final IOException e) { throw new RuntimeException("error reading ErraiApp.properties", e); } finally { if (inputStream != null) { try { inputStream.close(); } catch (final IOException e) { } } } } return extensions; }
Source:
<code>public void loadUsageRecipes(ItemStack ingredient) { if (ingredient.getItem() == Items.potionitem || ingredients.contains(ingredient)) for (NEIBrewingRecipe recipe : apotions) if (NEIServerUtils.areStacksSameType(recipe.ingredient.item, ingredient) || NEIServerUtils.areStacksSameType(recipe.input.item, ingredient)) arecipes.add(new CachedBrewingRecipe(recipe)); label0: for (IBrewingRecipe recipe : BrewingRecipeRegistry.getRecipes()) if (recipe instanceof BrewingRecipe || recipe instanceof BrewingOreRecipe) <START> if (NEIServerUtils.areStacksSameType(((AbstractBrewingRecipe<?>) recipe).input, ingredient)) <END> arecipes.add(new CachedBrewingRecipe((AbstractBrewingRecipe<?>) recipe)); else { ItemStack[] recipeIngredients = NEIServerUtils.extractRecipeItems(((AbstractBrewingRecipe<?>) recipe).ingredient); for (ItemStack recipeIngredient : recipeIngredients) if (NEIServerUtils.areStacksSameType(recipeIngredient, ingredient)) { arecipes.add(new CachedBrewingRecipe((AbstractBrewingRecipe<?>) recipe)); continue label0; } } }</code><technical_language>AbstractBrewingRecipe<?> cast is done 4 times, a bit verbose, a local variable, named arecipe</technical_language>

Target:
public void loadUsageRecipes(ItemStack ingredient) { if (ingredient.getItem() == Items.potionitem || ingredients.contains(ingredient)) for (NEIBrewingRecipe recipe : apotions) if (NEIServerUtils.areStacksSameType(recipe.ingredient.item, ingredient) || NEIServerUtils.areStacksSameType(recipe.input.item, ingredient)) arecipes.add(new CachedBrewingRecipe(recipe)); nextRecipe: for (IBrewingRecipe recipe : BrewingRecipeRegistry.getRecipes()) if (recipe instanceof BrewingRecipe || recipe instanceof BrewingOreRecipe) { AbstractBrewingRecipe<?> arecipe = (AbstractBrewingRecipe<?>) recipe; if (NEIServerUtils.areStacksSameType(arecipe.input, ingredient)) arecipes.add(new CachedBrewingRecipe(arecipe)); else { ItemStack[] recipeIngredients = NEIServerUtils.extractRecipeItems(arecipe.ingredient); for (ItemStack recipeIngredient : recipeIngredients) if (NEIServerUtils.areStacksSameType(recipeIngredient, ingredient)) { arecipes.add(new CachedBrewingRecipe(arecipe)); continue nextRecipe; } } } }
Source:
<code>private void displayKeyBinding(KeyCode key, int y) { Vec2d pos = keymap.get(key); if (pos == null) { return; } GraphicsContext gc = keyboard.getGraphicsContext2D(); <START> gc.strokeLine(pos.x / 2 + 18, pos.y / 2 + 18, <END> 850, y + 8); Image img = Preloader.getImageOrLoad("keyboard.png"); gc.drawImage(img, pos.x, pos.y, 72, 72, pos.x / 2, pos.y / 2, 36, 36); }</code><technical_language>Put line. java gc.strokeLine(pos.x / 2 + 18, pos.y / 2 + 18, 850, y + 8); <layout</technical_language>

Target:
private void displayKeyBinding(KeyCode key, int y) { Vec2d pos = KEYMAP.get(key); if (pos == null) { return; } GraphicsContext gc = keyboard.getGraphicsContext2D(); gc.strokeLine(pos.x / 2 + 18, pos.y / 2 + 18, 850, y + 8); Image img = Preloader.getImageOrLoad("keyboard.png"); gc.drawImage(img, pos.x, pos.y, 72, 72, pos.x / 2, pos.y / 2, 36, 36); }
Source:
<code>protected DataSetReadyCallback createDataSetTaskCallback(final int startRange, final FilterSettings tableSettings) { return new AbstractDataSetReadyCallback(errorPopup, view, tableSettings.getUUID()) { @Override public void callback(DataSet dataSet) { if (dataSet != null && dataSetQueryHelper.getCurrentTableSettings().getKey().equals(tableSettings.getKey())) { final List<TaskSummary> myTasksFromDataSet = new ArrayList<TaskSummary>(); for (int i = 0; i < dataSet.getRowCount(); i++) { if(HUMAN_TASKS_WITH_ADMIN_DATASET.equals(dataSet.getUUID())) { myTasksFromDataSet.add(new TaskAdminSummaryDataSetMapper().apply(dataSet, <START> i)); <END> }else { myTasksFromDataSet.add(new TaskSummaryDataSetMapper().apply(dataSet, i)); } } boolean lastPageExactCount = false; if (dataSet.getRowCount() < view.getListGrid().getPageSize()) { lastPageExactCount = true; } List<DataSetOp> ops = tableSettings.getDataSetLookup().getOperationList(); String filterValue = isFilteredByTaskName(ops); if (AbstractMultiGridView.TAB_SEARCH.equals(tableSettings.getKey()) == false && filterValue != null) { getDomainSpecifDataForTasks(startRange, filterValue, myTasksFromDataSet, lastPageExactCount); } else { updateDataOnCallback(myTasksFromDataSet, startRange, startRange + myTasksFromDataSet.size(), lastPageExactCount); } } view.hideBusyIndicator(); } @Override public boolean onError(final ClientRuntimeError error) { view.hideBusyIndicator(); showErrorPopup(Constants.INSTANCE.TaskListCouldNotBeLoaded()); return false; } }; }</code><technical_language>argument of _apply_ method is aligned argument</technical_language>

Target:
protected DataSetReadyCallback createDataSetTaskCallback(final int startRange, final FilterSettings tableSettings) { return new AbstractDataSetReadyCallback(errorPopup, view, tableSettings.getUUID()) { @Override public void callback(DataSet dataSet) { if (dataSet != null && dataSetQueryHelper.getCurrentTableSettings().getKey().equals(tableSettings.getKey())) { final List<TaskSummary> myTasksFromDataSet = new ArrayList<TaskSummary>(); for (int i = 0; i < dataSet.getRowCount(); i++) { myTasksFromDataSet.add(new TaskSummaryDataSetMapper().apply(dataSet, i)); } boolean lastPageExactCount = false; if (dataSet.getRowCount() < view.getListGrid().getPageSize()) { lastPageExactCount = true; } List<DataSetOp> ops = tableSettings.getDataSetLookup().getOperationList(); String filterValue = isFilteredByTaskName(ops); if (AbstractMultiGridView.TAB_SEARCH.equals(tableSettings.getKey()) == false && filterValue != null) { getDomainSpecifDataForTasks(startRange, filterValue, myTasksFromDataSet, lastPageExactCount); } else { updateDataOnCallback(myTasksFromDataSet, startRange, startRange + myTasksFromDataSet.size(), lastPageExactCount); } } view.hideBusyIndicator(); } @Override public boolean onError(final ClientRuntimeError error) { view.hideBusyIndicator(); showErrorPopup(Constants.INSTANCE.TaskListCouldNotBeLoaded()); return false; } }; }
Source:
<code>public String generateRandomNoForDisplayId() { int discrepancyNoteLength; try { discrepancyNoteLength = Integer.parseInt(CoreResources.getField("dicrepancyNote.DisplayId.GenerationLength")); <START> if (discrepancyNoteLength <= 0 || discrepancyNoteLength > 9) { <END> discrepancyNoteLength = 9; logger.error("Maximum DiscrepancyNoteLength is 9"); } }catch (Exception e){ discrepancyNoteLength = 9; logger.error("Error fetching DiscrepancyNoteLength from properties file"); } int max = (int) Math.pow(10, discrepancyNoteLength); return StringUtils.leftPad(Integer.toString(RandomUtils.nextInt(0, max)), discrepancyNoteLength, '0'); }</code><technical_language>store default 9 in a private static final variable referencing multiple times</technical_language>

Target:
public String generateRandomNoForDisplayId() { int discrepancyNoteLength; try { discrepancyNoteLength = Integer.parseInt(CoreResources.getField("discrepancyNote.displayId.length")); if (discrepancyNoteLength <= 0 || discrepancyNoteLength > DEFAULT_DISCREPANCY_NOTE_DISPLAYID_LENGTH) { discrepancyNoteLength = DEFAULT_DISCREPANCY_NOTE_DISPLAYID_LENGTH; logger.error("Maximum DiscrepancyNoteLength is "+DEFAULT_DISCREPANCY_NOTE_DISPLAYID_LENGTH); } }catch (Exception e){ discrepancyNoteLength = DEFAULT_DISCREPANCY_NOTE_DISPLAYID_LENGTH; logger.error("Error fetching DiscrepancyNoteLength from properties file"); } int max = (int) Math.pow(10, discrepancyNoteLength); return StringUtils.leftPad(Integer.toString(RandomUtils.nextInt(0, max)), discrepancyNoteLength, '0'); }
Source:
<code>private GlusterVolumeTaskStatusEntity fetchTaskStatusDetails() { VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeRebalanceStatus, new GlusterVolumeVDSParameters(getUpServerId(clusterId), volume.getName())); GlusterVolumeTaskStatusEntity entity = (GlusterVolumeTaskStatusEntity) returnValue.getReturnValue(); <START> List<Step> stepsList = getStepDao().getStepsByExternalId(volume.getAsyncTask().getTaskId()); <END> if (stepsList != null && !stepsList.isEmpty()) { entity.setStartTime(stepsList.get(0).getStartTime()); } return entity; }</code><technical_language>NPE</technical_language>

Target:
private GlusterVolumeTaskStatusEntity fetchTaskStatusDetails() { VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeRebalanceStatus, new GlusterVolumeVDSParameters(getUpServerId(clusterId), volume.getName())); GlusterVolumeTaskStatusEntity entity = (GlusterVolumeTaskStatusEntity) returnValue.getReturnValue(); GlusterAsyncTask asyncTask = volume.getAsyncTask(); if (asyncTask != null) { List<Step> stepsList = getStepDao().getStepsByExternalId(asyncTask.getTaskId()); if (stepsList != null && !stepsList.isEmpty()) { entity.setStartTime(stepsList.get(0).getStartTime()); } } return entity; }