auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void onResume() { ActivityUtils.prepareLogging(); Logger.info(LOG_TAG, "Called SendTabActivity.onResume."); super.onResume(); final Context applicationContext = getApplicationContext(); final AccountManager accountManager = AccountManager.get(applicationContext); final Account[] fxAccounts = accountManager.getAccountsByType(FxAccountConstants.ACCOUNT_TYPE); if (fxAccounts.length > 0) { final AndroidFxAccount fxAccount = new AndroidFxAccount(applicationContext, fxAccounts[0]); if (fxAccount.getState().getNeededAction() != Action.None) { <START> Logger.warn(LOG_TAG, "Firefox Account named like " + Utils.obfuscateEmail(fxAccounts[0].name) + <END> " needs action before it can send a tab; redirecting to status activity."); final Intent intent = new Intent(applicationContext, FxAccountGetStartedActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); notifyAndFinish(false); return; } this.tabSender = new FxAccountTabSender(applicationContext, fxAccount); Logger.info(LOG_TAG, "Allowing tab send for Firefox Account."); registerDisplayURICommand(); return; } final Account[] syncAccounts = accountManager.getAccountsByType(SyncConstants.ACCOUNTTYPE_SYNC); if (syncAccounts.length > 0) { this.tabSender = new Sync11TabSender(applicationContext, syncAccounts[0], accountManager); Logger.info(LOG_TAG, "Allowing tab send for Sync account."); registerDisplayURICommand(); return; } final Intent intent = new Intent(applicationContext, FxAccountGetStartedActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); notifyAndFinish(false); }</code><technical_language>get obfuscated email AndroidFxAccount? Worth adding that</technical_language>

Target:
public void onResume() { ActivityUtils.prepareLogging(); Logger.info(LOG_TAG, "Called SendTabActivity.onResume."); super.onResume(); final Context applicationContext = getApplicationContext(); final AccountManager accountManager = AccountManager.get(applicationContext); final Account[] fxAccounts = accountManager.getAccountsByType(FxAccountConstants.ACCOUNT_TYPE); if (fxAccounts.length > 0) { final AndroidFxAccount fxAccount = new AndroidFxAccount(applicationContext, fxAccounts[0]); if (fxAccount.getState().getNeededAction() != Action.None) { Logger.warn(LOG_TAG, "Firefox Account named like " + fxAccount.getObfuscatedEmail() + " needs action before it can send a tab; redirecting to status activity."); redirectToNewTask(FxAccountStatusActivity.class, false); return; } this.tabSender = new FxAccountTabSender(applicationContext, fxAccount); Logger.info(LOG_TAG, "Allowing tab send for Firefox Account."); registerDisplayURICommand(); return; } final Account[] syncAccounts = accountManager.getAccountsByType(SyncConstants.ACCOUNTTYPE_SYNC); if (syncAccounts.length > 0) { this.tabSender = new Sync11TabSender(applicationContext, syncAccounts[0], accountManager); Logger.info(LOG_TAG, "Allowing tab send for Sync account."); registerDisplayURICommand(); return; } redirectToNewTask(FxAccountGetStartedActivity.class, false); }
Source:
<code>public void addMessages(List<String> messagesToAdd) { <START> if (messagesToAdd != null) { <END> for (String messageToAdd : messagesToAdd) { addMessage(messageToAdd); } } }</code><technical_language>this a CollectionUtils.isNotEmpty check instead of a != null for efficiency</technical_language>

Target:
public void addMessages(List<String> messagesToAdd) { if (CollectionUtils.isNotEmpty(messagesToAdd)) { for (String messageToAdd : messagesToAdd) { addMessage(messageToAdd); } } }
Source:
<code>public void annotationToMethodsReturnsValuesInTheMapThatAreUnmodifiable() { exception.expect(UnsupportedOperationException.class); TestClass tc = new TestClass(MethodsAnnotated.class); Map<Class<? extends Annotation>, List<FrameworkMethod>> annotationToMethods = tc.getAnnotationToMethods(); <START> annotationToMethods.put(Ignore.class, null); <END> }</code><technical_language>This test method tests (this method is identical previous)</technical_language>

Target:
public void annotationToMethodsReturnsValuesInTheMapThatAreUnmodifiable() { TestClass tc = new TestClass(MethodsAnnotated.class); Map<Class<? extends Annotation>, List<FrameworkMethod>> annotationToMethods = tc.getAnnotationToMethods(); List<FrameworkMethod> methods = annotationToMethods.get(Ignore.class); exception.expect(UnsupportedOperationException.class); methods.add(null); }
Source:
<code>public void startTrackingBpForProcess(final IContainerDMContext containerDmc, final RequestMonitor rm) { final IBreakpointsTargetDMContext targetBpDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(fDebugModelId); for (IBreakpoint breakpoint : breakpoints) { <START> if (supportsBreakpoint(breakpoint) && breakpoint instanceof ICBreakpoint) { <END> setTargetFilter((ICBreakpoint) breakpoint, containerDmc); } } startTrackingBreakpoints(targetBpDmc, rm); }</code><technical_language>a heavy read bug! check if breakpoint applicable reverse instanceof check call. Instanceof is cheaper</technical_language>

Target:
public void startTrackingBpForProcess(final IContainerDMContext containerDmc, final RequestMonitor rm) { final IBreakpointsTargetDMContext targetBpDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(fDebugModelId); for (IBreakpoint breakpoint : breakpoints) { if (breakpoint instanceof ICBreakpoint && supportsBreakpoint(breakpoint)) { setTargetFilter((ICBreakpoint) breakpoint, containerDmc); } } startTrackingBreakpoints(targetBpDmc, rm); }
Source:
<code>private static String encodeUniqueQueuedTaskName(StoredTask task) { Instant updatedAt = task.getUpdatedAt(); return Long.toString(task.getId()) + ".t" + String.format(ENGLISH, <START> "%x%08x", updatedAt.getEpochSecond(), updatedAt.getNano()); <END> }</code><technical_language>updated_at (generated now() pg function) is guaranteed unique now() precision is guaranteed high. <LINK_0> This especially true if pg is running in a VM etc. a counter instead</technical_language>

Target:
private static String encodeUniqueQueuedTaskName(StoredTask task) { int retryCount = task.getRetryCount(); if (retryCount == 0) { return Long.toString(task.getId()); } else { return Long.toString(task.getId()) + ".r" + Integer.toString(retryCount); } }
Source:
<code>private String[] getExcludeClassNamePatterns() { String[] patterns = getValueFromAnnotation(ExcludeClassNamePatterns.class, ExcludeClassNamePatterns::value, new String[0]); if (patterns.length == 0) { <START> return new String[] {}; <END> } Preconditions.containsNoNullElements(patterns, "ExcludeClassNamePatterns must not contain null elements"); trim(patterns); return patterns; }</code><technical_language>need create a new array here. done in previous line. return patterns if length is 0</technical_language>

Target:
private String[] getExcludeClassNamePatterns() { String[] patterns = getValueFromAnnotation(ExcludeClassNamePatterns.class, ExcludeClassNamePatterns::value, new String[0]); Preconditions.containsNoNullElements(patterns, "ExcludeClassNamePatterns must not contain null elements"); trim(patterns); return patterns; }
Source:
<code>public ASTNode transform(KItem kItem) { if (!(kItem.kLabel() instanceof KLabel) || !(kItem.kList() instanceof KList)) { return super.transform(kItem); } assert kItem.kLabel() instanceof KLabel : "KLabel variables are not supported"; assert kItem.kList() instanceof KList : "KList must be concrete"; KLabel kLabel = (KLabel) kItem.kLabel(); KList kList = (KList) kItem.kList(); if (kLabel instanceof KLabelConstant) { KLabelConstant kLabelConstant = (KLabelConstant) kLabel; if (kLabelConstant.isBinder()) { assert kList.getContents().size()==2 && !kList.hasFrame() : "Only supporting binders of the form lambda x. e for now"; <START> Term boundVar = kList.get(0); <END> Term bindingExp = kList.get(1); Term variable = boundVar; Term freshBoundVars = FreshOperations.fresh(variable.sort(), context); Term current = substitution.get(boundVar); substitution.put(boundVar, freshBoundVars); Term resultBindingExp = (Term) bindingExp.accept(this); if (current != null) { substitution.put(boundVar, current); } kList = new KList(ImmutableList.<Term>of(freshBoundVars,resultBindingExp)); return new KItem(kLabel, kList, context); } } return super.transform(kItem); }</code><technical_language>this a nervous... is a reason preexisting binder attributes complex implement now</technical_language>

Target:
public ASTNode transform(KItem kItem) { if (!(kItem.kLabel() instanceof KLabel) || !(kItem.kList() instanceof KList)) { return super.transform(kItem); } KLabel kLabel = (KLabel) kItem.kLabel(); KList kList = (KList) kItem.kList(); if (kLabel instanceof KLabelConstant) { KLabelConstant kLabelConstant = (KLabelConstant) kLabel; if (kLabelConstant.isBinder()) { Map<Integer, Term> freshSubstitution = new HashMap<>(); Multimap<Integer, Integer> backBinding = HashMultimap.create(); Multimap<Integer, Integer> binderMap = kLabelConstant.getBinderMap(); for (Integer keyIndex : binderMap.keySet()) { Term boundVar = kList.get(keyIndex); if (!unboundedTerms.contains(boundVar) && !substitution.containsKey(boundVar)) continue; Term freshBoundVar = FreshOperations.fresh(boundVar.sort(), context); freshSubstitution.put(keyIndex, freshBoundVar); backBinding.put(keyIndex, keyIndex); for (Integer valueIndex : binderMap.get(keyIndex)) { backBinding.put(valueIndex, keyIndex); } } List<Term> termList = new ArrayList<>(); termList.addAll(kList.getContents()); for (int idx = 0; idx < termList.size(); idx++) { Map<Term, Term> newSubstitution = new HashMap<>(substitution); if (backBinding.containsKey(idx)) { for (Integer boundPosition : backBinding.get(idx)) { Term variable = kList.get(boundPosition); if (unboundedTerms.contains(variable)) { newSubstitution.put(variable, freshSubstitution.get(boundPosition)); } else if (substitution.containsKey(variable)) { newSubstitution.remove(variable); } } } Term bindingExp = termList.get(idx); Term resultBindingExp = userSubstitution(newSubstitution, bindingExp, context); termList.set(idx, resultBindingExp); } kList = new KList(ImmutableList.copyOf(termList)); kItem = new KItem(kLabel, kList, context); return new DoneTransforming(kItem); } } return super.transform(kItem); }
Source:
<code>public static ObjectMapper createMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.setDateFormat(new ISO8601DateFormat()); <START> mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); <END> return mapper; }</code><technical_language>@aheritier I a custom Jackson deserializer for CustomFieldValue more sense instead of changing mapper for dtos</technical_language>

Target:
public static ObjectMapper createMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.setDateFormat(new ISO8601DateFormat()); return mapper; }
Source:
<code>private boolean CheckVcardSelector(String vcard, String vcardselectorop) { boolean selectedIn = true; for (PropertyMask bit : PropertyMask.values()) { if (checkbit(bit.pos, selector)) { <START> Log.e(TAG, <END> "checking for prop :" + bit.prop); if (vcardselectorop.equals("0")) { if (checkprop(vcard, bit.prop)) { Log.e(TAG, "bit.prop.equals current prop :" + bit.prop); selectedIn = true; break; } else { selectedIn = false; } } else if (vcardselectorop.equals("1")) { if (!checkprop(vcard, bit.prop)) { Log.e(TAG, "bit.prop.notequals current prop" + bit.prop); selectedIn = false; return selectedIn; } else { selectedIn = true; } } } } return selectedIn; }</code><technical_language>Is this error</technical_language>

Target:
private boolean CheckVcardSelector(String vcard, String vcardselectorop) { boolean selectedIn = true; for (PropertyMask bit : PropertyMask.values()) { if (checkbit(bit.pos, selector)) { Log.d(TAG, "checking for prop :" + bit.prop); if (vcardselectorop.equals("0")) { if (checkprop(vcard, bit.prop)) { Log.d(TAG, "bit.prop.equals current prop :" + bit.prop); selectedIn = true; break; } else { selectedIn = false; } } else if (vcardselectorop.equals("1")) { if (!checkprop(vcard, bit.prop)) { Log.d(TAG, "bit.prop.notequals current prop" + bit.prop); selectedIn = false; return selectedIn; } else { selectedIn = true; } } } } return selectedIn; }
Source:
<code>public VMTemplateVO create(TemplateProfile profile) { VMTemplateVO template; if (profile.getTemplateType() == TemplateType.SYSTEM ){ <START> profile.setAccountId(1L); END> template = persistTemplate(profile, State.Inactive); } else { template = persistTemplate(profile, State.Active); } if (template == null) { throw new CloudRuntimeException("Unable to persist the template " + profile.getTemplate()); } if (!profile.isDirectDownload()) { List<Long> zones = profile.getZoneIdList(); if (zones == null){ createTemplateWithinZone(null, profile, template); } else { for (Long zId : zones) { createTemplateWithinZone(zId, profile, template); } } } else { persistDirectDownloadTemplate(template.getId(), profile.getSize()); } _resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template); return template; }</code><technical_language>I a constant for somewhere. if ;)</technical_language>

Target:
public VMTemplateVO create(TemplateProfile profile) { VMTemplateVO template; if (profile.getTemplateType() == TemplateType.SYSTEM ){ template = persistTemplate(profile, State.Inactive); } else { template = persistTemplate(profile, State.Active); } if (template == null) { throw new CloudRuntimeException("Unable to persist the template " + profile.getTemplate()); } if (!profile.isDirectDownload()) { List<Long> zones = profile.getZoneIdList(); if (zones == null){ createTemplateWithinZone(null, profile, template); } else { for (Long zId : zones) { createTemplateWithinZone(zId, profile, template); } } } else { persistDirectDownloadTemplate(template.getId(), profile.getSize()); } _resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template); return template; }
Source:
<code>private String getFileDownloadURL(final Supplier<Path> pathSupplier) { <START> return GWT.getModuleBaseURL() + "defaulteditor/download?path=" + URIUtil.encodeQueryString(URIUtil.decode(pathSupplier.get().toURI())); <END> }</code><technical_language>"defaulteditor/download?path=" this literal a constant</technical_language>

Target:
private String getFileDownloadURL(final Supplier<Path> pathSupplier) { return GWT.getModuleBaseURL() + DEFAULT_EDITOR + URIUtil.encodeQueryString(URIUtil.decode(pathSupplier.get().toURI())); }
Source:
<code>public byte[] marshal(Context context, ObjectOutputStream objectOutputStream, Object o) throws IOException { Document document = (Document) o; String updatedAttribute = document.getAttribute(Document.UPDATED_ATTRIBUTE); <START> if ("true".equals(updatedAttribute)) { <END> documentStorageService.saveDocument(document, document.getContent()); document.addAttribute(Document.UPDATED_ATTRIBUTE, "false"); } ByteArrayOutputStream buff = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(buff); oos.writeUTF(document.getIdentifier()); oos.writeUTF(document.getClass().getCanonicalName()); oos.writeUTF(document.getLink()); oos.close(); return buff.toByteArray(); }</code><technical_language>Boolean.parseBoolean(String s) handle null for</technical_language>

Target:
public byte[] marshal(Context context, ObjectOutputStream objectOutputStream, Object o) throws IOException { Document document = (Document) o; String updatedAttribute = document.getAttribute(Document.UPDATED_ATTRIBUTE); if (Boolean.parseBoolean(updatedAttribute)) { documentStorageService.saveDocument(document, document.getContent()); document.addAttribute(Document.UPDATED_ATTRIBUTE, "false"); } ByteArrayOutputStream buff = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(buff); oos.writeUTF(document.getIdentifier()); oos.writeUTF(document.getClass().getCanonicalName()); oos.writeUTF(document.getLink()); oos.close(); return buff.toByteArray(); }
Source:
<code><START> public void userCanBeKickedOutFromChat() { <END> ChatPageObject chatUserOne = openChatForUser(userOne, userOnePassword); switchToWindow(1); new SpecialVersionPage().open(); ChatPageObject chatStaffUser = openChatForUser(userStaff, userStaffPassword); chatStaffUser.kickUserFromChat(userOne); switchToWindow(0); chatUserOne.verifyUserIsKickedFromChat(userOne); }</code><technical_language>is "kick" name of action appears in functionality ? If yes, stay. If "remove" this, stick functionality naming</technical_language>

Target:
public void userCanBeKickedOutFromChat() { ChatPage chatUserOne = openChatForUser(userOne, userOnePassword); switchToWindow(1); new SpecialVersionPage().open(); ChatPage chatStaffUser = openChatForUser(userStaff, userStaffPassword); chatStaffUser.clickOnDifferentUser(userOne); chatStaffUser.clickOnUserOptionsKickButton(); switchToWindow(0); Assertion.assertTrue(chatUserOne.isUserKickedFromChat(), "USER IS NOT KICKED FROM CHAT"); }
Source:
<code>private void readOffsets(TopicPartition topicPart) throws IOException { String topic = topicPart.topic(); int partition = topicPart.partition(); Path path = new Path(url + "/" + topicsDir + "/" + topic + "/" + partition); if (!fs.exists(path)) { return; } PathFilter filter = new CommittedFileFilter(); <START> FileStatus[] committedFiles = fs.listStatus(path, filter); <END> for (FileStatus committedFile : committedFiles) { String filename = committedFile.getPath().getName(); String[] parts = filename.split("_"); try { long endOffset = Long.parseLong(parts[1]); if (!offsets.containsKey(topicPart) || endOffset > offsets.get(topicPart)) { offsets.put(topicPart, endOffset + 1); } } catch (NumberFormatException e) { log.warn("Invalid committed file: {}", filename); } } }</code><technical_language>question other exceptions need catch</technical_language>

Target:
private void readOffsets(TopicPartition topicPart) throws CopycatException { String path = FileUtils.directoryName(url, topicsDir, topicPart); PathFilter filter = new CommittedFileFilter(); try { if (!storage.exists(path)) { return; } FileStatus[] committedFiles = storage.listStatus(path, filter); for (FileStatus committedFile : committedFiles) { String filename = committedFile.getPath().getName(); String[] parts = filename.split("_"); try { long endOffset = Long.parseLong(parts[1]); if (!offsets.containsKey(topicPart) || endOffset > offsets.get(topicPart)) { offsets.put(topicPart, endOffset); } } catch (NumberFormatException e) { log.warn("Invalid committed file: {}", filename); } } } catch (IOException e) { throw new CopycatException(e); } }
Source:
<code>public void requestTicketOfTypeStrings() { User user = persistUser(); TicketType type = ticketTypeRepository.findByName(TEST_TICKET).get(); TicketOption pickupOption = ticketOptionRepository.findByName(PICKUP_SERVICE_OPTION).get(); TicketOption chMemberOption = ticketOptionRepository.findByName(CH_MEMBER_OPTION).get(); List<TicketOption> options = Arrays.asList(pickupOption, chMemberOption); <START> Set<TicketOption> optionSet = new HashSet<>(options); <END> String typeString = TEST_TICKET; List<String> optionsString = Arrays.asList(CH_MEMBER_OPTION, PICKUP_SERVICE_OPTION); Ticket ticket = ticketService.requestTicketOfType(user, typeString, optionsString); assertEquals(user, ticket.getOwner()); assertEquals(optionSet, ticket.getEnabledOptions()); assertEquals(type, ticket.getType()); }</code><technical_language>insert previous Arrays.asList call in HashSet constructor, removes line allows another newline for readability</technical_language>

Target:
public void requestTicketOfTypeStrings() { User user = persistUser(); TicketType type = ticketTypeRepository.findByName(TEST_TICKET) .orElseThrow(() -> new TicketTypeNotFoundException(TEST_TICKET)); TicketOption pickupOption = ticketOptionRepository.findByName(PICKUP_SERVICE_OPTION) .orElseThrow(TicketOptionNotFoundException::new); TicketOption chMemberOption = ticketOptionRepository.findByName(CH_MEMBER_OPTION).orElseThrow(TicketOptionNotFoundException::new); List<String> optionsList = Arrays.asList(CH_MEMBER_OPTION, PICKUP_SERVICE_OPTION); Ticket ticket = ticketService.requestTicketOfType(user, TEST_TICKET, optionsList); assertEquals(user, ticket.getOwner()); assertThat(ticket.getEnabledOptions()).containsAll(Arrays.asList(pickupOption, chMemberOption)); assertEquals(type, ticket.getType()); }
Source:
<code><START> public List<ThreadState> getThreads() { <END> return config.sendThreads ? ThreadState.getLiveThreads(config) : null; }</code><technical_language>This needs protected ThreadState needs public</technical_language>

Target:
protected List<ThreadState> getThreads() { return config.sendThreads ? ThreadState.getLiveThreads(config) : null; }
Source:
<code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final int orientation = getResources().getConfiguration().orientation; MainActivity.info("NEWS: onCreateView. orientation: " + orientation); final LinearLayout rootView = (LinearLayout) inflater.inflate(R.layout.news, container, false); setupListView(rootView); final NewsDownloadHandler handler = new NewsDownloadHandler(rootView, numberFormat, getActivity().getPackageName(), getResources()); handler.setNewsListAdapter(listAdapter); final ApiDownloader task = new ApiDownloader(getActivity(), ListFragment.lameStatic.dbHelper, "news-cache.json", MainActivity.NEWS_URL, false, false, false, ApiDownloader.REQUEST_GET, new ApiListener() { @Override public void requestComplete(final JSONObject json, final boolean isCache) { handleNews(json, handler); } }); try { task.startDownload(this); <START> } catch (WiGLEAuthException waex) END> return rootView; }</code><technical_language>Empty catches wig out, info log</technical_language>

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final int orientation = getResources().getConfiguration().orientation; MainActivity.info("NEWS: onCreateView. orientation: " + orientation); final LinearLayout rootView = (LinearLayout) inflater.inflate(R.layout.news, container, false); setupListView(rootView); final NewsDownloadHandler handler = new NewsDownloadHandler(rootView, numberFormat, getActivity().getPackageName(), getResources()); handler.setNewsListAdapter(listAdapter); final ApiDownloader task = new ApiDownloader(getActivity(), ListFragment.lameStatic.dbHelper, "news-cache.json", MainActivity.NEWS_URL, false, false, false, ApiDownloader.REQUEST_GET, new ApiListener() { @Override public void requestComplete(final JSONObject json, final boolean isCache) { handleNews(json, handler); } }); try { task.startDownload(this); } catch (WiGLEAuthException waex) { MainActivity.warn("Authentication error on news load (should not happen)", waex); } return rootView; }
Source:
<code>public static XPathReference getAbsRef(XPathReference ref, TreeReference parentRef) { TreeReference tref; if (!parentRef.isAbsolute()) { throw new RuntimeException("XFormParser.getAbsRef: parentRef must be absolute"); } if (ref != null) { tref = ref.getReference(); } else { tref = TreeReference.selfRef(); } tref = tref.parent(parentRef); if (tref == null) { <START> throw new XFormParseException("Binding path [" + ref.getReference().toString(true) + "] not allowed with parent binding of [" + parentRef + "]"); <END> } return new XPathReference(tref); }</code><technical_language>conditional block ref null - handling here</technical_language>

Target:
public static XPathReference getAbsRef(XPathReference ref, TreeReference parentRef) { TreeReference tref; if (!parentRef.isAbsolute()) { throw new RuntimeException("XFormParser.getAbsRef: parentRef must be absolute"); } if (ref != null) { tref = ref.getReference(); } else { tref = TreeReference.selfRef(); } TreeReference refPreContextualization = tref; tref = tref.parent(parentRef); if (tref == null) { throw new XFormParseException("Binding path [" + refPreContextualization.toString(true) + "] not allowed with parent binding of [" + parentRef + "]"); } return new XPathReference(tref); }
Source:
<code>private void loadLookupTable() throws Exception { _lookupTableWriteLock.lock(); try { <START> List<SegmentDataManager> segmentManagers = acquireAllSegments(); <END> if (segmentManagers.size() == 0) { _lookupTable.clear(); return; } List<File> indexDirs = new ArrayList<>(); for (SegmentDataManager segmentManager: segmentManagers) { IndexSegment indexSegment = segmentManager.getSegment(); System.out.println(indexSegment.getSegmentName()); indexDirs.add(indexSegment.getSegmentMetadata().getIndexDir()); } MultiplePinotSegmentRecordReader reader = new MultiplePinotSegmentRecordReader(indexDirs); _lookupTable.clear(); while (reader.hasNext()) { GenericRow row = reader.next(); _lookupTable.put(row.getPrimaryKey(_primaryKeyColumns), row); } } finally { _lookupTableWriteLock.unlock(); } }</code><technical_language>simplify logic, clear lookup table first, load</technical_language>

Target:
private void loadLookupTable() throws Exception { _lookupTableWriteLock.lock(); try { _lookupTable.clear(); List<SegmentDataManager> segmentManagers = acquireAllSegments(); if (segmentManagers.size() == 0) { return; } try { for (SegmentDataManager segmentManager : segmentManagers) { IndexSegment indexSegment = segmentManager.getSegment(); try (PinotSegmentRecordReader reader = new PinotSegmentRecordReader( indexSegment.getSegmentMetadata().getIndexDir())) { while (reader.hasNext()) { GenericRow row = reader.next(); _lookupTable.put(row.getPrimaryKey(_primaryKeyColumns), row); } } } } finally { for (SegmentDataManager segmentManager : segmentManagers) { releaseSegment(segmentManager); } } } finally { _lookupTableWriteLock.unlock(); } }
Source:
<code>public void writeEntityBody(BulkStatus entity, JsonGenerator jg) throws IOException { jg.writeStringField(BULK_ID, entity.getId()); jg.writeStringField(BULK_STATE, entity.getState().toString()); <START> jg.writeStringField(BULK_CREATION, String.valueOf(entity.getCreationInstant().toString())); <END> writeEntityField(BULK_COMMAND, entity.getCommand(), jg); if (entity.getCount() != null) { jg.writeNumberField(BULK_COUNT, entity.getCount().longValue()); } }</code><technical_language>String.value of a toString()</technical_language>

Target:
public void writeEntityBody(BulkStatus entity, JsonGenerator jg) throws IOException { jg.writeStringField(BULK_ID, entity.getId()); jg.writeStringField(BULK_STATE, entity.getState().toString()); jg.writeStringField(BULK_SUBMIT, entity.getSubmitTime().toString()); writeEntityField(BULK_COMMAND, entity.getCommand(), jg); if (entity.getCount() != null) { jg.writeNumberField(BULK_COUNT, entity.getCount().longValue()); } }
Source:
<code>AbstractEslintSensor(JavaScriptChecks checks, EslintBridgeServer eslintBridgeServer, @Nullable AnalysisWarnings analysisWarnings) { this.checks = checks; this.rules = checks.eslintBasedChecks().stream() .map(check -> new EslintBridgeServer.Rule(check.eslintKey(), check.configurations())) .toArray(Rule[]::new); this.eslintBridgeServer = eslintBridgeServer; this.analysisWarnings = analysisWarnings; checks.all().stream() .filter(check -> check instanceof ParsingErrorCheck) .findFirst() <START> .ifPresent(parsingErrorCheck -> parsingErrorRuleKey = checks.ruleKeyFor(parsingErrorCheck)); <END> }</code><technical_language>if rewrite this expression .map(checks::ruleKeyFor).orElse(null); field final is nicer</technical_language>

Target:
AbstractEslintSensor(JavaScriptChecks checks, EslintBridgeServer eslintBridgeServer, @Nullable AnalysisWarnings analysisWarnings) { this.checks = checks; this.rules = checks.eslintBasedChecks().stream() .map(check -> new EslintBridgeServer.Rule(check.eslintKey(), check.configurations())) .toArray(Rule[]::new); this.eslintBridgeServer = eslintBridgeServer; this.analysisWarnings = analysisWarnings; this.parsingErrorRuleKey = checks.all().stream() .filter(check -> check instanceof ParsingErrorCheck) .findFirst() .map(checks::ruleKeyFor).orElse(null); }
Source:
<code>public ImageData createImageData(double width, double height) { context.createImageData(width, height); <START> return null; <END> }</code><technical_language>return context.createImageData(width, height); ? question method below</technical_language>

Target:
public ImageData createImageData(double width, double height) { return nativeClassConverter.convert(context.createImageData(width, height), ImageData.class); }
Source:
<code>public void rebuildRecentBoardsMenu() throws Exception { Enumeration<AbstractButton> btns = recentBoardsButtonGroup.getElements(); while (btns.hasMoreElements()) { AbstractButton x = btns.nextElement(); if (x.isSelected()) { return; } } btns = recentBoardsButtonGroup.getElements(); while (btns.hasMoreElements()) { AbstractButton x = btns.nextElement(); boardMenu.remove(x); } int index = 0; for (TargetBoard board : BaseNoGui.getRecentlyUsedBoards()) { JMenuItem item = createBoardMenusAndCustomMenus(boardsCustomMenus, menuItemsToClickAfterStartup, buttonGroupsMap, board, board.getContainerPlatform(), board.getContainerPlatform().getContainerPackage()); boardMenu.insert(item, 3); item.setAccelerator(KeyStroke.getKeyStroke('0' + index, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | ActionEvent.SHIFT_MASK)); recentBoardsButtonGroup.add(item); boardsButtonGroup.add(item); index ++; <START> } <END> boardMenuScroller.setTopFixedCount(3 + index); }</code><technical_language>do need this? Please eat exceptions..</technical_language>

Target:
public void rebuildRecentBoardsMenu() throws Exception { Enumeration<AbstractButton> btns = recentBoardsButtonGroup.getElements(); while (btns.hasMoreElements()) { AbstractButton x = btns.nextElement(); if (x.isSelected()) { return; } } btns = recentBoardsButtonGroup.getElements(); while (btns.hasMoreElements()) { AbstractButton x = btns.nextElement(); boardMenu.remove(x); } int index = 0; for (TargetBoard board : BaseNoGui.getRecentlyUsedBoards()) { JMenuItem item = createBoardMenusAndCustomMenus(boardsCustomMenus, menuItemsToClickAfterStartup, buttonGroupsMap, board, board.getContainerPlatform(), board.getContainerPlatform().getContainerPackage()); boardMenu.insert(item, 3); item.setAccelerator(KeyStroke.getKeyStroke('1' + index, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | ActionEvent.SHIFT_MASK)); recentBoardsButtonGroup.add(item); boardsButtonGroup.add(item); index ++; } boardMenuScroller.setTopFixedCount(3 + index); }
Source:
<code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); <START> if (args.containsKey("filter")) { <END> filters.put(args.getString("filter"), true); } }</code><technical_language>"filter" a constant(KEY_FILTER) in NotificationListFragment, argument key place need it. typo bug in other place</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args.containsKey(EXTRA_FILTER)) { filters.put(args.getString(EXTRA_FILTER), true); } }
Source:
<code>public void cancel(Account account, OCFile file) { UploadFileOperation upload = null; synchronized (mPendingUploads) { upload = mPendingUploads.remove(buildRemoteName(account, file)); } if (upload != null) { <START> mCurrentUpload.cancel(); <END> } }</code><technical_language>change in this line is a mistake solving conflicts, right</technical_language>

Target:
public void cancel(Account account, OCFile file) { UploadFileOperation upload = null; synchronized (mPendingUploads) { upload = mPendingUploads.remove(buildRemoteName(account, file)); } if (upload != null) { upload.cancel(); } }
Source:
<code><START> private void persistDiffPreferences() { <END> AccountDiffPreference diffPref = new AccountDiffPreference(); diffPref.setIgnoreWhitespace(getIgnoreWhitespace().getCode()); diffPref.setTabSize(tabWidth.getIntValue()); diffPref.setLineLength(colWidth.getIntValue()); diffPref.setSyntaxHighlighting(syntaxHighlighting.getValue()); diffPref.setShowWhitespaceErrors(whitespaceErrors.getValue()); diffPref.setIntralineDifference(intralineDifference.getValue()); diffPref.setShowTabs(showTabs.getValue()); Util.ACCOUNT_SVC.changeDiffPreferences(diffPref, new GerritCallback<VoidResult>() { @Override public void onSuccess(VoidResult result) { } }); }</code><technical_language>save stuff try disable of related widgets save RPC completes, re-enable them. disable while page is loading. patch viewers embed this panel watching for ValueChangeEvent call setEnabled(false), do RPC, call setEnabled(true). If saving preferences, setEnabled(false), avoid setEnabled(true) RPC is done. need some sort of additional flag waiting for application setEnabled(true) re-enable widgets</technical_language>

Target:
private void persistDiffPreferences() { AccountDiffPreference diffPref = new AccountDiffPreference(Gerrit.getUserAccount().getId()); diffPref.setIgnoreWhitespace(getIgnoreWhitespace()); diffPref.setTabSize(tabWidth.getIntValue()); diffPref.setLineLength(colWidth.getIntValue()); diffPref.setSyntaxHighlighting(syntaxHighlighting.getValue()); diffPref.setShowWhitespaceErrors(whitespaceErrors.getValue()); diffPref.setIntralineDifference(intralineDifference.getValue()); diffPref.setShowTabs(showTabs.getValue()); Util.ACCOUNT_SVC.changeDiffPreferences(diffPref, new GerritCallback<VoidResult>() { @Override public void onSuccess(VoidResult result) { } }); Gerrit.setAccountDiffPreference(diffPref); }
Source:
<code>private Integer generateHashCode(AndroidViewComponent component, PercentStorageRecord.Dim dim) { if (dim == PercentStorageRecord.Dim.HEIGHT) { <START> return (component.hashCode() + dim.hashCode()) * 2 + 1; <END> } else { return (component.hashCode() + dim.hashCode()) * 2; } }</code><technical_language>need add dim.hashCode() (or next line). virtue of adding 0 1 encoding dimension information perfectly</technical_language>

Target:
private Integer generateHashCode(AndroidViewComponent component, PercentStorageRecord.Dim dim) { if (dim == PercentStorageRecord.Dim.HEIGHT) { return component.hashCode() * 2 + 1; } else { return component.hashCode() * 2; } }
Source:
<code>public void hashValues(FloatColumnSelector dimSelector, HyperLogLogCollector collector) { <START> collector.add(CardinalityAggregator.hashFn.hashUnencodedChars(String.valueOf(dimSelector.get())).asBytes()); <END> }</code><technical_language>hashFn.hashInt(Float.floatToIntBits(dimSelector.get())) faster encoding float a string</technical_language>

Target:
public void hashValues(FloatColumnSelector dimSelector, HyperLogLogCollector collector) { collector.add(CardinalityAggregator.hashFn.hashInt(Float.floatToIntBits(dimSelector.get())).asBytes()); }
Source:
<code><START> public void testInDAG() throws IOException, Exception <END> { try { LocalMode lma = LocalMode.newInstance(); Configuration conf = new Configuration(false); lma.prepareDAG(new Application(), conf); LocalMode.Controller lc = lma.getController(); lc.run(5000); } catch (ConstraintViolationException e) { Assert.fail("constraint violations: " + e.getConstraintViolations()); } }</code><technical_language>Is purpose of this test validation of dag connectivity</technical_language>

Target:
public void testInDAG() throws Exception { LocalMode lma = LocalMode.newInstance(); Configuration conf = new Configuration(false); Application testApp = new Application(); String outputFileName = "target/output.txt"; long timeout = 2000; new File(outputFileName).delete(); testApp.setOutputFileName(outputFileName); lma.prepareDAG(testApp, conf); LocalMode.Controller lc = lma.getController(); lc.runAsync(); File target = new File("target/output.txt"); long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime <= timeout) { try { Thread.sleep(10); } catch (InterruptedException e) { break; } if (target.length() > 100000) { break; } } Assert.assertTrue(target.exists()); try { List<String> lines = FileUtils.readLines(target); double finalMedian = Double.parseDouble(lines.get(lines.size() - 1)); Assert.assertTrue("Median is close to 0.0", -0.05 <= finalMedian && finalMedian <= 0.05); } catch (IOException e) { e.printStackTrace(); } }
Source:
<code>private Type<?> getType(Type<?> baseType, Attribute<?, ?> attribute) { Class<?> baseClass = baseType.getJavaType(); Member member = attribute.getJavaMember(); if (attribute instanceof SingularAttribute) { if (member instanceof Method) { member = ReflectionUtils.getMethod(baseClass, member.getName()); } else if (member instanceof Field) { <START> member = ReflectionUtils.getField(baseClass, member.getName()); <END> } if (member == null && attribute.getJavaMember() != null) { throw new IllegalStateException("Cannot resolve " + attribute.getJavaMember().getName() + " on " + baseClass.getSimpleName()); } } if (baseClass != null) { if (attribute.getJavaMember() instanceof Field) { return metamodel.type(ReflectionUtils.getResolvedFieldType(baseClass, (Field) member)); } else if (attribute.getJavaMember() instanceof Method) { return metamodel.type(ReflectionUtils.getResolvedMethodReturnType(baseClass, (Method) member)); } } if (attribute instanceof PluralAttribute<?, ?, ?>) { return ((PluralAttribute<?, ?, ?>) attribute).getElementType(); } return ((SingularAttribute<?, ?>) attribute).getType(); }</code><technical_language>easier if this Class<?> clazz = com.blazebit.persistence.parser.util.JpaMetamodelUtils#resolveFieldClass(baseType.getJavaType(), attribute); if (clazz != null) { return metamodel.type(clazz); } if (attribute instanceof PluralAttribute<?, ?, ?>) { return ((PluralAttribute<?, ?, ?>) attribute).getElementType(); } return ((SingularAttribute<?, ?>) attribute).getType();</technical_language>

Target:
private Type<?> getType(Type<?> baseType, Attribute<?, ?> attribute) { Class<?> baseClass = baseType.getJavaType(); if (baseClass != null) { Class<?> clazz = JpaMetamodelUtils.resolveFieldClass(baseType.getJavaType(), attribute); if (clazz != null) { return metamodel.type(clazz); } } if (attribute instanceof PluralAttribute<?, ?, ?>) { return ((PluralAttribute<?, ?, ?>) attribute).getElementType(); } return ((SingularAttribute<?, ?>) attribute).getType(); }
Source:
<code>public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } JaasAuthenticationConfig other = (JaasAuthenticationConfig) obj; <START> if (loginModuleConfigs == null) { if (other.loginModuleConfigs != null) { return false; } } else if (!loginModuleConfigs.equals(other.loginModuleConfigs)) { return false; } <END> return true; }</code><technical_language>Objects.equals()</technical_language>

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } JaasAuthenticationConfig other = (JaasAuthenticationConfig) obj; return Objects.equals(loginModuleConfigs, other.loginModuleConfigs); }
Source:
<code>public Insert(Table<T> table, Query subQuery, List<String> columns, DuplicateKeyContext<T> duplicateKeyContext) { this.table = table; this.columns = columns; <START> this.subQuery = subQuery; <END> this.duplicateKeyContext = duplicateKeyContext; }</code><technical_language>insertSource, query smth else? a bit confusing values in there, variable is called subQuery. Otherwise, lgtm</technical_language>

Target:
public Insert(Table<T> table, Query subQuery, List<String> columns, DuplicateKeyContext<T> duplicateKeyContext) { this.table = table; this.columns = columns; this.insertSource = subQuery; this.duplicateKeyContext = duplicateKeyContext; }
Source:
<code><START> public void HiViATFShouldRequestForMEGAAdUnitVAST() throws UnsupportedEncodingException { <END> final String adUnit = "/5441/wka1a.VIDEO/uap_bfab/desktop/oasis-article/_project43-life"; networkTrafficInterceptor.startIntercepting(); AdsBaseObject ads = new AdsBaseObject(driver, AdsDataProvider.UAP_HIVI_PAGE.getUrl()); ads.triggerAdSlot(AdsContent.BOTTOM_LB); ads.waitForVASTRequestWithAdUnit(networkTrafficInterceptor, adUnit); }</code><technical_language>HiViATFShouldRequestForMEGAAdUnitVAST -> HiViBTFShouldRequestForMEGAAdUnitVAST IMHO :smile_cat:</technical_language>

Target:
public void HiViATFShouldRequestForMEGAAdUnitVAST() throws UnsupportedEncodingException { final String adUnit = "/5441/wka1a.VIDEO/uap_bfaa/desktop/oasis-article/_project43-life"; checkRequestForAdUnit(AdsDataProvider.UAP_HIVI_PAGE, adUnit); }
Source:
<code>public DesiredCapabilities getCapability(String testName) { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities = initCapabilities(capabilities); if (R.CONFIG.getBoolean(SpecialKeywords.FULL_RESET_BEFORE_SUITE) && !R.CONFIG.get(SpecialKeywords.FULL_RESET_BEFORE_SUITE).isEmpty()) { <START> LOGGER.info("Will be execute 'fullResetBeforeSuite'!"); <END> executeFullResetBeforeSuite(capabilities); } return capabilities; }</code><technical_language>debug level instead of info</technical_language>

Target:
public DesiredCapabilities getCapability(String testName) { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities = initCapabilities(capabilities); return capabilities; }
Source:
<code><START> public void setEventBus(EventBus eventBus) { <END> this.eventBus = eventBus; if (eventBus == null) { unregisterHandlers(); } }</code><technical_language>I this method final addition of extra "hook" (overridable) method register handlers: public final void setEventBus(EventBus eventBus) { this.eventBus = eventBus; if (eventBus != null) { registerHandlers(); } else { unregisterHandlers(); } } /** * Override this method register custom event handlers necessary. */ protected void registerHandlers() { // No-op, override necessary }</technical_language>

Target:
public final void setEventBus(EventBus eventBus) { this.eventBus = eventBus; if (eventBus == null) { unregisterHandlers(); } else { registerHandlers(); } }
Source:
<code>public MongoDbContainer() { <START> this("mongo:4.1"); <END> }</code><technical_language>I this a constant, DEFAULT_IMAGE_AND_TAG</technical_language>

Target:
public MongoDbContainer() { this(DEFAULT_IMAGE_AND_TAG); }
Source:
<code>private static Object[] computeParameters(Map<Class<?>, IClass> classes, Class<?> ec, IObjectFactory factory) throws NoSuchMethodException, IllegalAccessException, InstantiationException { IClass enclosingIClass = classes.get(ec); Object[] enclosingInstances; if (null != enclosingIClass) { enclosingInstances = enclosingIClass.getInstances(false); if ((null == enclosingInstances) || (enclosingInstances.length == 0)) { Object o = factory.newInstance(ec.getConstructor(ec)); enclosingIClass.addInstance(o); enclosingInstances = new Object[]{o}; } } else { enclosingInstances = new Object[]{ec.newInstance()}; } Object enclosingClassInstance = enclosingInstances[0]; <START> return new Object[]{enclosingClassInstance}; <END> }</code><technical_language>returning object is intent of method? java if (enclosingIClass == null) { return ec.newInstance(); } Object[] enclosingInstances = enclosingIClass.getInstances(false); if (enclosingInstances != null && enclosingInstances.length > 0) { return enclosingInstances[0]; } Object o = factory.newInstance(ec.getConstructor(ec)); enclosingIClass.addInstance(o); return o;</technical_language>

Target:
private static Object computeParameters(Map<Class<?>, IClass> classes, Class<?> ec, IObjectFactory factory) throws NoSuchMethodException, IllegalAccessException, InstantiationException { IClass enclosingIClass = classes.get(ec); if (enclosingIClass == null) { return ec.newInstance(); } Object[] enclosingInstances = enclosingIClass.getInstances(false); if (enclosingInstances == null || enclosingInstances.length == 0) { return factory.newInstance(ec.getConstructor(ec)); } return enclosingInstances[0]; }
Source:
<code>public void listModifyingBatch() { Date startDate = createDate(2010, 1, 1); Date endDate = createDate(2020, 1, 1); Entitlement ent = setUpModifyingEntitlements(startDate, endDate, 4, "1"); Date startDate1 = createDate(2030, 1, 1); Date endDate1 = createDate(2040, 1, 1); Entitlement ent1 = setUpModifyingEntitlements(startDate1, endDate1, 2, "2"); Set<Entitlement> ents = entitlementCurator.listModifying(Arrays.asList(ent, ent1)); assertEquals(6, ents.size()); assertTrue(!ents.contains(ent)); assertTrue(!ents.contains(ent1)); <START> <END> }</code><technical_language>Extraneous whitespace</technical_language>

Target:
public void listModifyingBatch() { Date startDate = createDate(2010, 1, 1); Date endDate = createDate(2020, 1, 1); Entitlement ent = setUpModifyingEntitlements(startDate, endDate, 4, "1"); Date startDate1 = createDate(2030, 1, 1); Date endDate1 = createDate(2040, 1, 1); Entitlement ent1 = setUpModifyingEntitlements(startDate1, endDate1, 2, "2"); Set<Entitlement> ents = entitlementCurator.listModifying(Arrays.asList(ent, ent1)); assertEquals(6, ents.size()); assertThat(ents, not(hasItem(ent))); assertThat(ents, not(hasItem(ent1))); }
Source:
<code>private void register(Kryo kryo, Registration registration) { int id = registration.getId(); Registration existing = kryo.getRegistration(id); if (existing != null) { <START> throw new SerializationFailedException((String.format("registration already exists %s", existing))); <END> } if (log.isInfoEnabled()) { log.info(String.format("registering %s with serializer %s", registration, registration.getSerializer().getClass() .getName())); } kryo.register(registration); }</code><technical_language>??? Do do registerType() serialization operation</technical_language>

Target:
private void register(Kryo kryo, Registration registration) { int id = registration.getId(); Registration existing = kryo.getRegistration(id); if (existing != null) { throw new RuntimeException((String.format("registration already exists %s", existing))); } if (log.isInfoEnabled()) { log.info(String.format("registering %s with serializer %s", registration, registration.getSerializer().getClass() .getName())); } kryo.register(registration); }