auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void subscribe_renderGroup() { String sectionLabel = "section label"; <START> String questionLabel = "question label"; <END> List<Section> sectionList = getSectionList(sectionLabel, questionLabel, "group"); when(mPage.getSections()).thenReturn(sectionList); LinearLayout sectionLayout = new LinearLayout(Cache.getContext()); when(mFormDisplayPageView.createSectionLayout(sectionLabel)).thenReturn(sectionLayout); LinearLayout questionLayout = new LinearLayout(Cache.getContext()); when(mFormDisplayPageView.createQuestionGroupLayout(questionLabel)).thenReturn(questionLayout); presenter.subscribe(); verify(mFormDisplayPageView).createSectionLayout(sectionList.get(0).getLabel()); verify(mFormDisplayPageView).attachSectionToView(sectionLayout); verify(mFormDisplayPageView).attachQuestionToSection(sectionLayout, questionLayout); }</code><technical_language>@shivtej1505 values in test constants ? If yest apply change feel free merge :)</technical_language>

Target:
public void subscribe_renderGroup() { List<Section> sectionList = getSectionList(sectionLabel, questionLabel, "group"); when(mPage.getSections()).thenReturn(sectionList); LinearLayout sectionLayout = new LinearLayout(Cache.getContext()); when(mFormDisplayPageView.createSectionLayout(sectionLabel)).thenReturn(sectionLayout); LinearLayout questionLayout = new LinearLayout(Cache.getContext()); when(mFormDisplayPageView.createQuestionGroupLayout(questionLabel)).thenReturn(questionLayout); presenter.subscribe(); verify(mFormDisplayPageView).createSectionLayout(sectionList.get(0).getLabel()); verify(mFormDisplayPageView).attachSectionToView(sectionLayout); verify(mFormDisplayPageView).attachQuestionToSection(sectionLayout, questionLayout); }
Source:
<code>public String getQualifiedName() { return <START> StyleResolver.getQualifiedItemName(mySelectedValue.myValue); <END> }</code><technical_language>do call getSelectedValue() in other places, code instead</technical_language>

Target:
public String getQualifiedName() { return StyleResolver.getQualifiedItemName(getSelectedValue()); }
Source:
<code>private void InitVdsBroker() { log.infoFormat("Initialize vdsBroker ({0},{1})", _vds.getHostName(), _vds.getPort()); int clientTimeOut = Config.<Integer> getValue(ConfigValues.vdsTimeout) * 1000; int connectionTimeOut = Config.<Integer> getValue(ConfigValues.vdsConnectionTimeout) * 1000; int clientRetries = Config.<Integer> getValue(ConfigValues.vdsRetries); <START> if (_vds.getPort() == 4044) { <END> _vdsProxy = new JsonRpcVdsServer(JsonRpcUtils.createClient(_vds.getHostName(), _vds.getPort(), connectionTimeOut, clientTimeOut, clientRetries, Config.<Boolean> getValue(ConfigValues.EncryptHostCommunication))); } else { Pair<VdsServerConnector, HttpClient> returnValue = XmlRpcUtils.getConnection(_vds.getHostName(), _vds.getPort(), clientTimeOut, connectionTimeOut, clientRetries, VdsServerConnector.class, Config.<Boolean> getValue(ConfigValues.EncryptHostCommunication)); _vdsProxy = new VdsServerWrapper(returnValue.getFirst(), returnValue.getSecond()); } }</code><technical_language>Please move port number a constant</technical_language>

Target:
private void InitVdsBroker() { log.infoFormat("Initialize vdsBroker ({0},{1})", _vds.getHostName(), _vds.getPort()); int clientTimeOut = Config.<Integer> getValue(ConfigValues.vdsTimeout) * 1000; int connectionTimeOut = Config.<Integer> getValue(ConfigValues.vdsConnectionTimeout) * 1000; int clientRetries = Config.<Integer> getValue(ConfigValues.vdsRetries); if (_vds.getPort() == JSONRPC_PORT) { _vdsProxy = new JsonRpcVdsServer(JsonRpcUtils.createClient(_vds.getHostName(), _vds.getPort(), connectionTimeOut, clientTimeOut, clientRetries, Config.<Boolean> getValue(ConfigValues.EncryptHostCommunication))); } else { Pair<VdsServerConnector, HttpClient> returnValue = XmlRpcUtils.getConnection(_vds.getHostName(), _vds.getPort(), clientTimeOut, connectionTimeOut, clientRetries, VdsServerConnector.class, Config.<Boolean> getValue(ConfigValues.EncryptHostCommunication)); _vdsProxy = new VdsServerWrapper(returnValue.getFirst(), returnValue.getSecond()); } }
Source:
<code>public void add(SchemaObject obj) { if (SysProperties.CHECK && obj.getSchema() != this) { <START> throw DbException.throwInternalError("wrong schema"); <END> } String name = obj.getName(); Map<String, SchemaObject> map = getMap(obj.getType()); if (SysProperties.CHECK && map.get(name) != null) { throw DbException.throwInternalError("object already exists: " + name); } map.put(name, obj); freeUniqueName(name); }</code><technical_language>unnecesssary change</technical_language>

Target:
public void add(SchemaObject obj) { if (SysProperties.CHECK && obj.getSchema() != this) { DbException.throwInternalError("wrong schema"); } String name = obj.getName(); Map<String, SchemaObject> map = getMap(obj.getType()); if (SysProperties.CHECK && map.get(name) != null) { DbException.throwInternalError("object already exists: " + name); } map.put(name, obj); freeUniqueName(name); }
Source:
<code>public void handleDebugEvents(DebugEvent[] events) { for (DebugEvent event : events) { if (event.getKind() == DebugEvent.TERMINATE) { Object source = event.getSource(); if (source instanceof IProcess) { ILaunch launch = ((IProcess) source).getLaunch(); if (launch != null) { ILaunchConfiguration lc = launch.getLaunchConfiguration(); if (lc != null && lc.equals(nodeDebugLaunch)) { <START> try { <END> SessionStorage.get().remove(server); server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor()); } finally { DebugPlugin.getDefault().removeDebugEventListener(this); } } } } } } }</code><technical_language>extract checks navigations a method #getLaunchConfiguration(DebugEvent event)? This shorten lenghty checks extractions (event -> source -> process -> launch -> launchConfiguration improve readability I believe</technical_language>

Target:
public void handleDebugEvents(DebugEvent[] events) { for (DebugEvent event : events) { if (event.getKind() == DebugEvent.TERMINATE) { ILaunchConfiguration lc = getLaunchConfiguration(event); if (lc != null && lc.equals(nodeDebugLaunch)) { try { SessionStorage.get().remove(server); if (server.getServerState() == IServer.STATE_STARTED) { server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor()); } } finally { DebugPlugin.getDefault().removeDebugEventListener(this); } } } } }
Source:
<code>public static String sanitize(String s) { <START> return s.replaceAll("[^A-Za-z0-9]+", "-"); <END> }</code><technical_language>Java return CharMatcher.inRange('A', 'Z') .or(CharMatcher.inRange('a', 'z')) .or(CharMatcher.inRange('0', '9')) .negate() .trimAndCollapseFrom(s, '-'); This convert .Something.*.Blah_$$$_whatever_ Something-Blah-whatever</technical_language>

Target:
public static String sanitize(String s) { return CharMatcher.inRange('A', 'Z') .or(CharMatcher.inRange('a', 'z')) .or(CharMatcher.inRange('0', '9')) .negate() .trimAndCollapseFrom(s, '-'); }
Source:
<code>private static void playSound(final String filename) { try { Media media = new Media(Audio.class.getResource(filename).toString()); MediaPlayer mp = new MediaPlayer(media); mp.play(); mps.add(mp); } catch (MediaException e) { <START> System.err.println("Could not instantiate Media Player"); <END> } }</code><technical_language>is logger here</technical_language>

Target:
private static void playSound(final String filename) { try { Media media = new Media(Audio.class.getResource(filename).toString()); MediaPlayer mp = new MediaPlayer(media); mp.play(); mps.add(mp); } catch (MediaException e) { Logger.warning("Could not instantiate Media Player"); } }
Source:
<code><START> private static File locateTestsArtifact(String version, File target, boolean enterprise) { <END> File artifact = new File(LOCAL_M2_REPOSITORY_PREFIX + constructPathForTests(version, enterprise)); if (artifact.exists()) { return artifact; } else { return downloadMemberTests(version, target, enterprise); } }</code><technical_language>Minor: locateMemberTests renamed locateTestsArtifact, downloadMemberTests renamed, too</technical_language>

Target:
private static File locateTestsArtifact(String version, File target, boolean enterprise) { File artifact = new File(LOCAL_M2_REPOSITORY_PREFIX + constructPathForTests(version, enterprise)); if (artifact.exists()) { return artifact; } else { return downloadTestsArtifact(version, target, enterprise); } }
Source:
<code>public static synchronized ProfilingLogger getLogger(final ImmutableMap<String, Object> execEnvVars) { if (instance == null) { try { instance = new ProfilingLogger(execEnvVars); } catch (DbException e) { <START> if (LOGGER.isErrorEnabled()) { <END> LOGGER.error("Failed to initialize profiling logger:", e); } } } Preconditions.checkArgument(instance.connectionInfo == (ConnectionInfo) execEnvVars .get(MyriaConstants.EXEC_ENV_VAR_DATABASE_CONN_INFO), "Connection info should not change."); return instance; }</code><technical_language>I get rid of checks save a large amount of work. need check logging is enabled here, work function</technical_language>

Target:
public static synchronized ProfilingLogger getLogger(final ImmutableMap<String, Object> execEnvVars) { if (instance == null) { try { instance = new ProfilingLogger(execEnvVars); } catch (DbException e) { LOGGER.error("Failed to initialize profiling logger:", e); } } Preconditions.checkArgument(instance.connectionInfo == (ConnectionInfo) execEnvVars .get(MyriaConstants.EXEC_ENV_VAR_DATABASE_CONN_INFO), "Connection info should not change."); return instance; }
Source:
<code>protected void logExceptions(final Context context, RetriesExhaustedWithDetailsException exception) { List<Throwable> causes = exception.getCauses(); String failEventId = UUID.randomUUID().toString(); <START> LOG.warn(String.format("%s: %s occured during finishing: %s", context, failEventId, <END> exception.getMessage())); for (Throwable cause : causes) { LOG.warn(failEventId + ": " + context + " see cause: " + cause.getMessage(), cause); } }</code><technical_language>This warning message is clear me. provide a sample</technical_language>

Target:
protected void logExceptions(final Context context, RetriesExhaustedWithDetailsException exception) { List<Throwable> causes = exception.getCauses(); String failEventId = UUID.randomUUID().toString(); String message = String.format("For context %s: eventId: %s occured during bulk writing.", context, failEventId); LOG.warn(message, exception); for (int i = 0; i < causes.size(); i++) { LOG.warn(String.format("context %s: eventId %s excepition %d", context, failEventId, i), causes.get(i)); } }
Source:
<code>public void executeBatch() { if ( threadLocalQueue != null ) { dialect.executeBatch( threadLocalQueue.get() ); <START> threadLocalQueue = null; <END> } }</code><technical_language>I ThreadLocal set null (and I instantiate eagerly in constructor), thread-specific be. a thread a null reference another thread executed a batch</technical_language>

Target:
public void executeBatch() { if ( operationsQueue.get() != null ) { dialect.executeBatch( operationsQueue.get() ); operationsQueue.set( null ); } }
Source:
<code>private void showPostInfo(Post post) { StringBuilder text = new StringBuilder(); for (PostImage image : post.images) { text.append("Filename: ") .append(image.filename).append(".").append(image.extension) .append(" \nDimensions: ") .append(image.imageWidth).append("x").append(image.imageHeight) .append("\nSize: ") .append(AndroidUtils.getReadableFileSize(image.size, false)); if (image.spoiler) { text.append("\nSpoilered"); } text.append("\n"); } text.append("Posted: ").append(PostHelper.getLocalDate(post)); if (!TextUtils.isEmpty(post.id)) { text.append("\nId: ").append(post.id); } if (!TextUtils.isEmpty(post.tripcode)) { text.append("\nTripcode: ").append(post.tripcode); } if (post.httpIcons != null && !post.httpIcons.isEmpty()) { for (PostHttpIcon icon : post.httpIcons) { if (icon.url.toString().contains("troll")) { text.append("\nTroll Country: ").append(icon.name); } else if (icon.url.toString().contains("country")) { text.append("\nCountry: ").append(icon.name); <START> } else { <END> text.append("\n4chan Pass Year: ").append(icon.name); } } } if (!TextUtils.isEmpty(post.capcode)) { text.append("\nCapcode: ").append(post.capcode); } threadPresenterCallback.showPostInfo(text.toString()); }</code><technical_language>good explicitly call out since4pass icon type instead of else. in case add another icon, show since4pass instead</technical_language>

Target:
private void showPostInfo(Post post) { StringBuilder text = new StringBuilder(); for (PostImage image : post.images) { text.append("Filename: ") .append(image.filename).append(".").append(image.extension) .append(" \nDimensions: ") .append(image.imageWidth).append("x").append(image.imageHeight) .append("\nSize: ") .append(AndroidUtils.getReadableFileSize(image.size)); if (image.spoiler) { text.append("\nSpoilered"); } text.append("\n"); } text.append("Posted: ").append(PostHelper.getLocalDate(post)); if (!TextUtils.isEmpty(post.id)) { text.append("\nId: ").append(post.id); } if (!TextUtils.isEmpty(post.tripcode)) { text.append("\nTripcode: ").append(post.tripcode); } if (post.httpIcons != null && !post.httpIcons.isEmpty()) { for (PostHttpIcon icon : post.httpIcons) { if (icon.url.toString().contains("troll")) { text.append("\nTroll Country: ").append(icon.name); } else if (icon.url.toString().contains("country")) { text.append("\nCountry: ").append(icon.name); } else if (icon.url.toString().contains("minileaf")) { text.append("\n4chan Pass Year: ").append(icon.name); } } } if (!TextUtils.isEmpty(post.capcode)) { text.append("\nCapcode: ").append(post.capcode); } threadPresenterCallback.showPostInfo(text.toString()); }
Source:
<code>public void transferCorrupted(TransferEvent event) { <START> logger.error(event.getException().getMessage()); <END> }</code><technical_language>logger.error("some message", event.getException()); instead</technical_language>

Target:
public void transferCorrupted(TransferEvent event) { logger.error("Corrupted transfer", event.getException()); }
Source:
<code>public boolean isMapDatabaseSwitchSupported() { <START> return !getMapGenerator().requiresInternetConnection() <END> && null != Settings.getMapFile(); }</code><technical_language>This read easier others splitting check "guards style": <LINK_0> if (getMapGenerator.requiresInternetConnection()) { return false; } if (Settings.getMapFile() == null) { return false; } return true; if want ask: original code more compact optimized? No, is not. compiler create basically binary code for versions. Besides that, if differences in binary, matter. Code optimized for readability understandability, is severe problem in software development</technical_language>

Target:
public boolean isMapDatabaseSwitchSupported() { if (getMapGenerator().requiresInternetConnection()) { return false; } if (null == Settings.getMapFile()) { return false; } return true; }
Source:
<code>public static int maxProfit(int[] prices) { <START> if(prices == null || prices.length == 0 || prices.length == 1){ <END> return 0; } int max = 0; int minPrice = prices[0]; for(int i = 0; i < prices.length; i++){ minPrice = Math.min(minPrice, prices[i]); max = Math.max(max, prices[i] - minPrice); } return max; }</code><technical_language>prices.length == 0 || prices.length == 1 <==> prices.length < 2</technical_language>

Target:
public static int maxProfit(int[] prices) { if(prices == null || prices.length < 2){ return 0; } int max = 0; int minPrice = prices[0]; for(int i = 1; i < prices.length; i++){ minPrice = Math.min(minPrice, prices[i]); max = Math.max(max, prices[i] - minPrice); } return max; }
Source:
<code>public Comparator getComparator(List<AggregatorFactory> aggregatorSpecs, List<PostAggregator> postAggregatorSpecs) { <START> return ComparatorUtils.NATURAL_COMPARATOR; <END> }</code><technical_language>break Alphanumeric sorting, e.g natural comparator sorts in wrong order "NUM10071", "NUM9999"</technical_language>

Target:
public Comparator getComparator(List<AggregatorFactory> aggregatorSpecs, List<PostAggregator> postAggregatorSpecs) { return comparator; }
Source:
<code>public void remove(final Collection<TopicPartition> revokedChangelogs) { final List<TopicPartition> revokedInitializedChangelogs = new ArrayList<>(); for (final TopicPartition partition : revokedChangelogs) { final ChangelogMetadata changelogMetadata = changelogs.remove(partition); <START> if (changelogMetadata != null) { <END> if (changelogMetadata.state() != ChangelogState.REGISTERED) { revokedInitializedChangelogs.add(partition); } changelogMetadata.clear(); } } removeChangelogsFromRestoreConsumer(revokedInitializedChangelogs); }</code><technical_language>Nice catch, this is possible</technical_language>

Target:
public void remove(final Collection<TopicPartition> revokedChangelogs) { final List<TopicPartition> revokedInitializedChangelogs = new ArrayList<>(); for (final TopicPartition partition : revokedChangelogs) { final ChangelogMetadata changelogMetadata = changelogs.remove(partition); if (changelogMetadata != null) { if (changelogMetadata.state() != ChangelogState.REGISTERED) { revokedInitializedChangelogs.add(partition); } changelogMetadata.clear(); } else { log.debug("Changelog partition could not be found, " + "it could be already cleaned up during the handling" + "of task corruption and never restore again", partition); } } removeChangelogsFromRestoreConsumer(revokedInitializedChangelogs); }
Source:
<code>public void validate(final PreparedUpdate update, final UpdateContext updateContext) { <START> final List<RpslAttribute> mntByAttribute = update.getUpdatedObject().findAttributes(AttributeType.MNT_BY); <END> if (mntByAttribute.size() !=1 || !mntByAttribute.get(0).getCleanValue().equals(POETC_FORM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute.get(0), UpdateMessages.poeticFormRequiresDbmMaintainer()); } }</code><technical_language>update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); is a bit cleaner</technical_language>

Target:
public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final List<RpslAttribute> mntByAttribute = update.getUpdatedObject().findAttributes(AttributeType.MNT_BY); if (mntByAttribute.size() !=1 || !mntByAttribute.get(0).getCleanValue().equals(POETIC_FORM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute.get(0), UpdateMessages.poeticFormRequiresDbmMaintainer()); } }
Source:
<code>public void receivePushHookOnWorkflow() throws Exception { j.jenkins.getInjector().injectMembers(this); WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "Test Workflow"); GitHubPushTrigger trigger = new GitHubPushTrigger(); trigger.start(job, false); job.addTrigger(trigger); job.setDefinition(new CpsFlowDefinition("node {" + "git '<LINK_1>'" + "}")); WorkflowRun lastRun = j.assertBuildStatusSuccess(job.scheduleBuild2(0)); lastRun.getActions(BuildData.class).get(0).buildsByBranchName = new HashMap<String, Build>(); new DefaultPushGHEventSubscriber() .onEvent(GHEvent.PUSH, GitHubWebHookFullTest.classpath("payloads/push-wf.json")); <START> Run build = waitForBuild(2, job); <END> j.assertBuildStatusSuccess(build); }</code><technical_language>JenkinsRule.waitUntilNoActivity easier. is I test triggers. [example](<LINK_0></technical_language>

Target:
public void receivePushHookOnWorkflow() throws Exception { WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "Test Workflow"); GitHubPushTrigger trigger = new GitHubPushTrigger(); trigger.start(job, false); job.addTrigger(trigger); job.setDefinition(new CpsFlowDefinition("node {" + "git '<LINK_1>'" + "}")); WorkflowRun lastRun = j.assertBuildStatusSuccess(job.scheduleBuild2(0)); lastRun.getActions(BuildData.class).get(0).buildsByBranchName = new HashMap<String, Build>(); new DefaultPushGHEventSubscriber() .onEvent(GHEvent.PUSH, GitHubWebHookFullTest.classpath("payloads/push-wf.json")); j.waitUntilNoActivity(); j.assertBuildStatusSuccess(job.getBuildByNumber(2)); }
Source:
<code>protected Collection<? extends IEditCommandRequest> getRequests(List<Object> newValues, Collection<?> removedValues) { LinkedList<IEditCommandRequest> requests = new LinkedList<IEditCommandRequest>(); if(feature instanceof EReference && ((EReference)feature).isContainment() && removedValues != null) { for(Object o : removedValues) { if(o instanceof EObject) { requests.add(new DestroyElementRequest((TransactionalEditingDomain)editingDomain, (EObject)o, false)); } } } <START> List<Object> ownedComments = new LinkedList<Object>(); <END> for(EObject ownedComment : ((ElementImpl)source).getOwnedComments()) { ownedComments.add(ownedComment); if(removedValues != null) { if(removedValues.contains(ownedComment)) { ownedComments.remove(ownedComment); } } } for(Object value : newValues) { if(value instanceof Comment) { if(((Comment)value).eContainer() == null) { ownedComments.add(value); } } } requests.add(new SetRequest((TransactionalEditingDomain)editingDomain, source, feature, ownedComments)); return requests; }</code><technical_language>Nit-pick: ArrayList this list appended (and saves creation of ephemeral list-node objects)</technical_language>

Target:
protected Collection<? extends IEditCommandRequest> getRequests(List<Object> newValues, Collection<?> removedValues) { LinkedList<IEditCommandRequest> requests = new LinkedList<IEditCommandRequest>(); if(feature instanceof EReference && ((EReference)feature).isContainment() && removedValues != null) { for(Object o : removedValues) { if(o instanceof EObject) { requests.add(new DestroyElementRequest((TransactionalEditingDomain)editingDomain, (EObject)o, false)); } } } List<Object> ownedComments = new ArrayList<Object>(); for(EObject ownedComment : ((Element)source).getOwnedComments()) { if(removedValues == null || !removedValues.contains(ownedComment)) { ownedComments.add(ownedComment); } } for(Object value : newValues) { if(value instanceof Comment) { if(((Comment)value).eContainer() == null) { ownedComments.add(value); } } } requests.add(new SetRequest((TransactionalEditingDomain)editingDomain, source, feature, ownedComments)); return requests; }
Source:
<code>public static Expression<Number> mod(Expression<Number> number1, Expression<Number> number2) { <START> return new OperatorExpression<Number>("$divide", number1, number2); <END> }</code><technical_language>@kdkeck a copy/paste error</technical_language>

Target:
public static Expression<Number> mod(Expression<Number> number1, Expression<Number> number2) { return new OperatorExpression<Number>("$mod", number1, number2); }
Source:
<code>private boolean isDraft(final ReceiveCommand cmd) { <START> String refName = cmd.getRefName(); <END> if (refName.startsWith(NEW_DRAFT_CHANGE)) { return true; } return false; }</code><technical_language>making method implementation be: return cmd.getRefName().startsWith(NEW_DRAFT_CHANGE);</technical_language>

Target:
private boolean isDraft(final ReceiveCommand cmd) { return cmd.getRefName().startsWith(NEW_DRAFT_CHANGE); }
Source:
<code>public MimeMessage sendRegistrationInviteToInstructor(String courseId, String instructorEmail) throws EntityDoesNotExistException { CourseAttributes course = coursesLogic.getCourse(courseId); if (course == null) { throw new EntityDoesNotExistException( "Course does not exist [" + courseId + "], " <START> + "trying to send invite email to student [" + instructorEmail + "]"); <END> } InstructorAttributes instructorData = getInstructorForEmail(courseId, instructorEmail); if (instructorData == null) { throw new EntityDoesNotExistException( "Instructor [" + instructorEmail + "] does not exist in course [" + courseId + "]"); } Emails emailMgr = new Emails(); try { MimeMessage email = emailMgr.generateInstructorCourseJoinEmail(course, instructorData); emailMgr.sendEmailWithLogging(email); return email; } catch (Exception e) { throw new RuntimeException("Unexpected error while sending email", e); } }</code><technical_language>student :laughing: open issue change this instructor instead if a need change it</technical_language>

Target:
public MimeMessage sendRegistrationInviteToInstructor(String courseId, String instructorEmail) throws EntityDoesNotExistException { CourseAttributes course = coursesLogic.getCourse(courseId); if (course == null) { throw new EntityDoesNotExistException( "Course does not exist [" + courseId + "], " + "trying to send invite email to instructor [" + instructorEmail + "]"); } InstructorAttributes instructorData = getInstructorForEmail(courseId, instructorEmail); if (instructorData == null) { throw new EntityDoesNotExistException( "Instructor [" + instructorEmail + "] does not exist in course [" + courseId + "]"); } try { MimeMessage email = new EmailGenerator().generateInstructorCourseJoinEmail(course, instructorData); new Emails().sendEmailWithLogging(email); return email; } catch (Exception e) { throw new RuntimeException("Unexpected error while sending email", e); } }
Source:
<code>public MeasureAndDispatchResourceServerTokenServices(final MetricRegistry metricRegistry, final SecuritySettings securitySettings, final RestTemplate restTemplate, final FeatureToggleService featureToggleService) { remoteService = new TokenInfoResourceServerTokenServices( securitySettings.getTokenInfoUrl(), securitySettings.getClientId(), new DefaultAuthenticationExtractor(), new DefaultUserRolesProvider(), restTemplate); localService = new TokenInfoResourceServerTokenServices( <START> securitySettings.getTokenInfoUrl(), <END> securitySettings.getClientId(), new DefaultAuthenticationExtractor(), new DefaultUserRolesProvider(), restTemplate); timer = metricRegistry.timer(MetricUtils.NAKADI_PREFIX + "general.accessTokenValidation"); this.featureToggleService = featureToggleService; }</code><technical_language>@adyach this remote url</technical_language>

Target:
public MeasureAndDispatchResourceServerTokenServices(final MetricRegistry metricRegistry, final SecuritySettings securitySettings, final RestTemplate restTemplate, final FeatureToggleService featureToggleService) { remoteService = new TokenInfoResourceServerTokenServices( securitySettings.getTokenInfoUrl(), securitySettings.getClientId(), new DefaultAuthenticationExtractor(), new DefaultUserRolesProvider(), restTemplate); localService = new TokenInfoResourceServerTokenServices( securitySettings.getLocalTokenInfoUrl(), securitySettings.getClientId(), new DefaultAuthenticationExtractor(), new DefaultUserRolesProvider(), restTemplate); timer = metricRegistry.timer(MetricUtils.NAKADI_PREFIX + "general.accessTokenValidation"); this.featureToggleService = featureToggleService; }
Source:
<code>private void handleException() { <START> Publisher<CoreEvent> pub = checkLogHandler.route(just(mock(CoreEvent.class))); <END> pub.subscribe(new Subscriber<CoreEvent>() { @Override public void onSubscribe(Subscription s) { } @Override public void onNext(CoreEvent event) { } @Override public void onError(Throwable t) { } @Override public void onComplete() { } }); }</code><technical_language>Flux.from abbreviated subscribe</technical_language>

Target:
private void handleException() { Flux.from(checkLogHandler.route(just(mock(CoreEvent.class)))).subscribe(e -> { }, e -> { }); }
Source:
<code>private void recreatePK(StatementExecutor executor, String tableName, PrimaryKey pk) throws OrmException { try { if (pk.oldNameInDb == null) { ui.message("WARN: primary key for table %s didn't <START> exist\n", <END> tableName); } else { if (dialect instanceof DialectPostgreSQL) { executor.execute("ALTER TABLE " + tableName + " DROP CONSTRAINT " + pk.oldNameInDb); } else { executor.execute("ALTER TABLE " + tableName + " DROP PRIMARY KEY"); } } } catch (OrmException ignore) { ui.message("WARN: %s\n", ignore.getMessage()); } executor.execute("ALTER TABLE " + tableName + " ADD PRIMARY KEY(" + Joiner.on(",").join(pk.cols) + ")"); }</code><technical_language>I agree</technical_language>

Target:
private void recreatePK(StatementExecutor executor, String tableName, PrimaryKey pk) throws OrmException { try { if (pk.oldNameInDb == null) { ui.message("WARN: primary key for table %s didn't exist ... ", tableName); } else { if (dialect instanceof DialectPostgreSQL) { executor.execute("ALTER TABLE " + tableName + " DROP CONSTRAINT " + pk.oldNameInDb); } else { executor.execute("ALTER TABLE " + tableName + " DROP PRIMARY KEY"); } } } catch (OrmException ignore) { ui.message("WARN: %s\n", ignore.getMessage()); } executor.execute("ALTER TABLE " + tableName + " ADD PRIMARY KEY(" + Joiner.on(",").join(pk.cols) + ")"); }
Source:
<code>private void doBuild(IProgressMonitor monitor) throws CoreException, OperationCanceledException { SubMonitor subMonitor = SubMonitor.convert(monitor, Policy.opWork + <START> Policy.endOpWork + 1); <END> final ISchedulingRule rule = workspace.getRuleFactory().buildRule(); try { workspace.prepareOperation(rule, subMonitor.split(1)); workspace.beginOperation(true); final int trigger = IncrementalProjectBuilder.AUTO_BUILD; workspace.broadcastBuildEvent(workspace, IResourceChangeEvent.PRE_BUILD, trigger); IStatus result = Status.OK_STATUS; try { if (shouldBuild()) result = workspace.getBuildManager().build(workspace.getBuildOrder(), ICoreConstants.EMPTY_BUILD_CONFIG_ARRAY, trigger, subMonitor.split(Policy.opWork)); } finally { workspace.broadcastBuildEvent(workspace, IResourceChangeEvent.POST_BUILD, trigger); } if (!result.isOK()) { throw new ResourceException(result); } buildNeeded = false; } finally { if (workspace.getElementTree().isImmutable()) { workspace.newWorkingTree(); } workspace.endOperation(rule, false); } }</code><technical_language>Remove Policy.endOpWork constant references it. Change Policy.opWork 99 100</technical_language>

Target:
private void doBuild(IProgressMonitor monitor) throws CoreException, OperationCanceledException { SubMonitor subMonitor = SubMonitor.convert(monitor, Policy.opWork + 1); final ISchedulingRule rule = workspace.getRuleFactory().buildRule(); try { workspace.prepareOperation(rule, subMonitor.split(1)); workspace.beginOperation(true); final int trigger = IncrementalProjectBuilder.AUTO_BUILD; workspace.broadcastBuildEvent(workspace, IResourceChangeEvent.PRE_BUILD, trigger); IStatus result = Status.OK_STATUS; try { if (shouldBuild()) result = workspace.getBuildManager().build(workspace.getBuildOrder(), ICoreConstants.EMPTY_BUILD_CONFIG_ARRAY, trigger, subMonitor.split(Policy.opWork)); } finally { workspace.broadcastBuildEvent(workspace, IResourceChangeEvent.POST_BUILD, trigger); } if (!result.isOK()) { throw new ResourceException(result); } buildNeeded = false; } finally { if (workspace.getElementTree().isImmutable()) { workspace.newWorkingTree(); } workspace.endOperation(rule, false); } }
Source:
<code>public String getServerSpecificRoot(String hostId) { if (!m_hostRoots.containsKey(hostId)) { <START> throw new RuntimeException("getServerSpecificRoot possibly called before cluster has started."); <END> } return m_hostRoots.get(hostId) + "/voltdbroot"; }</code><technical_language>IllegalArgumentException</technical_language>

Target:
public String getServerSpecificRoot(String hostId) { if (!m_hostRoots.containsKey(hostId)) { throw new IllegalArgumentException("getServerSpecificRoot possibly called before cluster has started."); } return m_hostRoots.get(hostId) + "/voltdbroot"; }
Source:
<code>public PaginatedArrayList<Map<String, Object>> getItems(final User user, final int limit, final int offset, final Map<String, Object> params) throws PaginationException { try { final PaginatedArrayList<Map<String, Object>> result = new PaginatedArrayList(); final List<Relationship> relationships = relationshipAPI .getOneSidedRelationships((ContentType) params.get(CONTENT_TYPE_PARAM), limit, offset); result.add(relationships.stream() .collect(Collectors.toMap(Relationship::getInode, r -> r))); return result; } catch (DotDataException e) { <START> throw new DotRuntimeException(e); <END> } }</code><technical_language>please log error returning Exception</technical_language>

Target:
public PaginatedArrayList<Map<String, Object>> getItems(final User user, final int limit, final int offset, final Map<String, Object> params) throws PaginationException { try { final PaginatedArrayList<Map<String, Object>> result = new PaginatedArrayList(); final List<Relationship> relationships = relationshipAPI .getOneSidedRelationships((ContentType) params.get(CONTENT_TYPE_PARAM), limit, offset); result.add(relationships.stream() .collect(Collectors.toMap(Relationship::getInode, r -> r))); return result; } catch (DotDataException e) { Logger.error(this, "Error getting relationships", e); throw new DotRuntimeException(e); } }
Source:
<code>public void delete(MailboxSession session, Mailbox mailbox, List<MessageUid> expungedUids) throws MailboxException { try { indexer.deleteMessages(expungedUids.stream() .map(uid -> indexIdFor(mailbox, uid)) .collect(Collectors.toList())); } catch (Exception e) { <START> if (LOGGER.isErrorEnabled()) { <END> LOGGER.error("Error when deleting messages in mailbox from index", mailbox.getMailboxId().serialize(), ImmutableList.copyOf(expungedUids), e); } } }</code><technical_language>remove this "isErrorEnabled"</technical_language>

Target:
public void delete(MailboxSession session, Mailbox mailbox, List<MessageUid> expungedUids) throws MailboxException { try { indexer.deleteMessages(expungedUids.stream() .map(uid -> indexIdFor(mailbox, uid)) .collect(Collectors.toList())); } catch (Exception e) { if (LOGGER.isErrorEnabled()) { LOGGER.error("Error when deleting messages in mailbox from index", mailbox.getMailboxId().serialize(), expungedUids.toArray(), e); } } }
Source:
<code>public ResourceHolder<T> get() { CountingHolder obj; if(size.getAndIncrement() > maxCapacity) { size.decrementAndGet(); <START> do { obj = objects.remove(); } while(obj == null); <END> obj.count.incrementAndGet(); objects.offer(obj); return obj; } else { obj = new CountingHolder(generator.get()); obj.count.incrementAndGet(); objects.offer(obj); return obj; } }</code><technical_language>I objects.remove() is throw exceptions return null pool is empty</technical_language>

Target:
public ResourceHolder<T> get() { final CountingHolder holder; try { holder = queue.take(); } catch(InterruptedException e) { Thread.currentThread().interrupt(); throw Throwables.propagate(e); } synchronized (holder) { holder.count.incrementAndGet(); queue.offer(holder); } return holder; }
Source:
<code>public PayloadValidatingInterceptor payloadValidatingInterceptor() { final PayloadValidatingInterceptor payloadValidatingInterceptor = new PayloadValidatingInterceptor(); <START> final Resource[] resources = new Resource[] { new ClassPathResource("schemas/common.xsd"), <END> new ClassPathResource("schemas/ts-adhocmanagement.xsd"), new ClassPathResource("schemas/ts-schedulemanagement.xsd") }; payloadValidatingInterceptor.setSchemas(resources); return payloadValidatingInterceptor; }</code><technical_language>constants for string values occuring more once</technical_language>

Target:
public PayloadValidatingInterceptor payloadValidatingInterceptor() { final PayloadValidatingInterceptor payloadValidatingInterceptor = new PayloadValidatingInterceptor(); final Resource[] resources = new Resource[] { new ClassPathResource(COMMON_XSD_PATH), new ClassPathResource(TS_ADHOCMANAGEMENT_XSD_PATH), new ClassPathResource(TS_SCHEDULE_MANAGEMENT_XSD_PATH) }; payloadValidatingInterceptor.setSchemas(resources); return payloadValidatingInterceptor; }
Source:
<code>public FEELFnResult<Boolean> invoke(@ParameterName( "list" ) List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "cannot be null")); } if (!TypeUtil.isCollectionTypeHomogenous(list, Boolean.class)) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "an element in the list is not a Boolean")); } for ( final Object element : list ) { <START> if (element == null || element == Boolean.FALSE) { <END> return FEELFnResult.ofResult( false ); } } return FEELFnResult.ofResult( true ); }</code><technical_language>a bit lost this change.. is this iterating twice? check iteration good</technical_language>

Target:
public FEELFnResult<Boolean> invoke(@ParameterName( "list" ) List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "cannot be null")); } boolean result = true; boolean containsNull = false; for ( final Object element : list ) { if (element != null && !(element instanceof Boolean)) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "an element in the list is not a Boolean")); } else { if (element != null) { result &= (Boolean) element; } else if (!containsNull) { containsNull = true; } } } if (containsNull && result) { return FEELFnResult.ofResult( null ); } else { return FEELFnResult.ofResult( result ); } }
Source:
<code>public void updateDiseaseOccurrenceIsValidatedValues(int diseaseGroupId, DateTime modelRunPrepDate) { int numRemovedFromValidator = 0; List<DiseaseOccurrence> occurrences = diseaseService.getDiseaseOccurrencesInValidation(diseaseGroupId); Set<DiseaseOccurrence> reviewedOccurrences = getAllReviewedOccurrences(diseaseGroupId); Boolean isValidated; for (DiseaseOccurrence occurrence : occurrences) { isValidated = false; if (duringDiseaseSetUp(occurrence.getDiseaseGroup())) { isValidated = true; <START> } else { <END> if (occurrenceHasBeenInReviewForMoreThanAWeek(occurrence, modelRunPrepDate)) { isValidated = reviewedOccurrences.contains(occurrence) ? true : null; } } if (isValidated == null || isValidated) { occurrence.setValidated(isValidated); diseaseService.saveDiseaseOccurrence(occurrence); numRemovedFromValidator++; } } logResults(occurrences.size(), numRemovedFromValidator); }</code><technical_language>More usual "} else if (...) {"</technical_language>

Target:
public void updateDiseaseOccurrenceIsValidatedValues(int diseaseGroupId, DateTime modelRunPrepDate) { int numRemovedFromValidator = 0; List<DiseaseOccurrence> occurrences = diseaseService.getDiseaseOccurrencesInValidation(diseaseGroupId); Set<DiseaseOccurrence> reviewedOccurrences = getAllReviewedOccurrences(diseaseGroupId); Boolean isValidated; for (DiseaseOccurrence occurrence : occurrences) { isValidated = false; if (duringDiseaseSetUp(occurrence.getDiseaseGroup())) { isValidated = true; } else if (occurrenceHasBeenInReviewForMoreThanAWeek(occurrence, modelRunPrepDate)) { isValidated = reviewedOccurrences.contains(occurrence) ? true : null; } if (isValidated == null || isValidated) { occurrence.setValidated(isValidated); diseaseService.saveDiseaseOccurrence(occurrence); numRemovedFromValidator++; } } logResults(occurrences.size(), numRemovedFromValidator); }
Source:
<code>protected void executeVmCommand() { Set<Guid> mImagesToBeRemoved = new HashSet<Guid>(); List<DiskImage> images = getParameters().Images; if (images == null) { images = ImagesHandler.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm(getVmId()), true, false); } for (DiskImage image : images) { if (Boolean.TRUE.equals(image.getActive())) { mImagesToBeRemoved.add(image.getImageId()); } } <START> Collection<DiskImage> failedToBeRemoved = new LinkedList<>(); <END> for (final DiskImage image : images) { if (mImagesToBeRemoved.contains(image.getImageId())) { VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction(VdcActionType.RemoveImage, buildRemoveImageParameters(image), ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalTaskIdList().addAll(vdcReturnValue.getInternalTaskIdList()); } else { failedToBeRemoved.add(image); log.errorFormat("Can't remove image id: {0} for VM id: {1} due to: {2}. Image will be set at illegal state with no snapshot id.", image.getImageId(), getParameters().getVmId(), vdcReturnValue.getFault().getMessage()); TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Object>() { @Override public Object runInTransaction() { updateDiskImagesToIllegal(image); return true; } }); } } } setActionReturnValue(failedToBeRemoved); setSucceeded(true); }</code><technical_language>s/failedToBeRemoved/failedRemoving/</technical_language>

Target:
protected void executeVmCommand() { Set<Guid> mImagesToBeRemoved = new HashSet<Guid>(); List<DiskImage> images = getParameters().Images; if (images == null) { images = ImagesHandler.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm(getVmId()), true, false); } for (DiskImage image : images) { if (Boolean.TRUE.equals(image.getActive())) { mImagesToBeRemoved.add(image.getImageId()); } } Collection<DiskImage> failedRemoving = new LinkedList<>(); for (final DiskImage image : images) { if (mImagesToBeRemoved.contains(image.getImageId())) { VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction(VdcActionType.RemoveImage, buildRemoveImageParameters(image), ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalTaskIdList().addAll(vdcReturnValue.getInternalTaskIdList()); } else { failedRemoving.add(image); log.errorFormat("Can't remove image id: {0} for VM id: {1} due to: {2}. Image will be set at illegal state with no snapshot id.", image.getImageId(), getParameters().getVmId(), vdcReturnValue.getFault().getMessage()); TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Object>() { @Override public Object runInTransaction() { updateDiskImagesToIllegal(image); return true; } }); } } } setActionReturnValue(failedRemoving); setSucceeded(true); }
Source:
<code>public OseeGroup(IArtifactToken token) { this.token = token; this.groupArtifact = null; <START> this.groupArtifact = null; <END> }</code><technical_language>is groupArtifact set twice</technical_language>

Target:
public OseeGroup(IArtifactToken token) { this.token = token; this.groupArtifact = null; }
Source:
<code>private static int setDiskBootOrder(List<VmDevice> devices, int bootOrder) { <START> VM vm = DbFacade.getInstance().getVmDAO().get(vmBaseInstance.getId()); <END> boolean isOldCluster = VmDeviceCommonUtils.isOldClusterVersion(vm.getvds_group_compatibility_version()); for (VmDevice device : devices) { if (device.getType() .equals(VmDeviceType.getName(VmDeviceType.DISK)) && device.getDevice().equals( VmDeviceType.getName(VmDeviceType.DISK))) { Guid id = device.getDeviceId(); Disk disk = DbFacade.getInstance().getDiskDao().get(id); if (id != null && !id.equals(Guid.Empty)) { if (isOldCluster) { if (disk != null && disk.getDiskType().equals(DiskType.System)) { device.setBootOrder(bootOrder++); break; } } else { device.setBootOrder(bootOrder++); } } } } return bootOrder; }</code><technical_language>this means push of patchset once, else break build. do so, move this line proper commit</technical_language>

Target:
private static int setDiskBootOrder(List<VmDevice> devices, int bootOrder) { VM vm = DbFacade.getInstance().getVmDAO().get(vmBaseInstance.getId()); boolean isOldCluster = VmDeviceCommonUtils.isOldClusterVersion(vm.getvds_group_compatibility_version()); for (VmDevice device : devices) { if (device.getType() .equals(VmDeviceType.DISK.getName()) && device.getDevice().equals( VmDeviceType.DISK.getName())) { Guid id = device.getDeviceId(); Disk disk = DbFacade.getInstance().getDiskDao().get(id); if (id != null && !id.equals(Guid.Empty)) { if (isOldCluster) { if (disk != null && disk.getDiskType().equals(DiskType.System)) { device.setBootOrder(bootOrder++); break; } } else { device.setBootOrder(bootOrder++); } } } } return bootOrder; }
Source:
<code>public boolean canCustomize(String text) { <START> return (COMPILATION_MESSAGE.exec(text) != null || <END> LINKER_MESSAGE.exec(text) != null); }</code><technical_language>replaced more simple one: return COMPILATION_MESSAGE.test(text) || LINKER_MESSAGE.test(text)</technical_language>

Target:
public boolean canCustomize(String text) { return (COMPILATION_MESSAGE.test(text) || LINKER_MESSAGE.test(text)); }
Source:
<code>public List<OrganizationDto> getAllRoot() throws Exception { List<OrganizationDto> organizations = requestFactory.fromUrl(getApiUrl()).request().asList(OrganizationDto.class); <START> organizations.removeIf((o -> nonNull(o.getParent()))); <END> return organizations; }</code><technical_language>odd parentheses in command: organizations.removeIf((o -> nonNull(o.getParent()))); \> organizations.removeIf(o -> nonNull(o.getParent()));</technical_language>

Target:
public List<OrganizationDto> getAllRoot() throws Exception { List<OrganizationDto> organizations = requestFactory.fromUrl(getApiUrl()).request().asList(OrganizationDto.class); organizations.removeIf(o -> o.getParent() != null); return organizations; }
Source:
<code>private static boolean restore(PageStore pageStore, PageStoreOptions options, MetaStore metaStore, CacheEvictor evictor) { <START> Path rootDir = Paths.get(options.getRootDir()); <END> if (!Files.exists(rootDir)) { LOG.error("Failed to restore PageStore: Directory does not exist", rootDir); return false; } try (Stream<PageInfo> stream = pageStore.getPages()) { Iterator<PageInfo> iterator = stream.iterator(); while (iterator.hasNext()) { PageInfo pageInfo = iterator.next(); if (pageInfo == null) { LOG.error("Invalid page info"); return false; } metaStore.addPage(pageInfo.getPageId(), pageInfo); evictor.updateOnPut(pageInfo.getPageId()); if (metaStore.bytes() > pageStore.getCacheSize()) { LOG.error("Loaded pages exceed cache capacity ({} bytes)", pageStore.getCacheSize()); return false; } } } catch (Exception e) { LOG.error("Failed to restore PageStore", e); return false; } LOG.info("Restored PageStore with existing pages and bytes", metaStore.pages(), metaStore.bytes()); return true; }</code><technical_language>Is this line noisy? I helpful</technical_language>

Target:
private static boolean restore(PageStore pageStore, PageStoreOptions options, MetaStore metaStore, CacheEvictor evictor) { LOG.info("Attempt to restore PageStore with {}", options); Path rootDir = Paths.get(options.getRootDir()); if (!Files.exists(rootDir)) { LOG.error("Failed to restore PageStore: Directory does not exist", rootDir); return false; } try (Stream<PageInfo> stream = pageStore.getPages()) { Iterator<PageInfo> iterator = stream.iterator(); while (iterator.hasNext()) { PageInfo pageInfo = iterator.next(); if (pageInfo == null) { LOG.error("Invalid page info"); return false; } metaStore.addPage(pageInfo.getPageId(), pageInfo); evictor.updateOnPut(pageInfo.getPageId()); if (metaStore.bytes() > pageStore.getCacheSize()) { LOG.error("Loaded pages exceed cache capacity ({} bytes)", pageStore.getCacheSize()); return false; } } } catch (Exception e) { LOG.error("Failed to restore PageStore", e); return false; } LOG.info("Restored PageStore with existing pages and bytes", metaStore.pages(), metaStore.bytes()); return true; }