auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public DefaultCacheManager(String globalConfigurationFile, String defaultConfigurationFile, String namedCacheFile, boolean start) throws IOException { ParserRegistry parserRegistry = new ParserRegistry(); ConfigurationBuilderHolder globalConfigurationBuilderHolder = parserRegistry.parseFile(globalConfigurationFile); ConfigurationBuilderHolder defaultConfigurationBuilderHolder = parserRegistry.parseFile(defaultConfigurationFile); globalConfiguration = globalConfigurationBuilderHolder.getGlobalConfigurationBuilder().build(); defaultConfiguration = defaultConfigurationBuilderHolder.getDefaultConfigurationBuilder().build(); if (namedCacheFile != null) { ConfigurationBuilderHolder namedConfigurationBuilderHolder = parserRegistry.parseFile(namedCacheFile); Entry<String, ConfigurationBuilder> entry = namedConfigurationBuilderHolder.getNamedConfigurationBuilders().entrySet().iterator().next(); ConfigurationBuilder builder = entry.getValue(); <START> builder.validate(globalConfiguration); <END> configurationOverrides.put(entry.getKey(), builder.build()); } globalComponentRegistry = new GlobalComponentRegistry(this.globalConfiguration, this, caches.keySet()); authzHelper = new AuthorizationHelper(globalConfiguration.security(), AuditContext.CACHEMANAGER, globalConfiguration.globalJmxStatistics().cacheManagerName()); if (start) start(); }</code><technical_language>I create another build method receives GlobalConfiguration parameter. if parameter is null, invokes normal build logic</technical_language>

Target:
public DefaultCacheManager(String globalConfigurationFile, String defaultConfigurationFile, String namedCacheFile, boolean start) throws IOException { ParserRegistry parserRegistry = new ParserRegistry(); ConfigurationBuilderHolder globalConfigurationBuilderHolder = parserRegistry.parseFile(globalConfigurationFile); ConfigurationBuilderHolder defaultConfigurationBuilderHolder = parserRegistry.parseFile(defaultConfigurationFile); globalConfiguration = globalConfigurationBuilderHolder.getGlobalConfigurationBuilder().build(); defaultConfiguration = defaultConfigurationBuilderHolder.getDefaultConfigurationBuilder().build(globalConfiguration); if (namedCacheFile != null) { ConfigurationBuilderHolder namedConfigurationBuilderHolder = parserRegistry.parseFile(namedCacheFile); Entry<String, ConfigurationBuilder> entry = namedConfigurationBuilderHolder.getNamedConfigurationBuilders().entrySet().iterator().next(); ConfigurationBuilder builder = entry.getValue(); configurationOverrides.put(entry.getKey(), builder.build(globalConfiguration)); } globalComponentRegistry = new GlobalComponentRegistry(this.globalConfiguration, this, caches.keySet()); authzHelper = new AuthorizationHelper(globalConfiguration.security(), AuditContext.CACHEMANAGER, globalConfiguration.globalJmxStatistics().cacheManagerName()); if (start) start(); }
Source:
<code><START> public void testLanguages() throws Exception { <END> WikipediaHomePage wikipediaHomePage = new WikipediaHomePage(getDriver()); wikipediaHomePage.open(); String welcomeText = wikipediaHomePage.getWelcomeText(); String expectedWelcomeText = L10N.getText("HomePage.welcomeText"); Assert.assertEquals(welcomeText, expectedWelcomeText, "Wikipedia welcome text was not the expected."); }</code><technical_language>throws Exception - unused. if necessary refactorr methods</technical_language>

Target:
public void testLanguages() { WikipediaHomePage wikipediaHomePage = new WikipediaHomePage(getDriver()); wikipediaHomePage.open(); String welcomeText = wikipediaHomePage.getWelcomeText(); String expectedWelcomeText = L10N.getText("HomePage.welcomeText"); Assert.assertEquals(welcomeText, expectedWelcomeText, "Wikipedia welcome text was not the expected."); }
Source:
<code>public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CustomerToken that = (CustomerToken) o; if (!accessToken.equals(that.accessToken)) return false; if (!customerId.equals(that.customerId)) return false; <START> return expiresAt.equals(that.expiresAt); <END> }</code><technical_language>Do need expiresAt account for equals</technical_language>

Target:
public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CustomerToken that = (CustomerToken) o; if (accessToken != null ? !accessToken.equals(that.accessToken) : that.accessToken != null) return false; return customerId != null ? customerId.equals(that.customerId) : that.customerId == null; }
Source:
<code>private List<IdpConfig> getSelectedProviders() { List<IdpConfig> selectedProviders = new ArrayList<>(); if (mUseGoogleProvider.isChecked()) { selectedProviders.add( new IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER) .setPermissions(getGooglePermissions()) .build()); } if (mUseFacebookProvider.isChecked()) { selectedProviders.add( new IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER) .setPermissions(getFacebookPermissions()) .build()); } if (mUseTwitterProvider.isChecked()) { selectedProviders.add(new IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build()); } if (mUseEmailProvider.isChecked()) { selectedProviders.add(new IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build()); } if (mUsePhoneProvider.isChecked()) { Bundle params = new Bundle(); <START> params.putString(AuthUI.PHONE_VERIFICATION_DEFAULT_PHONE_EXTRA, "+13099126574"); <END> selectedProviders.add( new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER) .setParams(params) .build()); } return selectedProviders; }</code><technical_language>This is a minor point, I putting a random phone number sample confusion. people want this sample test phone auth real number. This type of example snippet belongs in README</technical_language>

Target:
private List<IdpConfig> getSelectedProviders() { List<IdpConfig> selectedProviders = new ArrayList<>(); if (mUseGoogleProvider.isChecked()) { selectedProviders.add( new IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER) .setPermissions(getGooglePermissions()) .build()); } if (mUseFacebookProvider.isChecked()) { selectedProviders.add( new IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER) .setPermissions(getFacebookPermissions()) .build()); } if (mUseTwitterProvider.isChecked()) { selectedProviders.add(new IdpConfig.Builder(AuthUI.TWITTER_PROVIDER).build()); } if (mUseEmailProvider.isChecked()) { selectedProviders.add(new IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build()); } if (mUsePhoneProvider.isChecked()) { selectedProviders.add( new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER).build()); } return selectedProviders; }
Source:
<code>public void updateCourseStructure(List<CourseUnitDto> courses) { Map<Long, Course> courseMap = new HashMap<>(); Map<Long, Chapter> chapterMap = new HashMap<>(); Map<Long, Lesson> lessonMap = new HashMap<>(); Map<Long, Quiz> quizMap = new HashMap<>(); clearRelationships(courses, courseMap, chapterMap, lessonMap, quizMap); for (CourseUnitDto courseUnitDto : courses) { LOGGER.debug("Start processing course with id and name {}", courseUnitDto.getId(), courseUnitDto.getName()); Course course = courseMap.get(courseUnitDto.getId()); if (course == null) { throw new CourseUnitNotFoundException("Cannot find course with id: " + courseUnitDto.getId()); } List<Chapter> chapters = new ArrayList<>(); if (courseUnitDto.getUnits() != null) { for (CourseUnitDto chapterUnitDto : courseUnitDto.getUnits()) { Chapter chapter = getChapter(chapterUnitDto.getId(), chapterMap); setUpLessons(chapterUnitDto, chapter, lessonMap); setUpQuiz((ChapterUnitDto) chapterUnitDto, chapter, quizMap); chapter.setCourse(course); chapter.setState(CourseUnitState.valueOf(chapterUnitDto.getState())); chapters.add(chapter); chapterMap.remove(chapterUnitDto.getId()); } } course.setState(CourseUnitState.valueOf(courseUnitDto.getState())); course.setChapters(chapters); courseMap.remove(courseUnitDto.getId()); <START> courseDataService.evictAllCache(); <END> courseDataService.update(course); } chapterDataService.evictAllCache(); lessonDataService.evictAllCache(); quizDataService.evictAllCache(); updateUnusedRecords(courseMap, chapterMap, lessonMap, quizMap); }</code><technical_language>evictEntityCache below? EvictAllCache clears entire Datanucleus cache for entities</technical_language>

Target:
public void updateCourseStructure(List<CourseUnitDto> courses) { Map<Long, Course> courseMap = new HashMap<>(); Map<Long, Chapter> chapterMap = new HashMap<>(); Map<Long, Lesson> lessonMap = new HashMap<>(); Map<Long, Quiz> quizMap = new HashMap<>(); clearRelationships(courses, courseMap, chapterMap, lessonMap, quizMap); for (CourseUnitDto courseUnitDto : courses) { LOGGER.debug("Start processing course with id and name {}", courseUnitDto.getId(), courseUnitDto.getName()); Course course = courseMap.get(courseUnitDto.getId()); if (course == null) { throw new CourseUnitNotFoundException("Cannot find course with id: " + courseUnitDto.getId()); } List<Chapter> chapters = new ArrayList<>(); if (courseUnitDto.getUnits() != null) { for (CourseUnitDto chapterUnitDto : courseUnitDto.getUnits()) { Chapter chapter = getChapter(chapterUnitDto.getId(), chapterMap); setUpLessons(chapterUnitDto, chapter, lessonMap); setUpQuiz((ChapterUnitDto) chapterUnitDto, chapter, quizMap); chapter.setCourse(course); chapter.setState(CourseUnitState.valueOf(chapterUnitDto.getState())); chapters.add(chapter); chapterMap.remove(chapterUnitDto.getId()); } } course.setState(CourseUnitState.valueOf(courseUnitDto.getState())); course.setChapters(chapters); courseMap.remove(courseUnitDto.getId()); courseDataService.update(course); } courseDataService.evictEntityCache(true); updateUnusedRecords(courseMap, chapterMap, lessonMap, quizMap); }
Source:
<code>public void setParams(MatrixLib value) { if (value != null) { if (value.numCols() != 1 || value.numRows() == 0) { throw new IllegalArgumentException( "The argument passed into setParams is not a column vector"); } initializeProbabilityVector(value); this.hasP = true; <START> int supportSize = 0; <END> for (int i = 0; i < k; i++) { if (!Util.closeToZero(this.p[i])) { supportSize++; } } this.finiteSupport = new Object[supportSize]; int curSupportIndex = 0; for (int i = 0; i < k; i++) { if (!Util.closeToZero(this.p[i])) { this.finiteSupport[curSupportIndex] = i; curSupportIndex++; } } } }</code><technical_language>simply 0 k-1</technical_language>

Target:
public void setParams(MatrixLib value) { if (value != null) { if (value.numCols() != 1 || value.numRows() == 0) { throw new IllegalArgumentException( "The argument passed into setParams is not a column vector"); } initializeProbabilityVector(value); this.hasP = true; this.finiteSupport = null; } }
Source:
<code>static ByteBuf decompressDomainName(ByteBuf compression) { String domainName = decodeDomainName(compression); <START> ByteBuf result = Unpooled.buffer(domainName.length() << 1); <END> encodeDomainName(domainName, result); return result; }</code><technical_language>compression.alloc().buffer(...) ensure allocator is (which a pooled allocated)</technical_language>

Target:
static ByteBuf decompressDomainName(ByteBuf compression) { String domainName = decodeDomainName(compression); ByteBuf result = compression.alloc().buffer(domainName.length() << 1); encodeDomainName(domainName, result); return result; }
Source:
<code>private void validateSchema(final EventTypeBase eventType) throws InvalidEventTypeException { try { final String eventTypeSchema = eventType.getSchema().getSchema(); JsonUtils.checkEventTypeSchemaValid(eventTypeSchema); final JSONObject schemaAsJson = new JSONObject(eventTypeSchema); final Schema schema = SchemaLoader.load(schemaAsJson); if (eventType.getCategory() == EventCategory.BUSINESS && schema.definesProperty("#/metadata")) { throw new InvalidEventTypeException("\"metadata\" property is reserved"); } if (featureToggleService.isFeatureEnabled(CHECK_PARTITIONS_KEYS)) { validatePartitionKeys(schema, eventType); } if (eventType.getCompatibilityMode() != CompatibilityMode.NONE) { <START> validateJsonSchemaConstraints(eventType, schemaAsJson); <END> } } catch (final JSONException e) { throw new InvalidEventTypeException("schema must be a valid json"); } catch (final SchemaException e) { throw new InvalidEventTypeException("schema must be a valid json-schema"); } }</code><technical_language>compatibility mode is validate constraints, event type. sense pass compatibility mode only</technical_language>

Target:
private void validateSchema(final EventTypeBase eventType) throws InvalidEventTypeException { try { final String eventTypeSchema = eventType.getSchema().getSchema(); JsonUtils.checkEventTypeSchemaValid(eventTypeSchema); final JSONObject schemaAsJson = new JSONObject(eventTypeSchema); validateJsonSchemaConstraints(eventType.getCompatibilityMode(), schemaAsJson); final Schema schema = SchemaLoader.load(schemaAsJson); if (eventType.getCategory() == EventCategory.BUSINESS && schema.definesProperty("#/metadata")) { throw new InvalidEventTypeException("\"metadata\" property is reserved"); } if (featureToggleService.isFeatureEnabled(CHECK_PARTITIONS_KEYS)) { validatePartitionKeys(schema, eventType); } } catch (final JSONException e) { throw new InvalidEventTypeException("schema must be a valid json"); } catch (final SchemaException e) { throw new InvalidEventTypeException("schema must be a valid json-schema"); } }
Source:
<code>private ExecutionFailureInfo rewriteTransportFailure(ExecutionFailureInfo executionFailureInfo) { if (executionFailureInfo.getRemoteHost() != null && failureDetector.getState(executionFailureInfo.getRemoteHost()) == GONE) { return new ExecutionFailureInfo( executionFailureInfo.getType(), executionFailureInfo.getMessage(), executionFailureInfo.getCause(), executionFailureInfo.getSuppressed(), executionFailureInfo.getStack(), executionFailureInfo.getErrorLocation(), REMOTE_HOST_GONE.toErrorCode(), executionFailureInfo.getRemoteHost()); } <START> else { <END> return executionFailureInfo; } }</code><technical_language>unnecessary else</technical_language>

Target:
private ExecutionFailureInfo rewriteTransportFailure(ExecutionFailureInfo executionFailureInfo) { if (executionFailureInfo.getRemoteHost() == null || failureDetector.getState(executionFailureInfo.getRemoteHost()) != GONE) { return executionFailureInfo; } return new ExecutionFailureInfo( executionFailureInfo.getType(), executionFailureInfo.getMessage(), executionFailureInfo.getCause(), executionFailureInfo.getSuppressed(), executionFailureInfo.getStack(), executionFailureInfo.getErrorLocation(), REMOTE_HOST_GONE.toErrorCode(), executionFailureInfo.getRemoteHost()); }
Source:
<code>public void onSaveClicked() { final CommandConfiguration selectedConfiguration; if (view.getSelectedConfiguration() == null) { return; } onNameChanged(); selectedConfiguration = view.getSelectedConfiguration(); updateCommand(selectedConfiguration).then(new Operation<WorkspaceDto>() { @Override public void apply(WorkspaceDto arg) throws OperationException { commandProcessingCallback = getCommandProcessingCallback(); fetchCommands(); fireConfigurationUpdated(selectedConfiguration); } }).catchError(new Operation<PromiseError>() { @Override public void apply(PromiseError arg) throws OperationException { <START> dialogFactory.createMessageDialog("Error", arg.toString(), null).show(); <END> } }); }</code><technical_language>plz, arg.getMessage() instead of arg.toString() toString() returns interesting for user</technical_language>

Target:
public void onSaveClicked() { final CommandConfiguration selectedConfiguration; if (view.getSelectedConfiguration() == null) { return; } onNameChanged(); selectedConfiguration = view.getSelectedConfiguration(); updateCommand(selectedConfiguration).then(new Operation<WorkspaceDto>() { @Override public void apply(WorkspaceDto arg) throws OperationException { commandProcessingCallback = getCommandProcessingCallback(); fetchCommands(); fireConfigurationUpdated(selectedConfiguration); } }).catchError(new Operation<PromiseError>() { @Override public void apply(PromiseError arg) throws OperationException { dialogFactory.createMessageDialog("Error", arg.getMessage(), null).show(); } }); }
Source:
<code><START> public Builder withCosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential) { <END> if (cosmosKeyCredential != null && StringUtils.isEmpty(cosmosKeyCredential.getMasterKey())) { throw new IllegalArgumentException("Cannot build client with empty key credential"); } this.cosmosKeyCredential = cosmosKeyCredential; return this; }</code><technical_language>Out of scope for this PR</technical_language>

Target:
public Builder withCosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential) { if (cosmosKeyCredential != null && StringUtils.isEmpty(cosmosKeyCredential.key())) { throw new IllegalArgumentException("Cannot build client with empty key credential"); } this.cosmosKeyCredential = cosmosKeyCredential; return this; }
Source:
<code>public void getCreatedOffers() { final String offerToken = createOffer(user, "test", AccessLevel.WRITE, null); PermissionManager pm = user.getPermissionManager(); looperThread.closeAfterTest(pm); pm.getCreatedOffers(new PermissionManager.OffersCallback() { @Override public void onSuccess(RealmResults<PermissionOffer> offers) { RealmResults filteredOffers = offers.where() .equalTo("token", offerToken) .findAllAsync(); looperThread.keepStrongReference(offers); filteredOffers.addChangeListener(new RealmChangeListener<RealmResults>() { @Override public void onChange(RealmResults results) { switch (results.size()) { case 0: return; case 1: looperThread.testComplete(); break; <START> case 2: <END> fail("To many offers: " + Arrays.toString(results.toArray())); } } }); } @Override public void onError(ObjectServerError error) { fail(error.toString()); } }); }</code><technical_language>default instead? If more 2</technical_language>

Target:
public void getCreatedOffers() { final String offerToken = createOffer(user, "test", AccessLevel.WRITE, null); PermissionManager pm = user.getPermissionManager(); looperThread.closeAfterTest(pm); pm.getCreatedOffers(new PermissionManager.OffersCallback() { @Override public void onSuccess(RealmResults<PermissionOffer> offers) { RealmResults filteredOffers = offers.where() .equalTo("token", offerToken) .findAllAsync(); looperThread.keepStrongReference(offers); filteredOffers.addChangeListener(new RealmChangeListener<RealmResults>() { @Override public void onChange(RealmResults results) { switch (results.size()) { case 0: return; case 1: looperThread.testComplete(); break; default: fail("To many offers: " + Arrays.toString(results.toArray())); } } }); } @Override public void onError(ObjectServerError error) { fail(error.toString()); } }); }
Source:
<code>private void sendMessage(final RawData message, final DTLSSession session) { try { final CorrelationContext ctx = new DtlsCorrelationContext( session.getSessionIdentifier().toString(), String.valueOf(session.getWriteEpoch()), session.getWriteStateCipher()); if (!checkOutboundCorrelationContext(message, ctx)) { return; } Record record = new Record( ContentType.APPLICATION_DATA, session.getWriteEpoch(), session.getSequenceNumber(), new ApplicationMessage(message.getBytes(), message.getInetSocketAddress()), session); <START> sendRecord(record); <END> message.onSent(ctx); } catch (GeneralSecurityException e) { LOGGER.log(Level.FINE, String.format("Cannot send APPLICATION record to peer [%s]", message.getInetSocketAddress()), e); } }</code><technical_language>if API better, I some concerns correlation context is upper layer record sent. I this involve some race condition issues. WDYT</technical_language>

Target:
private void sendMessage(final RawData message, final DTLSSession session) { try { final CorrelationContext ctx = new DtlsCorrelationContext( session.getSessionIdentifier().toString(), String.valueOf(session.getWriteEpoch()), session.getWriteStateCipher()); if (!checkOutboundCorrelationContext(message, ctx)) { return; } message.onContextEstablished(ctx); Record record = new Record( ContentType.APPLICATION_DATA, session.getWriteEpoch(), session.getSequenceNumber(), new ApplicationMessage(message.getBytes(), message.getInetSocketAddress()), session); sendRecord(record); message.onSent(); } catch (IOException e) { message.onError(e); } catch (GeneralSecurityException e) { LOGGER.log(Level.FINE, String.format("Cannot send APPLICATION record to peer [%s]", message.getInetSocketAddress()), e); message.onError(e); } }
Source:
<code>public void staffUserCanMoveThreadToOtherBoard() { ForumPageObject forumMainPage = new ForumPageObject(driver); <START> String title = PageContent.FORUM_TITLE_PREFIX + forumMainPage.getTimeStamp(); <END> String message = PageContent.FORUM_MESSAGE + forumMainPage.getTimeStamp(); forumMainPage.openForumMainPage(wikiURL); List<String> forumNames = forumMainPage.getForumNamesList(); ForumBoardPageObject forumBoard = forumMainPage.openForumBoard(); ForumThreadPageObject forumThread = forumBoard.startDiscussion(title, message, false); forumThread.verifyDiscussionTitleAndMessage(title, message); forumThread.moveThread(forumNames.get(1)); forumThread.verifyParentBoard(forumNames.get(1)); }</code><technical_language>format</technical_language>

Target:
public void staffUserCanMoveThreadToOtherBoard() { ForumPageObject forumMainPage = new ForumPageObject(driver); String title = String.format(PageContent.FORUM_TITLE_PREFIX, forumMainPage.getTimeStamp()); String message = String.format(PageContent.FORUM_MESSAGE + forumMainPage.getTimeStamp()); forumMainPage.openForumMainPage(wikiURL); List<String> forumNames = forumMainPage.getForumNamesList(); ForumBoardPageObject forumBoard = forumMainPage.openForumBoard(); ForumThreadPageObject forumThread = forumBoard.startDiscussion(title, message, false); forumThread.verifyDiscussionTitleAndMessage(title, message); forumThread.moveThread(forumNames.get(1)); forumThread.verifyParentBoard(forumNames.get(1)); }
Source:
<code>private DefaultExecutorListProviderImpl( @Parameter(NumExecutors.class) final int numExecutors) throws InjectionException { this.executors = new LinkedList<>(); for (int i = 0; i < numExecutors; i++) { final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder(); <START> jcb.bindNamedParameter(MistExecutorId.class, "MistExecutor-" + i); <END> final Injector injector = Tang.Factory.getTang().newInjector(jcb.build()); final MistExecutor executor = injector.getInstance(MistExecutor.class); this.executors.add(executor); } }</code><technical_language>I formatted string here, instead of simple + operator</technical_language>

Target:
private DefaultExecutorListProviderImpl( @Parameter(NumExecutors.class) final int numExecutors) throws InjectionException { if (numExecutors <= 0) { throw new RuntimeException("The number of executors should be greater than zero"); } this.executors = new LinkedList<>(); for (int i = 0; i < numExecutors; i++) { final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder(); final StringBuffer sb = new StringBuffer(); sb.append("MistExecutor-"); sb.append(i); jcb.bindNamedParameter(MistExecutorId.class, sb.toString()); final Injector injector = Tang.Factory.getTang().newInjector(jcb.build()); final MistExecutor executor = injector.getInstance(MistExecutor.class); this.executors.add(executor); } }
Source:
<code>public int getTreeDepth() { <START> if (currVisit == null) <END> return 0; return currVisit.depth; }</code><technical_language>style nit: missing braces</technical_language>

Target:
public int getTreeDepth() { if (currVisit == null) { return 0; } return currVisit.depth; }
Source:
<code>public static boolean confirmHardReset(Shell shell, final Repository repo) { String question = UIText.ResetTargetSelectionDialog_ResetConfirmQuestion; ILaunchConfiguration launch = LaunchFinder .getRunningLaunchConfiguration(Collections.singleton(repo), null); if (launch != null) { question = MessageFormat.format(question, "\n\n" + MessageFormat.format( UIText.LaunchFinder_RunningLaunchMessage, launch.getName())); } else { question = MessageFormat.format(question, ""); } MessageDialog messageDialog = new MessageDialog(shell, UIText.ResetTargetSelectionDialog_ResetQuestion, null, question, MessageDialog.QUESTION, 0, UIText.CommandConfirmationHardResetDialog_resetButtonLabel, <START> IDialogConstants.NO_LABEL); <END> return messageDialog.open() == Window.OK; }</code><technical_language>discussed bugzilla, this CANCEL_LABEL</technical_language>

Target:
public static boolean confirmHardReset(Shell shell, final Repository repo) { String question = UIText.ResetTargetSelectionDialog_ResetConfirmQuestion; ILaunchConfiguration launch = LaunchFinder .getRunningLaunchConfiguration(Collections.singleton(repo), null); if (launch != null) { question = MessageFormat.format(question, "\n\n" + MessageFormat.format( UIText.LaunchFinder_RunningLaunchMessage, launch.getName())); } else { question = MessageFormat.format(question, ""); } MessageDialog messageDialog = new MessageDialog(shell, UIText.ResetTargetSelectionDialog_ResetQuestion, null, question, MessageDialog.QUESTION, 0, UIText.CommandConfirmationHardResetDialog_resetButtonLabel, IDialogConstants.CANCEL_LABEL); return messageDialog.open() == Window.OK; }
Source:
<code>public void visitToken(DetailAST ast) { final ComponentCounter counter = new ComponentCounter(); <START> countComponents(counter, ast); <END> checkCounter(counter, ast); }</code><technical_language>Return a this method</technical_language>

Target:
public void visitToken(DetailAST ast) { final DetailAST modifiers = ast.findFirstToken(TokenTypes.MODIFIERS); final AccessModifierOption accessModifier = CheckUtil.getAccessModifierFromModifiersToken(modifiers); if (matchAccessModifiers(accessModifier)) { final DetailAST recordComponents = ast.findFirstToken(TokenTypes.RECORD_COMPONENTS); final int componentCount = countComponents(recordComponents); if (componentCount > max) { log(ast, MSG_KEY, componentCount, max); } } }
Source:
<code>QosIoException(QosException qosException, Response response) { <START> super("Failed to complete the request due to a server-side QoS condition"); <END> this.qosException = qosException; this.response = response; }</code><technical_language>Suggest putting status code message in case this escapes + is logged</technical_language>

Target:
QosIoException(QosException qosException, Response response) { super("Failed to complete the request due to a server-side QoS condition: " + response.code(), qosException); this.qosException = qosException; this.response = response; }
Source:
<code>public String getWorkflowDag(@ApiParam(hidden = true) @Auth Optional<User> user, @ApiParam(value = "workflowId", required = true) @PathParam("workflowId") Long workflowId, @ApiParam(value = "workflowVersionId", required = true) @PathParam("workflowVersionId") Long workflowVersionId) { Workflow workflow = workflowDAO.findById(workflowId); checkEntry(workflow); checkOptionalAuthRead(user, workflow); WorkflowVersion workflowVersion = getWorkflowVersion(workflow, workflowVersionId); SourceFile mainDescriptor = getMainDescriptorFile(workflowVersion); if (workflowVersion.getDagJson() != null) { return workflowVersion.getDagJson(); } if (mainDescriptor != null) { Set<SourceFile> secondaryDescContent = extractDescriptorAndSecondaryFiles(workflowVersion); LanguageHandlerInterface lInterface = LanguageHandlerFactory.getInterface(workflow.getFileType()); <START> String dagJson = lInterface.getCleanDAG(workflowVersion.getWorkflowPath(), mainDescriptor.getContent(), secondaryDescContent, <END> LanguageHandlerInterface.Type.DAG, toolDAO); if (workflowVersion.getReferenceType() == Version.ReferenceType.TAG && workflowVersion.isValid()) { workflowVersion.setDagJson(dagJson); } return dagJson; } return null; }</code><technical_language>I suggest in habit of declaring local variables final. configure IntelliJ create for default. is nit-picky, for example, reviewing, if I final, I I if is modified then</technical_language>

Target:
public String getWorkflowDag(@ApiParam(hidden = true) @Auth Optional<User> user, @ApiParam(value = "workflowId", required = true) @PathParam("workflowId") Long workflowId, @ApiParam(value = "workflowVersionId", required = true) @PathParam("workflowVersionId") Long workflowVersionId) { Workflow workflow = workflowDAO.findById(workflowId); checkEntry(workflow); checkOptionalAuthRead(user, workflow); WorkflowVersion workflowVersion = getWorkflowVersion(workflow, workflowVersionId); SourceFile mainDescriptor = getMainDescriptorFile(workflowVersion); if (workflowVersion.getDagJson() != null) { return workflowVersion.getDagJson(); } if (mainDescriptor != null) { Set<SourceFile> secondaryDescContent = extractDescriptorAndSecondaryFiles(workflowVersion); LanguageHandlerInterface lInterface = LanguageHandlerFactory.getInterface(workflow.getFileType()); final String dagJson = lInterface.getCleanDAG(workflowVersion.getWorkflowPath(), mainDescriptor.getContent(), secondaryDescContent, LanguageHandlerInterface.Type.DAG, toolDAO); workflowVersion.setDagJson(dagJson); return dagJson; } return null; }
Source:
<code>public String captureGesture(String gestureName) { StringBuffer script = new StringBuffer(); <START> DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); <END> Date date = new Date(); String indentSpace = ""; script.append("# - " + date + " - Captured gesture :\n"); if (gestureName != null) { indentSpace = " "; script.append(String.format("def %s():\n", gestureName)); } if (head != null) { script.append(indentSpace); script.append(head.getScript(getName())); } if (leftArm != null) { script.append(indentSpace); script.append(leftArm.getScript(getName())); } if (rightArm != null) { script.append(indentSpace); script.append(rightArm.getScript(getName())); } if (leftHand != null) { script.append(indentSpace); script.append(leftHand.getScript(getName())); } if (rightHand != null) { script.append(indentSpace); script.append(rightHand.getScript(getName())); } if (torso != null) { script.append(indentSpace); script.append(torso.getScript(getName())); } if (eyelids != null) { script.append(indentSpace); script.append(eyelids.getScript(getName())); } send("python", "appendScript", script.toString()); return script.toString(); }</code><technical_language>create this object a private member variable of class, re-creating time used</technical_language>

Target:
public String captureGesture(String gestureName) { StringBuffer script = new StringBuffer(); Date date = new Date(); String indentSpace = ""; script.append("# - " + date + " - Captured gesture :\n"); if (gestureName != null) { indentSpace = " "; script.append(String.format("def %s():\n", gestureName)); } if (head != null) { script.append(indentSpace); script.append(head.getScript(getName())); } if (leftArm != null) { script.append(indentSpace); script.append(leftArm.getScript(getName())); } if (rightArm != null) { script.append(indentSpace); script.append(rightArm.getScript(getName())); } if (leftHand != null) { script.append(indentSpace); script.append(leftHand.getScript(getName())); } if (rightHand != null) { script.append(indentSpace); script.append(rightHand.getScript(getName())); } if (torso != null) { script.append(indentSpace); script.append(torso.getScript(getName())); } if (eyelids != null) { script.append(indentSpace); script.append(eyelids.getScript(getName())); } send("python", "appendScript", script.toString()); return script.toString(); }
Source:
<code>protected void installLocations() { super.installLocations(); bind(ImplicitLocationSupplier.class) .to(OnlyLocationOrFirstZone.class) .in(Scopes.SINGLETON); <START> } <END></code><technical_language>This working before. If discard changes in location transformation function, discard changes in this class too</technical_language>

Target:
protected void installLocations() { super.installLocations(); bind(ImplicitLocationSupplier.class).to(FirstRegion.class).in(Scopes.SINGLETON); }
Source:
<code>public ParameterizedState(final List<Parameter<T, ?>> parameters) { Utils.nonNull(parameters, "List of parameters cannot be null."); Utils.nonEmpty(parameters, "List of parameters cannot be empty."); <START> final LinkedHashMap<T, Parameter<T, ?>> map = new LinkedHashMap<>(); <END> for (final Parameter<T, ?> parameter : parameters) { final T key = parameter.getName(); if (map.containsKey(key)) { throw new IllegalArgumentException("List of parameters cannot contain duplicate parameter key names."); } map.put(parameter.getName(), parameter); } final Class<T> keyClass = parameters.get(0).getName().getDeclaringClass(); final Set<T> keySet = EnumSet.allOf(keyClass); if (!keySet.equals(map.keySet())) { throw new IllegalArgumentException("List of parameters does not contain all parameters specified by ParameterEnum."); } parameterMap = map; }</code><technical_language>this constructor is performance-sensitive, I separate logic of 1) checking for duplicates 2) adding parameters. java final int numUniqueParameters = parameters.stream().map(Parameter::getName).distinct().count(); Utils.validateArg(numUniqueParameters == parameters.size(), "Parameters duplicates."); final LinkedHashMap<T, Parameter<T, ?>> map = new LinkedHashMap<>(); parameters.stream().forEach(p -> map.put(p.getName(), p);</technical_language>

Target:
public ParameterizedState(final List<Parameter<T, ?>> parameters) { Utils.nonNull(parameters, "List of parameters cannot be null."); Utils.nonEmpty(parameters, "List of parameters cannot be empty."); final int numUniqueParameters = (int) parameters.stream().map(Parameter::getName).distinct().count(); Utils.validateArg(numUniqueParameters == parameters.size(), "List of parameters may not contain duplicates."); final LinkedHashMap<T, Parameter<T, ?>> map = new LinkedHashMap<>(); parameters.stream().forEach(p -> map.put(p.getName(), p)); final Class<T> keyClass = parameters.get(0).getName().getDeclaringClass(); final Set<T> keySet = EnumSet.allOf(keyClass); Utils.validateArg(keySet.equals(map.keySet()), "List of parameters does not contain all parameters specified by ParameterEnum."); parameterMap = map; }
Source:
<code>protected void execute(ProcessContext process) throws Exception { process.log("Computing changes..."); schema.computeRequiredSchemaChanges(); process.log("Exporting changes..."); Map<String, PrintWriter> writers = new HashMap<>(); try { for (SchemaUpdateAction action : schema.getSchemaUpdateActions()) { PrintWriter writer = writers.computeIfAbsent(action.getRealm(), realm -> createWriter(process, realm)); action.getSql().forEach(writer::print); <START> writer.print(";"); <END> writer.println(); } } finally { writers.values().forEach(writer -> safeCloseWriter(writer, process)); } }</code><technical_language>statement of action ;</technical_language>

Target:
protected void execute(ProcessContext process) throws Exception { process.log("Computing changes..."); schema.computeRequiredSchemaChanges(); process.log("Exporting changes..."); Map<String, PrintWriter> writers = new HashMap<>(); try { for (SchemaUpdateAction action : schema.getSchemaUpdateActions()) { PrintWriter writer = writers.computeIfAbsent(action.getRealm(), realm -> createWriter(process, realm)); action.getSql().stream().map(sql -> sql + ";\n").forEach(writer::print); } } finally { writers.values().forEach(writer -> safeCloseWriter(writer, process)); } }
Source:
<code>public FileManager(String dataFolder) { if (dataFolder == null || "".equals(dataFolder)) { dataFolder = Paths.get(System.getProperty("java.io.tmpdir"), "blynk").toString(); } try { this.dataDir = createDatadir(dataFolder); <START> this.deletedDataDir = createDatadir(String.format("%s/%s", dataFolder, DELETED_DATA_DIR_NAME)); <END> } catch (RuntimeException e) { this.dataDir = createDatadir(Paths.get(System.getProperty("java.io.tmpdir"), "blynk")); this.deletedDataDir = createDatadir(String.format("%s/%s", this.dataDir.toString(), DELETED_DATA_DIR_NAME)); } log.info("Using data dir '{}'", dataDir); }</code><technical_language>need Paths.get instead of formatting. This code is system dependent</technical_language>

Target:
public FileManager(String dataFolder) { if (dataFolder == null || "".equals(dataFolder)) { dataFolder = Paths.get(System.getProperty("java.io.tmpdir"), "blynk").toString(); } try { this.dataDir = createDatadir(dataFolder); this.deletedDataDir = createDatadir(Paths.get(dataFolder, DELETED_DATA_DIR_NAME)); } catch (RuntimeException e) { this.dataDir = createDatadir(Paths.get(System.getProperty("java.io.tmpdir"), "blynk")); this.deletedDataDir = createDatadir(Paths.get(this.dataDir.toString(), DELETED_DATA_DIR_NAME)); } log.info("Using data dir '{}'", dataDir); }
Source:
<code>private static List<SimpleInterval> constructUntrimmedSegments(final Genome genome, final SortedMap<String, List<Breakpoint>> breakpointsByContig) { final List<SimpleInterval> segments = new ArrayList<>(); for (final String contig : breakpointsByContig.keySet()) { final List<Breakpoint> breakpoints = breakpointsByContig.get(contig); int start = breakpoints.get(0).getStart(); for (int i = 1; i < breakpoints.size(); i++) { final Breakpoint breakpoint = breakpoints.get(i); <START> int end; <END> switch (breakpoint.getType()) { case START: end = breakpoint.getSite() - 1; break; case END: end = breakpoint.getSite(); break; default: throw new GATKException.ShouldNeverReachHereException("Unknown breakpoint type in segment union."); } if (end < start) { continue; } final SimpleInterval segment = new SimpleInterval(contig, start, end); if (genome.getTargets().targetCount(segment) > 0 || genome.getSNPs().targetCount(segment) > 0) { segments.add(segment); } start = segment.getEnd() + 1; } } return segments; }</code><technical_language>final int end = breakpoint.getSite() - (breakpoint.getType() == START ? 1 : 0)</technical_language>

Target:
private static List<SimpleInterval> constructUntrimmedSegments(final Genome genome, final SortedMap<String, List<Breakpoint>> breakpointsByContig) { final List<SimpleInterval> segments = new ArrayList<>(); for (final String contig : breakpointsByContig.keySet()) { final List<Breakpoint> breakpoints = breakpointsByContig.get(contig); int start = breakpoints.get(0).getStart(); for (int i = 1; i < breakpoints.size(); i++) { final Breakpoint breakpoint = breakpoints.get(i); final int end = breakpoint.getSite() - (breakpoint.getType() == BreakpointType.START ? 1 : 0); if (end < start) { continue; } final SimpleInterval segment = new SimpleInterval(contig, start, end); if (genome.getTargets().targetCount(segment) > 0 || genome.getSNPs().targetCount(segment) > 0) { segments.add(segment); } start = segment.getEnd() + 1; } } return segments; }
Source:
<code>public boolean restart(Integer containerId) { if (containerId == null) { throw new UnsupportedOperationException("Not implemented"); } if (stateMgrAdaptor == null) { LOG.warning("SchedulerStateManagerAdaptor not initialized"); return false; } StMgr contaienrInfo = stateMgrAdaptor.getPhysicalPlan(topologyName).getStmgrs(containerId); <START> String ip = contaienrInfo.getHostName(); <END> int port = contaienrInfo.getShellPort(); String url = "http://" + ip + ":" + port + "/killexecutor"; String payload = "secret=" + topologyName; LOG.info("sending `kill container` to " + url + "; payload: " + payload); HttpURLConnection con = NetworkUtils.getHttpConnection(url); NetworkUtils.sendHttpPostRequest(con, "X", payload.getBytes()); boolean ret = NetworkUtils.checkHttpResponseCode(con, 200); con.disconnect(); return ret; }</code><technical_language>call variable host hostname. ip is confusing here</technical_language>

Target:
public boolean restart(Integer containerId) { if (containerId == null) { throw new UnsupportedOperationException("Not implemented"); } if (stateMgrAdaptor == null) { LOG.warning("SchedulerStateManagerAdaptor not initialized"); return false; } StMgr contaienrInfo = stateMgrAdaptor.getPhysicalPlan(topologyName).getStmgrs(containerId); String host = contaienrInfo.getHostName(); int port = contaienrInfo.getShellPort(); String url = "http://" + host + ":" + port + "/killexecutor"; String payload = "secret=" + topologyName; LOG.info("sending `kill container` to " + url + "; payload: " + payload); HttpURLConnection con = NetworkUtils.getHttpConnection(url); try { NetworkUtils.sendHttpPostRequest(con, "X", payload.getBytes()); return NetworkUtils.checkHttpResponseCode(con, 200); } finally { con.disconnect(); } }
Source:
<code>public void testAcceptableTokensMakeSense() { <START> final int expectedTokenTypesTotalNumber = 170; <END> assertEquals(expectedTokenTypesTotalNumber, TokenUtil.getTokenTypesTotalNumber(), "Total number of TokenTypes has changed, acceptable tokens in" + " IllegalTokenTextCheck need to be reconsidered."); final IllegalTokenTextCheck check = new IllegalTokenTextCheck(); final int[] allowedTokens = check.getAcceptableTokens(); final List<Integer> tokenTypesWithMutableText = Arrays.asList( TokenTypes.NUM_DOUBLE, TokenTypes.NUM_FLOAT, TokenTypes.NUM_INT, TokenTypes.NUM_LONG, TokenTypes.IDENT, TokenTypes.COMMENT_CONTENT, TokenTypes.STRING_LITERAL, TokenTypes.CHAR_LITERAL ); for (int tokenType : allowedTokens) { assertTrue(tokenTypesWithMutableText.contains(tokenType), TokenUtil.getTokenName(tokenType) + " should not be allowed" + " in this check as its text is a constant (IllegalTokenCheck should be used for" + " such cases)."); } }</code><technical_language>I do changes</technical_language>

Target:
public void testAcceptableTokensMakeSense() { final int expectedTokenTypesTotalNumber = 171; assertEquals(expectedTokenTypesTotalNumber, TokenUtil.getTokenTypesTotalNumber(), "Total number of TokenTypes has changed, acceptable tokens in" + " IllegalTokenTextCheck need to be reconsidered."); final IllegalTokenTextCheck check = new IllegalTokenTextCheck(); final int[] allowedTokens = check.getAcceptableTokens(); final List<Integer> tokenTypesWithMutableText = Arrays.asList( TokenTypes.NUM_DOUBLE, TokenTypes.NUM_FLOAT, TokenTypes.NUM_INT, TokenTypes.NUM_LONG, TokenTypes.IDENT, TokenTypes.COMMENT_CONTENT, TokenTypes.STRING_LITERAL, TokenTypes.CHAR_LITERAL ); for (int tokenType : allowedTokens) { assertTrue(tokenTypesWithMutableText.contains(tokenType), TokenUtil.getTokenName(tokenType) + " should not be allowed" + " in this check as its text is a constant (IllegalTokenCheck should be used for" + " such cases)."); } }
Source:
<code>public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> hostSubjects = vdsIds.stream() .map(vdsId -> new PermissionSubject(vdsId, VdcObjectType.VDS, getActionType().getActionGroup())) .collect(Collectors.toList()); <START> hostSubjects.add(new PermissionSubject(getClusterId(), VdcObjectType.Cluster, ActionGroup.CONFIGURE_HOST_NETWORK)); <END> return hostSubjects; }</code><technical_language>Is this compatible</technical_language>

Target:
public List<PermissionSubject> getPermissionCheckSubjects() { return vdsIds.stream() .map(vdsId -> new PermissionSubject(vdsId, VdcObjectType.VDS, getActionType().getActionGroup())) .collect(Collectors.toList()); }
Source:
<code>private String findCheckpointDir() throws Exception { final List<Path> checkpoint = new ArrayList<>(); <START> CommonUtils.waitFor("Checkpoint list:", () -> { <END> List<Path> checkpointTest = null; try { checkpointTest = Files.list(mDumpDir.toPath()) .filter(p -> p.toString().contains("checkpoints-")).collect(toList()); } catch (IOException e) { throw new RuntimeException(e); } if (checkpointTest.size() == 0) { return false; } else if (checkpointTest.size() == 1) { checkpoint.add(checkpointTest.get(0)); return true; } fail("Unexpected checkpoint list: " + checkpoint); return false; }, WaitForOptions.defaults().setTimeoutMs(500)); return checkpoint.get(0).toString(); }</code><technical_language>do "wait" part for list of paths? get non-empty list of paths, do previous/existing assert of size? current implementation of this function is condition terminate wait, asserts. prefer this wait function determines termination condition for wait, do assert of wait</technical_language>

Target:
private String findCheckpointDir() throws Exception { final List<Path> checkpoint = new ArrayList<>(); CommonUtils.waitFor("Checkpoint list:", () -> { List<Path> checkpointTest = null; try { checkpointTest = Files.list(mDumpDir.toPath()) .filter(p -> p.toString().contains("checkpoints-")).collect(toList()); } catch (IOException e) { throw new RuntimeException(e); } if (checkpointTest.size() == 0) { return false; } checkpoint.addAll(checkpointTest); return true; }, WaitForOptions.defaults().setTimeoutMs(500)); assertEquals("Unexpected checkpoint list: " + checkpoint, 1, checkpoint.size()); return checkpoint.get(0).toString(); }
Source:
<code>public void importObject(Reader reader) throws IOException { Rules existingRules = curator.getRules(); Rules newRules = new Rules(StringFromReader.asString(reader)); if (VersionUtil.getRulesVersionCompatibility(existingRules.getVersion(), newRules.getVersion())) { log.info("Importing new rules from manifest, current version: " + existingRules.getVersion() + " new version: " + newRules.getVersion()); curator.update(newRules); sink.emitRulesModified(existingRules, newRules); <START> jsProvider.get(); <END> } else { log.info("Ignoring older rules in manifest, current version: " + existingRules.getVersion() + " new version: " + newRules.getVersion()); } }</code><technical_language>compileRules public call directly? .get appears create some context a new runner. If interested in a recompile, save a bit of work there</technical_language>

Target:
public void importObject(Reader reader) throws IOException { Rules existingRules = curator.getRules(); Rules newRules = new Rules(StringFromReader.asString(reader)); if (VersionUtil.getRulesVersionCompatibility(existingRules.getVersion(), newRules.getVersion())) { log.info("Importing new rules from manifest, current version: " + existingRules.getVersion() + " new version: " + newRules.getVersion()); curator.update(newRules); sink.emitRulesModified(existingRules, newRules); jsProvider.compileRules(); } else { log.info("Ignoring older rules in manifest, current version: " + existingRules.getVersion() + " new version: " + newRules.getVersion()); } }
Source:
<code>private List<String> sparkClasspath() { String sparkJars = System.getProperty("spark.jars"); <START> Pattern isKotlinJar = Pattern.compile("/kotlin-(runtime|stdlib|compiler|reflect)(-.*)?\\.jar"); <END> Stream<File> addedJars = Arrays.stream(Utils.resolveURIs(sparkJars).split(",")) .filter(s -> !s.trim().equals("")) .filter(s -> !isKotlinJar.matcher(s).find()) .map(s -> { int p = s.indexOf(':'); return new File(s.substring(p + 1)); }); Stream<File> systemJars = Arrays.stream( System.getProperty("java.class.path").split(File.pathSeparator)) .map(File::new); return Stream.concat(addedJars, systemJars) .map(file -> { try { return file.getCanonicalPath(); } catch (IOException e) { return ""; } }) .collect(Collectors.toList()); }</code><technical_language>this pattern simplified /kotlin-[a-z]*(-.*)?\\.jar? I suppose want change this regex time new jar is added</technical_language>

Target:
private static List<String> sparkClasspath() { String sparkJars = System.getProperty("spark.jars"); Pattern isKotlinJar = Pattern.compile("/kotlin-[a-z]*(-.*)?\\.jar"); Stream<File> addedJars = Arrays.stream(Utils.resolveURIs(sparkJars).split(",")) .filter(s -> !s.trim().equals("")) .filter(s -> !isKotlinJar.matcher(s).find()) .map(s -> { int p = s.indexOf(':'); return new File(s.substring(p + 1)); }); Stream<File> systemJars = Arrays.stream( System.getProperty("java.class.path").split(File.pathSeparator)) .map(File::new); return Stream.concat(addedJars, systemJars) .map(file -> { try { return file.getCanonicalPath(); } catch (IOException e) { return ""; } }) .collect(Collectors.toList()); }