auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void invariant() { super.invariant(); <START> Assert.assertTrue(currentPathStartsWith("/courses/ti1705/TI1705/groups/")); <END> }</code><technical_language>if tests specific, a currentPathContains('assignment')</technical_language>

Target:
public void invariant() { super.invariant(); Assert.assertTrue(currentPathContains("deliveries")); }
Source:
<code>public void initialize(ConfigurableApplicationContext applicationContext) { applicationContext.getBeanFactory().addBeanPostProcessor(new BeanPostProcessor() { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return bean; } @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { <START> if (beanName.equals("secretManager")) { <END> MutablePropertySources src = applicationContext.getEnvironment().getPropertySources(); List<EnumerablePropertySource> sources = new ArrayList<>(); for (Iterator<PropertySource<?>> it = src.iterator(); it.hasNext(); ) { PropertySource ps = it.next(); if (ps instanceof EnumerablePropertySource) { sources.add((EnumerablePropertySource) ps); } } for (EnumerablePropertySource s : sources) { src.replace(s.getName(), new SecretAwarePropertySource(s, (SecretManager) bean)); } } return bean; } }); }</code><technical_language>Prefer "secretManager".equals(beanName). I doubt beanName is null, I tend err side of absolute caution in this case</technical_language>

Target:
public void initialize(ConfigurableApplicationContext applicationContext) { applicationContext.getBeanFactory().addBeanPostProcessor(new SecretBeanPostProcessor(applicationContext)); }
Source:
<code><START> public Command getNewRepoCommand() { <END> return newRepoCommand; }</code><technical_language>this public? (package-protected fine.. a detail)</technical_language>

Target:
Command getNewRepoCommand() { return newRepoCommand; }
Source:
<code>private void fetchNestedTemplate(PresenterOptions presenterOptions) throws Exception { NestedPresenterOptions nestedPresenterOptions = new NestedPresenterOptions(); nestedPresenterOptions.setPlace(presenterConfigModel.isUsePlace()); nestedPresenterOptions.setNameToken(presenterConfigModel.getNameToken()); nestedPresenterOptions.setCrawlable(presenterConfigModel.isUseCrawlable()); nestedPresenterOptions.setCodeSplit(presenterConfigModel.isUseCodesplit()); nestedPresenterOptions.setNameToken(presenterConfigModel.getNameTokenWithClass()); nestedPresenterOptions.setNameTokenImport(presenterConfigModel.getNameTokenUnitImport()); nestedPresenterOptions.setContentSlotImport(presenterConfigModel.getContentSlotImport()); if (presenterConfigModel.getRevealInRoot()) { nestedPresenterOptions.setRevealType("Root"); } else if (presenterConfigModel.getRevealInRootLayout()) { nestedPresenterOptions.setRevealType("RootLayout"); } else if (presenterConfigModel.getPopupPresenter()) { nestedPresenterOptions.setRevealType("RootPopup"); } else if (presenterConfigModel.getRevealInSlot()) { nestedPresenterOptions.setRevealType(presenterConfigModel.getContentSlot()); } try { createdNestedPresenterTemplates = CreateNestedPresenter.run(presenterOptions, nestedPresenterOptions, true); } catch (Exception e) { <START> throw e; <END> } }</code><technical_language>catch</technical_language>

Target:
private void fetchNestedTemplate(PresenterOptions presenterOptions) throws Exception { NestedPresenterOptions nestedPresenterOptions = new NestedPresenterOptions(); nestedPresenterOptions.setPlace(presenterConfigModel.isUsePlace()); nestedPresenterOptions.setNameToken(presenterConfigModel.getNameToken()); nestedPresenterOptions.setCrawlable(presenterConfigModel.isUseCrawlable()); nestedPresenterOptions.setCodeSplit(presenterConfigModel.isUseCodesplit()); nestedPresenterOptions.setNameToken(presenterConfigModel.getNameTokenWithClass()); nestedPresenterOptions.setNameTokenImport(presenterConfigModel.getNameTokenUnitImport()); nestedPresenterOptions.setContentSlotImport(presenterConfigModel.getContentSlotImport()); if (presenterConfigModel.getRevealInRoot()) { nestedPresenterOptions.setRevealType("Root"); } else if (presenterConfigModel.getRevealInRootLayout()) { nestedPresenterOptions.setRevealType("RootLayout"); } else if (presenterConfigModel.getPopupPresenter()) { nestedPresenterOptions.setRevealType("RootPopup"); } else if (presenterConfigModel.getRevealInSlot()) { nestedPresenterOptions.setRevealType(presenterConfigModel.getContentSlot()); } createdNestedPresenterTemplates = CreateNestedPresenter.run(presenterOptions, nestedPresenterOptions, true); }
Source:
<code>private void markCommon(final RevObject obj, final AckNackResult anr) throws IOException { if (statelessRPC && anr == AckNackResult.ACK_COMMON && !obj.has(COMMON)) <START> pckState.writeString("have " + obj.name() + "\n"); <END> obj.add(COMMON); if (obj instanceof RevCommit) ((RevCommit) obj).carry(COMMON); }</code><technical_language>Worth putting a //$NON-NLS-1$ non-translatable strings? I Eclipse a quick-fix. need two, for NL for have</technical_language>

Target:
private void markCommon(final RevObject obj, final AckNackResult anr) throws IOException { if (statelessRPC && anr == AckNackResult.ACK_COMMON && !obj.has(COMMON)) { StringBuilder s; s = new StringBuilder(6 + Constants.OBJECT_ID_STRING_LENGTH); s.append("have "); s.append(obj.name()); s.append('\n'); pckState.writeString(s.toString()); } obj.add(COMMON); if (obj instanceof RevCommit) ((RevCommit) obj).carry(COMMON); }
Source:
<code>private void initialiseAsync() { runAsync.accept(() -> { while (uninitialised()) { try { initialise(); <START> } catch (Throwable th) { <END> log.warn("Async initialisation failed, retrying in 30 seconds.", th); Uninterruptibles.sleepUninterruptibly(30, TimeUnit.SECONDS); } } }); }</code><technical_language>exceptions want catch here, is permanently broken (e.g. IllegalArgumentException constructing some service). another big is interrupted exception, this is running a daemon thread safe prevent service stopping</technical_language>

Target:
private void initialiseAsync() { runAsync.accept(() -> { while (!isInitialized()) { try { initialise(); } catch (IllegalArgumentException ex) { log.info("Async initialisation failed, the service is in a state which will require " + "manual intervention to start.", ex); break; } catch (Throwable th) { log.info("Async initialisation failed, retrying in seconds.", RETRY_AFTER_SECONDS, th); Uninterruptibles.sleepUninterruptibly(RETRY_AFTER_SECONDS, TimeUnit.SECONDS); } } }); }
Source:
<code>public static ConcurrentHistogram createHdrHistogram( long highestTrackableValue ) { <START> return new ConcurrentHistogram( highestTrackableValue, 3 ); <END> }</code><technical_language>nice a constant for 3</technical_language>

Target:
public static ConcurrentHistogram createHdrHistogram( long highestTrackableValue ) { return new ConcurrentHistogram( highestTrackableValue, DEFAULT_NUMBER_OF_SIGNIFICANT_VALUE_DIGITS ); }
Source:
<code>public int getConnectionId() { <START> return this.channel != null ? this.channel.hashCode() : 0; <END> }</code><technical_language>replaced Objects.hashCode(channel) (since java 1.7)</technical_language>

Target:
public int getConnectionId() { return Objects.hashCode(this.channel); }
Source:
<code><START> public long getScheduledTime() { <END> Date date = instance.getScheduledDate(); if (date != null) { return date.getTime(); } return -1; }</code><technical_language>package local</technical_language>

Target:
private long getScheduledTime() { Date date = instance.getScheduledDate(); if (date != null) { return date.getTime(); } return -1; }
Source:
<code>public void insertPastState(long stateStartTime, long stateEndTime, int quark, ITmfStateValue value) throws TimeRangeException { @SuppressWarnings("restriction") <START> final int nbAttributes = fPartialSS.getNbAttributes(); <END> if (!fInitialized) { fCheckpointQuark = fPartialSS.getQuarkAbsoluteAndAdd(CHECKPOINT_NAME); fQuarksAdded.clear(); rebuildQuarks(nbAttributes, Boolean.TRUE); fCheckpoints.add(fPartialInput.getStartTime()); fInitialized = true; } if (quark == fCheckpointQuark) { fQuarksAdded.clear(); rebuildQuarks(nbAttributes, Boolean.TRUE); fCheckpoints.add(stateEndTime); return; } if (stateEndTime > fLatestTime) { fLatestTime = stateEndTime; } boolean insert = false; if (quark >= fQuarksAdded.size()) { rebuildQuarks(nbAttributes, Boolean.FALSE); insert = true; } if (fQuarksAdded.get(quark)) { fQuarksAdded.set(quark, Boolean.FALSE); insert = true; } if (insert) { fInnerHistory.insertPastState(stateStartTime, stateEndTime, quark, value); } }</code><technical_language>This method is in ITmfStateSystem, cast fPartialSS that. pretty though..</technical_language>

Target:
public void insertPastState(long stateStartTime, long stateEndTime, int quark, ITmfStateValue value) throws TimeRangeException { final int nbAttributes = ((ITmfStateSystem) fPartialSS).getNbAttributes(); if (!fInitialized) { fCheckpointQuark = fPartialSS.getQuarkAbsoluteAndAdd(CHECKPOINT_NAME); fQuarksAdded.clear(); rebuildQuarks(nbAttributes, Boolean.TRUE); fCheckpoints.add(fPartialInput.getStartTime()); fInitialized = true; } if (quark == fCheckpointQuark) { fQuarksAdded.clear(); rebuildQuarks(nbAttributes, Boolean.TRUE); fCheckpoints.add(stateEndTime); return; } if (stateEndTime > fLatestTime) { fLatestTime = stateEndTime; } boolean insert = false; if (quark >= fQuarksAdded.size()) { rebuildQuarks(nbAttributes, Boolean.FALSE); insert = true; } if (fQuarksAdded.get(quark)) { fQuarksAdded.set(quark, Boolean.FALSE); insert = true; } if (insert) { fInnerHistory.insertPastState(stateStartTime, stateEndTime, quark, value); } }
Source:
<code>public ElasticsearchTableDescription( @JsonProperty("tableName") String tableName, @JsonProperty("schemaName") String schemaName, @JsonProperty("host") String host, @JsonProperty("port") int port, @JsonProperty("clusterName") String clusterName, @JsonProperty("index") String index, @JsonProperty("indexExactMatch") boolean indexExactMatch, @JsonProperty("type") String type, @JsonProperty("columns") Optional<List<ElasticsearchColumn>> columns) { <START> checkArgument(!isNullOrEmpty(tableName), "tableName is null or empty"); <END> checkArgument(!isNullOrEmpty(host), "host is null or empty"); checkArgument(!isNullOrEmpty(clusterName), "clusterName is null or empty"); checkArgument(!isNullOrEmpty(index), "index is null or empty"); checkArgument(!isNullOrEmpty(type), "type is null or empty"); requireNonNull(columns, "columns is null"); this.tableName = tableName; this.schemaName = schemaName; this.host = host; this.port = port; this.clusterName = clusterName; this.index = index; this.indexExactMatch = indexExactMatch; this.type = type; this.columns = columns; }</code><technical_language>check schemaName here</technical_language>

Target:
public ElasticsearchTableDescription( @JsonProperty("tableName") String tableName, @JsonProperty("schemaName") String schemaName, @JsonProperty("host") String host, @JsonProperty("port") int port, @JsonProperty("clusterName") String clusterName, @JsonProperty("index") String index, @JsonProperty("indexExactMatch") boolean indexExactMatch, @JsonProperty("type") String type, @JsonProperty("columns") Optional<List<ElasticsearchColumn>> columns) { checkArgument(!isNullOrEmpty(tableName), "tableName is null or empty"); checkArgument(!isNullOrEmpty(schemaName), "schemaName is null or empty"); checkArgument(!isNullOrEmpty(host), "host is null or empty"); checkArgument(!isNullOrEmpty(clusterName), "clusterName is null or empty"); checkArgument(!isNullOrEmpty(index), "index is null or empty"); checkArgument(!isNullOrEmpty(type), "type is null or empty"); requireNonNull(columns, "columns is null"); this.tableName = tableName; this.schemaName = schemaName; this.host = host; this.port = port; this.clusterName = clusterName; this.index = index; this.indexExactMatch = indexExactMatch; this.type = type; this.columns = columns; }
Source:
<code>protected boolean validate() { <START> List<Pair<VM, VmDevice>> vmsForDisk = vmDao.getVmsWithPlugInfo(getDiskImage().getId()); <END> DiskValidator diskValidator = new DiskValidator(getDiskImage()); if (!validate(diskValidator.isDiskPluggedToVmsThatAreNotDown(false, vmsForDisk))) { StorageDomainStatic destDomain = storageDomainStaticDao.get(getParameters().getStorageDomainId()); if (destDomain.isBackup == true) { return false; } } return true; }</code><technical_language>add: import org.ovirt.engine.core.common.utils.Pair;</technical_language>

Target:
protected boolean validate() { List<Pair<VM, VmDevice>> vmsForDisk = vmDao.getVmsWithPlugInfo(getDiskImage().getId()); DiskValidator diskValidator = new DiskValidator(getDiskImage()); if (!validate(diskValidator.isDiskPluggedToVmsThatAreNotDown(false, vmsForDisk))) { StorageDomainStatic destDomain = storageDomainStaticDao.get(getParameters().getStorageDomainId()); if (destDomain.isBackup() == true) { return false; } } return true; }
Source:
<code>protected void notifyChanged(final BufferChangedEvent event) { ListenerList<IBufferChangedListener> listeners; <START> synchronized(this) { listeners = this.changeListeners; } <END> if (listeners != null) { Iterator<IBufferChangedListener> iterator = listeners.iterator(); while (iterator.hasNext()) { final IBufferChangedListener listener = iterator.next(); SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { Util.log(exception, "Exception occurred in listener of buffer change notification"); } public void run() throws Exception { listener.bufferChanged(event); } }); } } }</code><technical_language>risk preventing this "synchronized"? I recall synchronized guarding a single assignment. if assignment while another thread is in middle of addBufferChangedListener, I harm caused</technical_language>

Target:
protected void notifyChanged(final BufferChangedEvent event) { ListenerList<IBufferChangedListener> listeners = this.changeListeners; if (listeners != null) { Iterator<IBufferChangedListener> iterator = listeners.iterator(); while (iterator.hasNext()) { final IBufferChangedListener listener = iterator.next(); SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { Util.log(exception, "Exception occurred in listener of buffer change notification"); } public void run() throws Exception { listener.bufferChanged(event); } }); } } }
Source:
<code>public StudentAttributes makeStudent(String enrollLine, String courseId) throws EnrollException { if (enrollLine.isEmpty()) { throw new EnrollException(ERROR_ENROLL_LINE_EMPTY); } String[] columns = splitLineIntoColumns(enrollLine); boolean hasMissingFields = columns.length <= teamColumnIndex || columns.length <= nameColumnIndex <START> || columns.length <= emailColumnIndex; <END> if (hasMissingFields) { throw new EnrollException(ERROR_ENROLL_LINE_TOOFEWPARTS); } String paramTeam = columns[teamColumnIndex].trim(); String paramName = columns[nameColumnIndex].trim(); String paramEmail = columns[emailColumnIndex].trim(); String paramComment = ""; if (hasComment && columns.length > commentColumnIndex) { paramComment = columns[commentColumnIndex].trim(); } String paramSection = Const.DEFAULT_SECTION; if (hasSection && columns.length > sectionColumnIndex) { paramSection = columns[sectionColumnIndex].trim(); } return new StudentAttributes(paramSection, paramTeam, paramName, paramEmail, paramComment, courseId); }</code><technical_language>In original code, conditions aligned other easier read</technical_language>

Target:
public StudentAttributes makeStudent(String enrollLine, String courseId) throws EnrollException { if (enrollLine.isEmpty()) { throw new EnrollException(ERROR_ENROLL_LINE_EMPTY); } String[] columns = splitLineIntoColumns(enrollLine); boolean hasMissingFields = columns.length <= teamColumnIndex || columns.length <= nameColumnIndex || columns.length <= emailColumnIndex; if (hasMissingFields) { throw new EnrollException(ERROR_ENROLL_LINE_TOOFEWPARTS); } String paramTeam = columns[teamColumnIndex].trim(); String paramName = columns[nameColumnIndex].trim(); String paramEmail = columns[emailColumnIndex].trim(); String paramComment = ""; if (hasComment && columns.length > commentColumnIndex) { paramComment = columns[commentColumnIndex].trim(); } String paramSection; if (hasSection && columns.length > sectionColumnIndex) { paramSection = columns[sectionColumnIndex].trim(); } else { paramSection = Const.DEFAULT_SECTION; } return new StudentAttributes(paramSection, paramTeam, paramName, paramEmail, paramComment, courseId); }
Source:
<code>private void load(String filename) throws IOException{ <START> InputStream conceptStream = Database.class.getResourceAsStream(filename); <END> try { for (CSVRecord conceptRow : CSVFormat.RFC4180.withHeader().parse(new InputStreamReader(conceptStream))) { String tableName = conceptRow.get("omop_cdm_table"); String fieldName = conceptRow.get("omop_cdm_field"); Concept concept = new Concept(); concept.setConceptId(conceptRow.get("concept_id")); concept.setConceptName(conceptRow.get("concept_name")); concept.setStandardConcept(conceptRow.get("standard_concept")); this.put(tableName, fieldName, concept); } } catch (IOException e) { throw new IOException("Could not load concept_id hints: " + e.getMessage()); } }</code><technical_language>a try-with-resources block ensure stream is closed again. add multiple statements block, e.g. try (InputStream a = ...; InputStreamReader r= new InputStreamReader(a)) {</technical_language>

Target:
private void load(String filename) throws IOException{ try (InputStream conceptStream = Database.class.getResourceAsStream(filename)) { for (CSVRecord conceptRow : CSVFormat.RFC4180.withHeader().parse(new InputStreamReader(conceptStream))) { String tableName = conceptRow.get("omop_cdm_table"); String fieldName = conceptRow.get("omop_cdm_field"); Concept concept = new Concept(); concept.setConceptId(conceptRow.get("concept_id")); concept.setConceptName(conceptRow.get("concept_name")); concept.setStandardConcept(conceptRow.get("standard_concept")); this.put(tableName, fieldName, concept); } } catch (IOException e) { throw new IOException("Could not load concept_id hints: " + e.getMessage()); } }
Source:
<code>public static String amountToDollars(int n){ String s = "$ " + (n / 100) + "."; <START> if (((n % 100) / 10) == 0) { <END> s += "0"; } s += (n % 100); return s; }</code><technical_language>this clearer condition if ((n % 100) < 10)</technical_language>

Target:
public static String amountToDollars(int n){ String s = "$ " + (n / 100) + "."; if ((n % 100) < 10) { s += "0"; } s += (n % 100); return s; }
Source:
<code>public static String encodeURLData(final Map<String, String> data) throws Exception { StringBuffer buf = new StringBuffer(); Iterator<String> iter = data.keySet().iterator(); while (iter.hasNext()) { String key = iter.next(); <START> buf.append(URLEncoder.encode(key, StandardCharsets.UTF_8)).append("=") <END> .append(URLEncoder.encode(data.get(key), StandardCharsets.UTF_8)); if (iter.hasNext()) { buf.append("&"); } } return buf.toString(); }</code><technical_language>StandardCharsets.UTF_8.toString() Older methods support charset types directly</technical_language>

Target:
public static String encodeURLData(final Map<String, String> data) throws Exception { StringBuffer buf = new StringBuffer(); Iterator<String> iter = data.keySet().iterator(); while (iter.hasNext()) { String key = iter.next(); buf.append(URLEncoder.encode(key, StandardCharsets.UTF_8.toString())) .append("=") .append(URLEncoder.encode(data.get(key), StandardCharsets.UTF_8.toString())); if (iter.hasNext()) { buf.append("&"); } } return buf.toString(); }
Source:
<code>public void update() throws BankException, LoginException, BankChoiceException, IOException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } urlopen = login(); Matcher matcher; try { response = urlopen.open("<LINK_0>"); matcher = reAccounts.matcher(response); while (matcher.find()) { String balanceString ; balanceString = matcher.group(4) + ".00"; Account account = new Account(Html.fromHtml(matcher.group(2)).toString(), Helpers.parseBalance(balanceString), matcher.group(1).trim()); account.setCurrency("ISK"); balance = balance.add(Helpers.parseBalance(matcher.group(4))); accounts.add(account); } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } } <START> finally { <END> super.updateComplete(); } }</code><technical_language>remove finally {</technical_language>

Target:
public void update() throws BankException, LoginException, BankChoiceException, IOException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); } urlopen = login(); response = urlopen.open("<LINK_0>"); Matcher matcher = reAccounts.matcher(response); while (matcher.find()) { String balanceString ; balanceString = matcher.group(4) + ".00"; Account account = new Account(Html.fromHtml(matcher.group(2)).toString(), Helpers.parseBalance(balanceString), matcher.group(1).trim()); account.setCurrency("ISK"); balance = balance.add(Helpers.parseBalance(matcher.group(4))); accounts.add(account); } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } super.updateComplete(); }
Source:
<code>public IntegrationFlow imapMailFlow() { return IntegrationFlows.from(Mail.imapInboundAdapter("imap://localhost:143") .javaMailProperties(p -> p.put("mail.debug", "true")), e -> e.autoStartup(false) .poller(Pollers.fixedDelay(1000))) <START> .channel(pop3Channel()) <END> .get(); }</code><technical_language>Fault here: imapChannel()</technical_language>

Target:
public IntegrationFlow imapMailFlow() { return IntegrationFlows.from(Mail.imapInboundAdapter("imap://user:pw@localhost:" + imapPort + "/INBOX") .javaMailProperties(p -> p.put("mail.debug", "true")), e -> e.autoStartup(true) .poller(Pollers.fixedDelay(1000))) .channel(imapChannel()) .get(); }
Source:
<code>private static boolean hasAtLeastOneSiblingWithSameTokenType(DetailAST ast) { DetailAST cur = getFirstSibling(ast); boolean result = false; while (cur != null) { <START> if (cur != ast && cur.getType() == ast.getType()) { <END> result = true; } cur = cur.getNextSibling(); } return result; }</code><technical_language>is required compare cur != ast ? for testNotUniqueDetailAst? If yes, is incorrect, cheat manually creating tree in test</technical_language>

Target:
private static boolean hasAtLeastOneSiblingWithSameTokenType(DetailAST ast) { boolean result = false; if (ast.getParent() == null) { DetailAST prev = ast.getPreviousSibling(); while (prev != null) { if (prev.getType() == ast.getType()) { result = true; break; } prev = prev.getPreviousSibling(); } if (!result) { DetailAST next = ast.getNextSibling(); while (next != null) { if (next.getType() == ast.getType()) { result = true; break; } next = next.getNextSibling(); } } } else { result = ast.getParent().getChildCount(ast.getType()) > 1; } return result; }
Source:
<code>public void run() throws Exception { HadoopConfigurationInjector.prepareResourcesToInject(getJobProps(), getWorkingDirectory()); if (shouldProxy && obtainTokens) { userToProxy = getJobProps().getString("user.to.proxy"); getLog().info("Need to proxy. Getting tokens."); Props props = new Props(); props.putAll(getJobProps()); props.putAll(getSysProps()); tokenFile = HadoopJobUtils .getHadoopTokens(hadoopSecurityManager, props, getLog()); getJobProps().put("env." + HADOOP_TOKEN_FILE_LOCATION, tokenFile.getAbsolutePath()); <START> hadoopSecurityManager.updateJobProps(getJobProps(), getSysProps(), <END> getLog()); } try { super.run(); } catch (Exception e) { e.printStackTrace(); throw new Exception(e); } finally { if (tokenFile != null) { try { HadoopJobUtils.cancelHadoopTokens(hadoopSecurityManager, userToProxy, tokenFile, getLog()); } catch (Throwable t) { t.printStackTrace(); getLog().error("Failed to cancel tokens."); } if (tokenFile.exists()) { tokenFile.delete(); } } } }</code><technical_language>is this change necessary</technical_language>

Target:
public void run() throws Exception { HadoopConfigurationInjector.prepareResourcesToInject(getJobProps(), getWorkingDirectory()); if (shouldProxy && obtainTokens) { userToProxy = getJobProps().getString("user.to.proxy"); getLog().info("Need to proxy. Getting tokens."); Props props = new Props(); props.putAll(getJobProps()); props.putAll(getSysProps()); tokenFile = HadoopJobUtils .getHadoopTokens(hadoopSecurityManager, props, getLog()); getJobProps().put("env." + HADOOP_TOKEN_FILE_LOCATION, tokenFile.getAbsolutePath()); } try { super.run(); } catch (Exception e) { e.printStackTrace(); throw new Exception(e); } finally { if (tokenFile != null) { try { HadoopJobUtils.cancelHadoopTokens(hadoopSecurityManager, userToProxy, tokenFile, getLog()); } catch (Throwable t) { t.printStackTrace(); getLog().error("Failed to cancel tokens."); } if (tokenFile.exists()) { tokenFile.delete(); } } } }
Source:
<code>public void addAdditionalListeners() { super.addAdditionalListeners(); ActivityPartition activityPartition = getUMLElement(); if (activityPartition == null) { return; } getDiagramEventBroker().addNotificationListener(activityPartition, this); <START> if (!(activityPartition.getRepresents() instanceof ConnectableElement)) { return; } <END> Element el = (Element) activityPartition.getRepresents(); if (el != null) { getDiagramEventBroker().addNotificationListener(el, this); } }</code><technical_language>is some special handling of ConnectableElement here? numerous times, exist special handling of ConnectableElement. special case exist is if represents is a NamedElement, i.e. if represents Element a name not</technical_language>

Target:
public void addAdditionalListeners() { super.addAdditionalListeners(); ActivityPartition activityPartition = getUMLElement(); if (activityPartition == null) { return; } getDiagramEventBroker().addNotificationListener(activityPartition, this); Element el = activityPartition.getRepresents(); if (el != null) { getDiagramEventBroker().addNotificationListener(el, this); } }
Source:
<code>public synchronized void shutdown() { try { if (shutdownHook != null) { synchronized (shutdownHookMonitor) { if (shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(shutdownHook); frameworkProcess = null; shutdownHook.start(); shutdownHook = null; } } } } catch (IllegalStateException ignore) { <START> <END> } }</code><technical_language>Log Exception</technical_language>

Target:
public synchronized void shutdown() { try { if (shutdownHook != null) { synchronized (shutdownHookMonitor) { if (shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(shutdownHook); frameworkProcess = null; shutdownHook.start(); shutdownHook = null; } } } } catch (IllegalStateException ignore) { logger.error("Already started the process.", ignore); } }
Source:
<code>public SwapTrade trade(LocalDate valuationDate, MarketData marketData) { double marketQuote = marketData.getValue(spreadKey) + additionalSpread; FxRate fxRate = marketData.getValue(fxKey); <START> double rate = fxRate.fxRate(fxKey.getPair()); <END> return template.toTrade(valuationDate, BuySell.BUY, 1, rate, marketQuote); }</code><technical_language>This needs convention's currency pair extract data ensure rate is right round</technical_language>

Target:
public SwapTrade trade(LocalDate valuationDate, MarketData marketData) { double marketQuote = marketData.getValue(spreadKey) + additionalSpread; FxRate fxRate = marketData.getValue(fxKey); double rate = fxRate.fxRate(template.getCurrencyPair()); return template.toTrade(valuationDate, BuySell.BUY, 1, rate, marketQuote); }
Source:
<code>private static String getSqlFromLdapFilter(Filter filter) { StringBuilder sql = new StringBuilder(); Filter[] filters = filter.getComponents(); Filter notFilter = filter.getNOTComponent(); switch (filter.getFilterType()) { case Filter.FILTER_TYPE_AND: for (int x=0 ; x < filters.length; x++) { if (x == 0) { sql.append(OPEN_PARENS); } if (x > 0) { sql.append(AND); } sql.append(getSqlFromLdapFilter(filters[x])); if (x == filters.length - 1) { sql.append(CLOSED_PARENS); } } break; case Filter.FILTER_TYPE_OR: for (int x=0 ; x < filters.length; x++) { if (x == 0) { sql.append(OPEN_PARENS); } if (x > 0) { sql.append(OR); } sql.append(getSqlFromLdapFilter(filters[x])); if (x == filters.length - 1) { sql.append(CLOSED_PARENS); } } break; case Filter.FILTER_TYPE_NOT: sql.append(NOT); sql.append(getSqlFromLdapFilter(notFilter)); break; case Filter.FILTER_TYPE_EQUALITY: if (!filter.getAttributeName().equals(CATEGORY)) { <START> throw new IllegalArgumentException("Invalid Search Parameter"); <END> } sql.append(String.format(CATEGORY_STRING, filter.getAssertionValue().toLowerCase())); break; } return sql.toString(); }</code><technical_language>give more hints this is Invalid Search Parameter</technical_language>

Target:
private static String getSqlFromLdapFilter(Filter filter) { StringBuilder sql = new StringBuilder(); Filter[] filters = filter.getComponents(); Filter notFilter = filter.getNOTComponent(); switch (filter.getFilterType()) { case Filter.FILTER_TYPE_AND: for (int x=0 ; x < filters.length; x++) { if (x == 0) { sql.append(OPEN_PARENS); } if (x > 0) { sql.append(AND); } sql.append(getSqlFromLdapFilter(filters[x])); if (x == filters.length - 1) { sql.append(CLOSED_PARENS); } } break; case Filter.FILTER_TYPE_OR: for (int x=0 ; x < filters.length; x++) { if (x == 0) { sql.append(OPEN_PARENS); } if (x > 0) { sql.append(OR); } sql.append(getSqlFromLdapFilter(filters[x])); if (x == filters.length - 1) { sql.append(CLOSED_PARENS); } } break; case Filter.FILTER_TYPE_NOT: sql.append(NOT); sql.append(getSqlFromLdapFilter(notFilter)); break; case Filter.FILTER_TYPE_EQUALITY: if (!filter.getAttributeName().equals(CATEGORY)) { throw new IllegalArgumentException("Invalid Search Parameter: LDAP attribute name must be 'cat'"); } sql.append(CATEGORY_STRING); break; } return sql.toString(); }
Source:
<code>public void handleConnectionWithValidCredentialDefaultEntry() throws Exception { final String user = "johny"; final String password = "password2"; final Opt<Identity> identity = new PsBasic( "RealmAA", new PsBasic.Default( "mike my%20password1 urn:basic:michael", String.format("%s %s urn:basic:%s", user, password, user) ) ).enter( new RqWithHeaders( new RqFake( RqMethod.GET, String.format( PsBasicTest.VALID_CODE, <START> RandomStringUtils.randomAlphanumeric(10) <END> ) ), this.generateAuthenticateHead(user, password) ) ); MatcherAssert.assertThat(identity.has(), Matchers.is(true)); MatcherAssert.assertThat( identity.get().urn(), CoreMatchers.equalTo(this.generateIdentityUrn(user)) ); }</code><technical_language>@xupyprmv Tv.TEN instead</technical_language>

Target:
public void handleConnectionWithValidCredentialDefaultEntry() throws Exception { final String user = "johny"; final String password = "password2"; final Opt<Identity> identity = new PsBasic( "RealmAA", new PsBasic.Default( "mike my%20password1 urn:basic:michael", String.format("%s %s urn:basic:%s", user, password, user) ) ).enter( new RqWithHeaders( new RqFake( RqMethod.GET, String.format( PsBasicTest.VALID_CODE, RandomStringUtils.randomAlphanumeric(Tv.TEN) ) ), PsBasicTest.header(user, password) ) ); MatcherAssert.assertThat(identity.has(), Matchers.is(true)); MatcherAssert.assertThat( identity.get().urn(), CoreMatchers.equalTo(PsBasicTest.urn(user)) ); }
Source:
<code>protected int doWork() { IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsWritable(OUTPUT); final ReferenceSequenceFile ref = ReferenceSequenceFileFactory.getReferenceSequenceFile(INPUT); final ReferenceSequenceMask referenceSequenceMask; if (INTERVALS != null) { IOUtil.assertFileIsReadable(INTERVALS); final IntervalList intervalList = IntervalList.fromFile(INTERVALS); referenceSequenceMask = new IntervalListReferenceSequenceMask(intervalList); } else { final SAMFileHeader header = new SAMFileHeader(); header.setSequenceDictionary(ref.getSequenceDictionary()); referenceSequenceMask = new WholeGenomeReferenceSequenceMask(header); } long nonNbases = 0L; for (final SAMSequenceRecord rec : ref.getSequenceDictionary().getSequences()) { final ReferenceSequence sequence = ref.getSequence(rec.getSequenceName()); final byte[] bases = sequence.getBases(); StringUtil.toUpperCase(bases); for (int i = 0; i < bases.length; i++) { if (referenceSequenceMask.get(sequence.getContigIndex(), i+1)) { <START> nonNbases += bases[i] == 'N' ? 0 : 1; <END> } } } try { final BufferedWriter out = IOUtil.openFileForBufferedWriting(OUTPUT); out.write(nonNbases + "\n"); out.close(); } catch (IOException ioe) { throw new PicardException("Error writing to file " + OUTPUT.getAbsolutePath(), ioe); } return 0; }</code><technical_language>SequenceUtil.N instead of N (perhaps overkill). IUPAC bases, matter for purposes? If so, !SequenceUtil.isValidBase</technical_language>

Target:
protected int doWork() { IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsWritable(OUTPUT); final ReferenceSequenceFile ref = ReferenceSequenceFileFactory.getReferenceSequenceFile(INPUT); final ReferenceSequenceMask referenceSequenceMask; if (INTERVALS != null) { IOUtil.assertFileIsReadable(INTERVALS); final IntervalList intervalList = IntervalList.fromFile(INTERVALS); referenceSequenceMask = new IntervalListReferenceSequenceMask(intervalList); } else { final SAMFileHeader header = new SAMFileHeader(); header.setSequenceDictionary(ref.getSequenceDictionary()); referenceSequenceMask = new WholeGenomeReferenceSequenceMask(header); } long nonNbases = 0L; for (final SAMSequenceRecord rec : ref.getSequenceDictionary().getSequences()) { final ReferenceSequence sequence = ref.getSequence(rec.getSequenceName()); final byte[] bases = sequence.getBases(); StringUtil.toUpperCase(bases); for (int i = 0; i < bases.length; i++) { if (referenceSequenceMask.get(sequence.getContigIndex(), i+1)) { nonNbases += bases[i] == SequenceUtil.N ? 0 : 1; } } } try { final BufferedWriter out = IOUtil.openFileForBufferedWriting(OUTPUT); out.write(nonNbases + "\n"); out.close(); } catch (IOException ioe) { throw new PicardException("Error writing to file " + OUTPUT.getAbsolutePath(), ioe); } return 0; }
Source:
<code>public IAttributeType getAgileTeamPointsAttributeType(IAgileTeam team) { IAttributeType type = AtsAttributeTypes.Points; String attrTypeName = atsServer.getAttributeResolver().getSoleAttributeValue(team, AtsAttributeTypes.PointsAttributeType, null); if (Strings.isValid(attrTypeName)) { boolean found = false; for (IAttributeType attrType : atsServer.getOrcsApi().getOrcsTypes().getAttributeTypes().getAll()) { if (attrType.getName().equals(attrTypeName)) { <START> type = <END> attrType; found = true; break; } } if (!found) { throw new OseeCoreException("Invalid attribute type name provided: %s", attrTypeName); } } return null; }</code><technical_language>this variable is used. Suggest removing if this is case</technical_language>

Target:
public IAttributeType getAgileTeamPointsAttributeType(IAgileTeam team) { IAttributeType type = AtsAttributeTypes.Points; String attrTypeName = atsServer.getAttributeResolver().getSoleAttributeValue(team, AtsAttributeTypes.PointsAttributeType, null); if (Strings.isValid(attrTypeName)) { type = getTypeFromName(attrTypeName); } return type; }
Source:
<code>public void setPresenter(ProviderDashboardContract.Presenter presenter) { <START> <END> }</code><technical_language>This empty. Possibly put java mPresenter = (ProviderDashboardPresenter) presenter;</technical_language>

Target:
public void setPresenter(ProviderDashboardContract.Presenter presenter) { mPresenter = (ProviderDashboardPresenter) presenter; }
Source:
<code>public OnmsNode act(final OnmsNode node, Map<String, Object> attributes) { try { final CompiledScript compiledScript = compileScript(getScript()); if (compiledScript == null) { LOG.warn("No compiled script available for execution."); } else { if (attributes.size() > 0 && attributes.get(RUN_IN_TRANSACTION) != null && attributes.get(RUN_IN_TRANSACTION).equals(true)) { return (OnmsNode) m_sessionUtils.withTransaction(() -> { try { if (node.getId() != null && node.getId() > 0) { OnmsNode onmsNode = m_nodeDao.get(node.getId()); return runScript(compiledScript, onmsNode, attributes); } else { LOG.warn("Unexpected node which is not persisted yet", node); } } catch (ScriptException e) { LOG.warn("Error applying ScriptPolicy.", e); } return node; }); } else { runScript(compiledScript, node, attributes); } } } catch (ScriptException e) { LOG.warn("Error while compiling script.", e); } catch (IOException e) { LOG.warn("Error while opening script file {}.", m_script, e); } catch (Exception e) { <START> LOG.warn("Unkown Error while applying script.", e); <END> } return node; }</code><technical_language>suggestion LOG.warn("Unknown error while applying script.", e);</technical_language>

Target:
public OnmsNode act(final OnmsNode node, Map<String, Object> attributes) { try { final CompiledScript compiledScript = compileScript(getScript()); if (compiledScript == null) { LOG.warn("No compiled script available for execution."); } else { if (attributes.size() > 0 && attributes.get(RUN_IN_TRANSACTION) != null && attributes.get(RUN_IN_TRANSACTION).equals(true)) { return (OnmsNode) m_sessionUtils.withTransaction(() -> { try { if (node.getId() != null && node.getId() > 0) { OnmsNode onmsNode = m_nodeDao.get(node.getId()); return runScript(compiledScript, onmsNode, attributes); } else { LOG.warn("Unexpected node which is not persisted yet", node); } } catch (ScriptException e) { LOG.warn("Error applying ScriptPolicy.", e); } return node; }); } else { runScript(compiledScript, node, attributes); } } } catch (ScriptException e) { LOG.warn("Error while compiling script.", e); } catch (IOException e) { LOG.warn("Error while opening script file {}.", m_script, e); } catch (Exception e) { LOG.warn("Unkown error while applying script.", e); } return node; }
Source:
<code>public RequestBuilder fit() { getOptions(); <START> deferred = true; <END> return this; }</code><technical_language>remove? This is true</technical_language>

Target:
public RequestBuilder fit() { PicassoBitmapOptions options = getOptions(); if (options.targetWidth != 0 || options.targetHeight != 0) { throw new IllegalStateException("Fit cannot be used with resize."); } deferred = true; return this; }
Source:
<code><START> public FiltersEndpoint filtersEndpoint() { <END> return new FiltersEndpoint(); }</code><technical_language>Need add @ConditionalOnEnabledEndpoint("filters")</technical_language>

Target:
public FiltersEndpoint filtersEndpoint() { FilterRegistry filterRegistry = FilterRegistry.instance(); return new FiltersEndpoint(filterRegistry); }
Source:
<code>private String readPasswordFile(String passwordFile) throws FileNotFoundException, IOException { <START> try (BufferedReader bufferedReader = new BufferedReader(new FileReader(passwordFile))) { <END> String readLine = bufferedReader.readLine(); return readLine; } }</code><technical_language>no... InputStreamReader charset</technical_language>

Target:
private String readPasswordFile(String passwordFile) throws FileNotFoundException, IOException { try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(passwordFile), "UTF-8"))) { String readLine = bufferedReader.readLine(); return readLine; } }
Source:
<code>private void parseReportsXML() { try { constructServiceRequestBuilder(ReportXmlService).sendRequest(null, new RequestCallback() { @Override public void onError(Request request, Throwable exception) { scheduleCheckStatus(); setXmlInitialized(); } @Override public void onResponseReceived(Request request, Response response) { <START> switch (response.getStatusCode()) { <END> case Response.SC_INTERNAL_SERVER_ERROR: scheduleCheckStatus(); setXmlInitialized(); break; case Response.SC_OK: try { if (ReportParser.getInstance().parseReport(response.getText())) { resourceMap = ReportParser.getInstance().getResourceMap(); dashboardMap = ReportParser.getInstance().getDashboardMap(); isCommunityEdition = ReportParser.getInstance().isCommunityEdition(); } } catch (DOMParseException e) { } finally { setXmlInitialized(); } break; } } }); } catch (RequestException e) { setXmlInitialized(); } }</code><technical_language>please default statement</technical_language>

Target:
private void parseReportsXML() { try { constructServiceRequestBuilder(ReportXmlService).sendRequest(null, new RequestCallback() { @Override public void onError(Request request, Throwable exception) { scheduleCheckStatus(); setXmlInitialized(); } @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_OK) { try { if (ReportParser.getInstance().parseReport(response.getText())) { resourceMap = ReportParser.getInstance().getResourceMap(); dashboardMap = ReportParser.getInstance().getDashboardMap(); isCommunityEdition = ReportParser.getInstance().isCommunityEdition(); } } catch (DOMParseException e) { } finally { setXmlInitialized(); } } else { scheduleCheckStatus(); setXmlInitialized(); } } }); } catch (RequestException e) { setXmlInitialized(); } }
Source:
<code>public static File writeToTempFile(InputStream is, File tempDir, String prefix, String suffix) { <START> if (is == null) throw new NullPointerException("Input stream required to create temp file for "+prefix+"*"+suffix); <END> mkdirs(tempDir); File tempFile; try { tempFile = File.createTempFile(prefix, suffix, tempDir); } catch (IOException e) { throw Throwables.propagate(e); } tempFile.deleteOnExit(); OutputStream out = null; try { out = new FileOutputStream(tempFile); ByteStreams.copy(is, out); } catch (IOException e) { throw Throwables.propagate(e); } finally { Streams.closeQuietly(is); Streams.closeQuietly(out); } return tempFile; }</code><technical_language>Preconditions.checkNotNull(is, "Input stream required create temp file for %s*%s", prefix, suffix);</technical_language>

Target:
public static File writeToTempFile(InputStream is, File tempDir, String prefix, String suffix) { Preconditions.checkNotNull(is, "Input stream required to create temp file for %s*%s", prefix, suffix); mkdirs(tempDir); File tempFile; try { tempFile = File.createTempFile(prefix, suffix, tempDir); } catch (IOException e) { throw Throwables.propagate(e); } tempFile.deleteOnExit(); OutputStream out = null; try { out = new FileOutputStream(tempFile); ByteStreams.copy(is, out); } catch (IOException e) { throw Throwables.propagate(e); } finally { Streams.closeQuietly(is); Streams.closeQuietly(out); } return tempFile; }
Source:
<code>public void callback(final HttpServletRequest request, final HttpServletResponse response) { assertNotNull("callbackLogic", callbackLogic); assertNotNull("config", config); final JEEContext context = new JEEContext(request, response, config.getSessionStore()); <START> callbackLogic.perform(context, config, (action, theContext) -> null, this.defaultUrl, <END> this.saveInSession, this.multiProfile, this.renewSession, this.defaultClient); }</code><technical_language>JEEHttpActionAdapter.INSTANCE</technical_language>

Target:
public void callback(final HttpServletRequest request, final HttpServletResponse response) { assertNotNull("callbackLogic", callbackLogic); assertNotNull("config", config); final JEEContext context = new JEEContext(request, response, config.getSessionStore()); callbackLogic.perform(context, config, JEEHttpActionAdapter.INSTANCE, this.defaultUrl, this.saveInSession, this.multiProfile, this.renewSession, this.defaultClient); }
Source:
<code>private ThriftSchemaConvertVisitor(FieldProjectionFilter fieldProjectionFilter, boolean doProjection, boolean keepOneOfEachUnion) { <START> this(fieldProjectionFilter, doProjection, keepOneOfEachUnion, null); <END> }</code><technical_language>avoid null</technical_language>

Target:
private ThriftSchemaConvertVisitor(FieldProjectionFilter fieldProjectionFilter, boolean doProjection, boolean keepOneOfEachUnion) { this(fieldProjectionFilter, doProjection, keepOneOfEachUnion, new Configuration()); }
Source:
<code>public boolean buildCollectorFile(ConcurStandardAccountingExtractFile saeFileContents) { ConcurStandardAccountingExtractCollectorBatchBuilder builder = new ConcurStandardAccountingExtractCollectorBatchBuilder( <START> universityDateService::getFiscalYear, dateTimeService::toString, <END> concurSAEValidationService::validateConcurStandardAccountingExtractDetailLine, this::getConcurParameterValueAsString); CollectorBatch collectorBatch = builder.buildCollectorBatchFromStandardAccountingExtract(0, saeFileContents); if (collectorBatch == null) { LOG.error("There was a problem preparing the data for the Collector file; will not create a file."); return false; } return true; }</code><technical_language>define lamba functions a variables understanding is on</technical_language>

Target:
public boolean buildCollectorFile(ConcurStandardAccountingExtractFile saeFileContents) { ConcurStandardAccountingExtractCollectorBatchBuilder builder = new ConcurStandardAccountingExtractCollectorBatchBuilder( universityDateService, dateTimeService, concurSAEValidationService, this::getConcurParameterValueAsString); CollectorBatch collectorBatch = builder.buildCollectorBatchFromStandardAccountingExtract(0, saeFileContents); if (collectorBatch == null) { LOG.error("There was a problem preparing the data for the Collector file; will not create a file."); return false; } return true; }
Source:
<code>public void destroy(int code) { if (routeBuilder == null) { return; } for (RouteDefinition routeDef : routeBuilder.getRouteCollection().getRoutes()) { try { String routeId = routeDef.getId(); LOGGER.trace("Stopping route with ID = and path {}", routeId, monitoredDirectory); <START> camelContext.stopRoute(routeId); <END> boolean status = camelContext.removeRoute(routeId); LOGGER.trace("Status of removing route is {}", routeId, status); camelContext.removeRouteDefinition(routeDef); } catch (Exception e) { LOGGER.debug("Unable to stop Camel route with route ID = {}", routeDef.getId(), e); } } }</code><technical_language>Access routeBuilder is done destroy init threads. a lock protection</technical_language>

Target:
public void destroy(int code) { CompletableFuture.runAsync(this::removeRoutes, configurationExecutor); }
Source:
<code>public void run(ToolingApiOperation runnable, CancellationTokenSource tokenSource, IProgressMonitor monitor) throws CoreException { IProgressMonitor efficientMonitor = new RateLimitingProgressMonitor(monitor, 500, TimeUnit.MILLISECONDS); <START> new WorkspaceRunnableAdapter(runnable, tokenSource).run(efficientMonitor); <END> }</code><technical_language>This this case work incidentally. proper approach define ToolingApiOperation#getRule() returns ISchedulingRule instance. rule passed IWorkspace#run() ToolingApiJob#setRule()as well</technical_language>

Target:
public void run(ToolingApiOperation runnable, CancellationTokenSource tokenSource, IProgressMonitor monitor) throws CoreException { IProgressMonitor efficientMonitor = new RateLimitingProgressMonitor(monitor, 500, TimeUnit.MILLISECONDS); ResourcesPlugin.getWorkspace().run(new WorkspaceRunnableAdapter(runnable, tokenSource), runnable.getRule(), IWorkspace.AVOID_UPDATE, efficientMonitor); }