auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void setUp() throws Exception { MockitoAnnotations.initMocks(this); configuration = new Configuration(); RegionCoprocessorEnvironment environment = new CompatRegionCoprocessorEnvironment() { @Override public int getVersion() { return 0; } @Override public String getHBaseVersion() { return null; } @Override public Coprocessor getInstance() { return null; } @Override public int getPriority() { return 0; } @Override public int getLoadSequence() { return 0; } @Override public Configuration getConfiguration() { return configuration; } @Override public HTableInterface getTable( TableName tableName) throws IOException { return null; } @Override public HTableInterface getTable(TableName tableName, ExecutorService service) throws IOException { return null; } @Override public ClassLoader getClassLoader() { return null; } @Override public Region getRegion() { return region; } @Override public HRegionInfo getRegionInfo() { return regionInfo; } @Override public RegionServerServices getRegionServerServices() { return null; } @Override public ConcurrentMap<String, Object> getSharedData() { return null; } <START> @Override <END> public MetricRegistry getMetricRegistryForRegionServer() { return null; } }; taskMetaDataEndpoint = new TaskMetaDataEndpoint(); taskMetaDataEndpoint.start(environment); }</code><technical_language>nit: Fix indentation. Also, is this change for</technical_language>

Target:
public void setUp() throws Exception { MockitoAnnotations.initMocks(this); configuration = new Configuration(); RegionCoprocessorEnvironment environment = new CompatRegionCoprocessorEnvironment() { @Override public int getVersion() { return 0; } @Override public String getHBaseVersion() { return null; } @Override public Coprocessor getInstance() { return null; } @Override public int getPriority() { return 0; } @Override public int getLoadSequence() { return 0; } @Override public Configuration getConfiguration() { return configuration; } @Override public HTableInterface getTable( TableName tableName) throws IOException { return null; } @Override public HTableInterface getTable(TableName tableName, ExecutorService service) throws IOException { return null; } @Override public ClassLoader getClassLoader() { return null; } @Override public Region getRegion() { return region; } @Override public HRegionInfo getRegionInfo() { return regionInfo; } @Override public RegionServerServices getRegionServerServices() { return null; } @Override public ConcurrentMap<String, Object> getSharedData() { return null; } }; taskMetaDataEndpoint = new TaskMetaDataEndpoint(); taskMetaDataEndpoint.start(environment); }
Source:
<code>private String getBarcodeQuality(ClusterData cluster) { <START> final String[] barcodeQ = new String[sampleBarcodeIndices.length]; <END> for (int i = 0; i < sampleBarcodeIndices.length; i++) { barcodeQ[i] = SAMUtils.phredToFastq(cluster.getRead(sampleBarcodeIndices[i]).getQualities()); } return String.join("~", barcodeQ); }</code><technical_language>a stringjoiner avoid creating array final StringJoiner barcodeQ = new StringJoiner("~"); for (int sampleBarcodeIndice : sampleBarcodeIndices) { barcodeQ.add(SAMUtils.phredToFastq(cluster.getRead(sampleBarcodeIndice).getQualities())); } return barcodeQ.toString();</technical_language>

Target:
private String getBarcodeQuality(ClusterData cluster) { final StringJoiner barcodeQ = new StringJoiner(MOLECULAR_INDEX_QUALITY_DELIMITER); for (int sampleBarcodeIndex : sampleBarcodeIndices) { barcodeQ.add(SAMUtils.phredToFastq(cluster.getRead(sampleBarcodeIndex).getQualities())); } return barcodeQ.toString(); }
Source:
<code>private ChromeCasts() { <START> chromeCasts = Collections.synchronizedList(new ArrayList<ChromeCast>()); <END> }</code><technical_language>moved field initialization declaration constructor? I leave in declaration for uniformity</technical_language>

Target:
private ChromeCasts() { }
Source:
<code>private void createActions(boolean forEditor) { fRenameAction = new CRenameAction(); fRenameAction.setActionDefinitionId(ICEditorActionDefinitionIds.RENAME_ELEMENT); fAllActions.add(fRenameAction); if <START> (!forEditor) { <END> fDeleteAction = new CDeleteAction(); fDeleteAction.setActionDefinitionId(ActionFactory.DELETE.getId()); fAllActions.add(fDeleteAction); } if (forEditor) { fExtractConstantAction= new ExtractConstantAction(); fExtractConstantAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_CONSTANT); fAllActions.add(fExtractConstantAction); fExtractLocalVariableAction= new ExtractLocalVariableAction(); fExtractLocalVariableAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_LOCAL_VARIABLE); fAllActions.add(fExtractLocalVariableAction); fExtractFunctionAction = new ExtractFunctionAction(); fExtractFunctionAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_FUNCTION); fAllActions.add(fExtractFunctionAction); fToggleFunctionAction = new ToggleFunctionAction(); fToggleFunctionAction.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_FUNCTION); fAllActions.add(fToggleFunctionAction); } fHideMethodAction = new HideMethodAction(); fHideMethodAction.setActionDefinitionId(ICEditorActionDefinitionIds.HIDE_METHOD); fAllActions.add(fHideMethodAction); }</code><technical_language>this "else" "if (forEditor)" block</technical_language>

Target:
private void createActions(boolean forEditor) { fRenameAction = new CRenameAction(); fRenameAction.setActionDefinitionId(ICEditorActionDefinitionIds.RENAME_ELEMENT); fAllActions.add(fRenameAction); if (forEditor) { fExtractConstantAction= new ExtractConstantAction(); fExtractConstantAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_CONSTANT); fAllActions.add(fExtractConstantAction); fExtractLocalVariableAction= new ExtractLocalVariableAction(); fExtractLocalVariableAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_LOCAL_VARIABLE); fAllActions.add(fExtractLocalVariableAction); fExtractFunctionAction = new ExtractFunctionAction(); fExtractFunctionAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_FUNCTION); fAllActions.add(fExtractFunctionAction); fToggleFunctionAction = new ToggleFunctionAction(); fToggleFunctionAction.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_FUNCTION); fAllActions.add(fToggleFunctionAction); } else { fDeleteAction = new CDeleteAction(); fDeleteAction.setActionDefinitionId(ICEditorActionDefinitionIds.DELETE_ELEMENT); fAllActions.add(fDeleteAction); } fHideMethodAction = new HideMethodAction(); fHideMethodAction.setActionDefinitionId(ICEditorActionDefinitionIds.HIDE_METHOD); fAllActions.add(fHideMethodAction); }
Source:
<code>private void setupUI() { setContentView(R.layout.prompt_view); <START> promptTitle = findViewById(R.id.prompt_title); <END> actionButton = findViewById(R.id.action_button); doLaterButton = findViewById(R.id.do_later_button); imageCue = findViewById(R.id.image_cue); instructions = findViewById(R.id.instructions); if (getInstructionsStringKey() != null) { instructions.setText(Localization.get(getInstructionsStringKey())); } TextView helpText = findViewById(R.id.help_text); helpText.setText(Localization.get("prompt.help.text", getActionString())); doLaterButton.setOnClickListener(v -> PromptActivity.this.finish()); if (inForceMode()) { promptTitle.setTextColor(getResources().getColor(R.color.cc_attention_negative_color)); promptTitle.setTypeface(Typeface.DEFAULT_BOLD); } setUpTypeSpecificUIComponents(); updateVisibilities(); }</code><technical_language>Is a reason linking @UiElement syntax? save a minor amount of code. I assume Locale strings required? a 'fallback' path Locale strings if availalble, on-device strings if not, helpful, especially if app successfully (or partially) seated, users recovery actions translated</technical_language>

Target:
private void setupUI() { if (getInstructionsStringKey() != null) { instructions.setText(Localization.get(getInstructionsStringKey())); } helpText.setText(Localization.get(getHelpTextResource())); doLaterButton.setOnClickListener(v -> PromptActivity.this.finish()); if (inForceMode()) { promptTitle.setTextColor(getResources().getColor(R.color.cc_attention_negative_color)); promptTitle.setTypeface(Typeface.DEFAULT_BOLD); } setUpTypeSpecificUIComponents(); updateVisibilities(); }
Source:
<code>public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { fAdditionalContentTypesIDs = new String[0]; if (data != null) { <START> if (data instanceof String && data.toString().length() > 0) { <END> fAdditionalContentTypesIDs = StringUtils.unpack(data.toString()); } } }</code><technical_language>This is a bit puzzling. Is instanceof necessary</technical_language>

Target:
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { fAdditionalContentTypesIDs = new String[0]; if (data instanceof String && data.toString().length() > 0) { fAdditionalContentTypesIDs = StringUtils.unpack(data.toString()); } }
Source:
<code>public Predicate visit(BetweenPredicate predicate, Indexes indexes) { TypeConverter converter = indexes.getConverter(predicate.attributeName); if (converter == null) { return predicate; } Comparable from = converter.convert(predicate.from); Comparable to = converter.convert(predicate.to); Order order = compare(from, to); switch (order) { case LESS: return predicate; case EQUAL: <START> return new EqualPredicate(predicate.attributeName, from); <END> case GREATER: return Predicates.alwaysFalse(); default: throw new IllegalStateException("Unexpected order: " + order); } }</code><technical_language>Predicates.equal</technical_language>

Target:
public Predicate visit(BetweenPredicate predicate, Indexes indexes) { TypeConverter converter = indexes.getConverter(predicate.attributeName); if (converter == null) { return predicate; } Comparable from = converter.convert(predicate.from); Comparable to = converter.convert(predicate.to); Order order = compare(from, to); switch (order) { case LESS: return predicate; case EQUAL: return Predicates.equal(predicate.attributeName, from); case GREATER: return Predicates.alwaysFalse(); default: throw new IllegalStateException("Unexpected order: " + order); } }
Source:
<code>public boolean doPostCreateApplication(ServiceProvider serviceProvider, String tenantDomain, String userName) throws IdentityApplicationManagementException { <START> if (isEnable()) { <END> audit.info(String.format(AUDIT_MESSAGE, userName, "create", serviceProvider.getApplicationID(), serviceProvider.getApplicationName(), SUCCESS)); } return true; }</code><technical_language>need check isEnable() here. checked in IdentityProviderManager invoking listener. contract of interface - listener is enabled not. UserOperationEventListeners need check this in implementation method is part of interface contract. in abstract class. This is interface in kernel add method in kernel</technical_language>

Target:
public boolean doPostCreateApplication(ServiceProvider serviceProvider, String tenantDomain, String userName) throws IdentityApplicationManagementException { int appId = -1; String name = "Undefined"; if (serviceProvider != null) { appId = serviceProvider.getApplicationID(); name = serviceProvider.getApplicationName(); } audit.info(String.format(AUDIT_MESSAGE, userName, "create", appId, name, SUCCESS)); return true; }
Source:
<code>public void activateClearance(StorageDomain storageDomain){ <START> storageDomain.setDomainStatus(StorageDomain.DomainStatus.ACTIVE); <END> updateStorageDomain(storageDomain); }</code><technical_language>NPE. In line 340 return null blow here</technical_language>

Target:
private void activateClearance(StorageDomain storageDomain){ storageDomain.setDomainStatus(StorageDomain.DomainStatus.ACTIVE); updateStorageDomain(storageDomain); }
Source:
<code>public void open_authPlain() throws Exception { settings.setAuthType(AuthType.PLAIN); MockImapServer server = new MockImapServer(); preAuthenticationDialog(server, "AUTH=PLAIN"); server.expect("2 AUTHENTICATE PLAIN"); server.output("+"); server.expect(ByteString.encodeUtf8("\000" + USERNAME + "\000" + PASSWORD).base64()); server.output("2 OK Success"); <START> simplePostAuthenticationDialog(server, true); <END> ImapConnection imapConnection = startServerAndCreateImapConnection(server); imapConnection.open(); server.verifyConnectionStillOpen(); server.verifyInteractionCompleted(); }</code><technical_language>here. true encoded in method name</technical_language>

Target:
public void open_authPlain() throws Exception { settings.setAuthType(AuthType.PLAIN); MockImapServer server = new MockImapServer(); preAuthenticationDialog(server, "AUTH=PLAIN"); server.expect("2 AUTHENTICATE PLAIN"); server.output("+"); server.expect(ByteString.encodeUtf8("\000" + USERNAME + "\000" + PASSWORD).base64()); server.output("2 OK Success"); postAuthenticationDialogRequestingCapabilities(server); ImapConnection imapConnection = startServerAndCreateImapConnection(server); imapConnection.open(); server.verifyConnectionStillOpen(); server.verifyInteractionCompleted(); }
Source:
<code>public Properties getProducerProperties(String outputChannelName) { Properties channelProducerProperties = new Properties(); BindingProperties bindingProperties = this.bindings.get(outputChannelName); if (bindingProperties != null) { <START> if (Boolean.TRUE.equals(bindingProperties.isSyncProducer())) { <END> channelProducerProperties.setProperty(BinderPropertyKeys.SYNC_PRODUCER, Boolean.toString(bindingProperties.isSyncProducer())); } } updateBatchProperties(outputChannelName, channelProducerProperties); updateProducerPartitionProperties(outputChannelName, channelProducerProperties); return channelProducerProperties; }</code><technical_language>here. binder able decide implement this</technical_language>

Target:
public Properties getProducerProperties(String outputChannelName) { Properties channelProducerProperties = new Properties(); updateBatchProperties(outputChannelName, channelProducerProperties); updateProducerPartitionProperties(outputChannelName, channelProducerProperties); return channelProducerProperties; }
Source:
<code>public void setVirtualHost(String virtualHost) { <START> this.virtualHost = (virtualHost == null || virtualHost.isEmpty()) ? "/" : virtualHost; <END> }</code><technical_language>org.springframework.util.StringUtils#hasLength avoid checks</technical_language>

Target:
public void setVirtualHost(String virtualHost) { this.virtualHost = StringUtils.hasLength(virtualHost) ? virtualHost : "/"; }
Source:
<code>public void beginFormat(Format format, Map<String, String> parameters) { if (this.previousFormatParameters != null) { if (parameters.isEmpty()) { <START> <END> } else if (!this.previousFormatParameters.equals(parameters)) { this.previousFormatParameters = null; printParameters(parameters, false); } else { this.previousFormatParameters = null; } } else if (this.previousFormatParameters == null) { printParameters(parameters, false); } switch (format) { case BOLD: if (this.previousFormatParameters != null) { getPrinter().print("(%%)"); this.previousFormatParameters = null; } getXWikiPrinter().printBeginBold(); break; case ITALIC: if (this.previousFormatParameters != null) { getPrinter().print("(%%)"); this.previousFormatParameters = null; } getXWikiPrinter().printBeginItalic(); break; case STRIKEDOUT: print("--"); break; case UNDERLINED: print("__"); break; case SUPERSCRIPT: print("^^"); break; case SUBSCRIPT: print(",,"); break; case MONOSPACE: print("##"); break; case NONE: break; } }</code><technical_language>code modified empty if</technical_language>

Target:
public void beginFormat(Format format, Map<String, String> parameters) { if (this.previousFormatParameters != null) { if (parameters.isEmpty()) { print("(%%)"); this.previousFormatParameters = null; } else if (!this.previousFormatParameters.equals(parameters)) { this.previousFormatParameters = null; printParameters(parameters, false); } else { this.previousFormatParameters = null; } } else if (this.previousFormatParameters == null) { printParameters(parameters, false); } switch (format) { case BOLD: if (this.previousFormatParameters != null) { getPrinter().print("(%%)"); this.previousFormatParameters = null; } getXWikiPrinter().printBeginBold(); break; case ITALIC: if (this.previousFormatParameters != null) { getPrinter().print("(%%)"); this.previousFormatParameters = null; } getXWikiPrinter().printBeginItalic(); break; case STRIKEDOUT: print("--"); break; case UNDERLINED: print("__"); break; case SUPERSCRIPT: print("^^"); break; case SUBSCRIPT: print(",,"); break; case MONOSPACE: print("##"); break; case NONE: break; } }
Source:
<code>private static int integerLiteral(char[] value) { int i = 0; char c = value[i++]; if (c == '0' && i < value.length) { c = value[i]; switch ((c | 0x20)) { case 'x': return probablyHex(value, i); case 'b': return probablyBinary(value, i); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': while (i < value.length) { <START> if (isOctal(c)) { <END> c = value[++i]; } else if (c == '\'') { i++; continue; } else { break; } } break; case '.': return afterDecimalPoint(value, i); } if (c == '8' || c == '9') { c = value[i]; while (Character.isDigit(c) && i < value.length) { c = value[++i]; } } return handleDecimalOrExponent(value, c, i); } else if (Character.isDigit(c)) { c = value[i]; while (i < value.length) { if (Character.isDigit(c)) { c = value[++i]; } else if (c == '\'') { i++; continue; } else { break; } } return handleDecimalOrExponent(value, c, i); } else { assert false; } return i; }</code><technical_language>I get effect repetition, writing functions called 'isOctalOrSeparator', 'isDigitOrSeparator', 'isHexDigitOrSeparator', functions instead of 'isOctal', 'Character.isDigit', 'isHexDigit' (respectively), while leaving loop in previous form</technical_language>

Target:
private static int integerLiteral(char[] value) { int i = 0; char c = value[i++]; if (c == '0' && i < value.length) { c = value[i]; switch ((c | 0x20)) { case 'x': return probablyHex(value, i); case 'b': return probablyBinary(value, i); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': while (isOctalOrSeparator(c) && i < value.length) { c = value[++i]; } break; case '.': return afterDecimalPoint(value, i); } if (c == '8' || c == '9') { c = value[i]; while (Character.isDigit(c) && i < value.length) { c = value[++i]; } } return handleDecimalOrExponent(value, c, i); } else if (Character.isDigit(c)) { c = value[i]; while (isDigitOrSeparator(c) && i < value.length) { c = value[++i]; } return handleDecimalOrExponent(value, c, i); } else { assert false; } return i; }
Source:
<code>public void testVerticalScrollingDown() { Assert.assertTrue(driver.findElementByXPath(" try { findElement(verView2); Assert.fail("shouldn't find element" + verView2); } catch (NoSuchElementException e) { } try { findElement(verView3); Assert.fail("shouldn't find element" + verView3); } catch (NoSuchElementException e) { } ((RemoteUIAScrollView) driver.findElementByXPath(" waitForElement(driver, By.xpath(" Assert.assertTrue(driver.findElementByXPath(" try { <START> findElement(verView1); <END> Assert.fail("shouldn't find element" + verView1); } catch (NoSuchElementException e) { } try { findElement(verView3); Assert.fail("shouldn't find element" + verView3); } catch (NoSuchElementException e) { } ((RemoteUIAScrollView) driver.findElementByXPath(" }</code><technical_language>This can/should combined try ... catch block follows</technical_language>

Target:
public void testVerticalScrollingDown() { Assert.assertTrue(driver.findElementByXPath(" Assert.assertFalse(elementExists(verView2)); Assert.assertFalse(elementExists(verView3)); ((RemoteUIAScrollView) driver.findElementByXPath(" waitForElement(driver, By.xpath(" Assert.assertTrue(driver.findElementByXPath(" Assert.assertFalse(elementExists(verView1)); Assert.assertFalse(elementExists(verView3)); ((RemoteUIAScrollView) driver.findElementByXPath(" }
Source:
<code>public static String encrypt(String utf8StrToEncrypt, Cipher cipher) { try { if (cipher != null) { return Base64.getEncoder().encodeToString(cipher.doFinal(utf8StrToEncrypt.getBytes("UTF-8"))); } else { throw new Exception("Must provide chiper"); <START> } <END> } catch (Exception e) { System.out.println("Error while encrypting: " + e.toString()); } return null; }</code><technical_language>spelling - cipher</technical_language>

Target:
public static String encrypt(String utf8StrToEncrypt, Cipher cipher) { try { if (cipher != null) { return Base64.getEncoder().encodeToString(cipher.doFinal(utf8StrToEncrypt.getBytes("UTF-8"))); } else { throw new Exception("Must provide cipher"); } } catch (Exception e) { System.out.println("Error while encrypting: " + e.toString()); } return null; }
Source:
<code>public void runMiniBatch(final Collection<NeuralNetworkData> miniBatchData, final MiniBatchInfo miniBatchInfo) { for (final NeuralNetworkData data : miniBatchData) { if (data.isValidation()) { continue; } final Matrix input = dataParser.asMatrix(data.getInstances()); final int[] labels = data.getLabels(); if (input.getColumns() != labels.length) { throw new RuntimeException("Invalid data: the number of inputs is not equal to the number of labels"); } neuralNetwork.train(input, labels); MatrixUtils.free(input); } <START> neuralNetwork.updateParameters(); <END> }</code><technical_language>in onEpochFinished</technical_language>

Target:
public void runMiniBatch(final Collection<NeuralNetworkData> miniBatchData, final MiniBatchInfo miniBatchInfo) { for (final NeuralNetworkData data : miniBatchData) { if (data.isValidation()) { continue; } final Matrix input = dataParser.asMatrix(data.getInstances()); final int[] labels = data.getLabels(); if (input.getColumns() != labels.length) { throw new RuntimeException("Invalid data: the number of inputs is not equal to the number of labels"); } neuralNetwork.train(input, labels); MatrixUtils.free(input); } }
Source:
<code>public SimpleXMLConverter() { <START> serializer = new Persister(); <END> }</code><technical_language>switch this to: java this(new Persister());</technical_language>

Target:
public SimpleXMLConverter() { this(new Persister()); }
Source:
<code>public void testEnvironmentVariableOverrides() { Map<String, String> overrideVariables = new HashMap<>(); <START> overrideVariables.put("HS_ACCESS_GROUP", "test"); <END> overrideVariables.put("STARTED_BY_USER", "notTestUser"); SingularityRunNowRequest runNowRequest = new SingularityRunNowRequestBuilder() .environmentVariables(overrideVariables) .build(); final SingularityRequest request = new SingularityRequestBuilder("test", RequestType.WORKER) .build(); final SingularityDeploy deploy = new SingularityDeployBuilder("test", "1") .setCommand(Optional.of("/bin/echo hi")) .setRunImmediately(Optional.of(runNowRequest)) .build(); final SingularityTaskRequest taskRequest = new SingularityTaskRequest(request, deploy, pendingTask); final SingularityTask task = builder.buildTask(offerHolder, null, taskRequest, taskResources, executorResources); Map<String, String> environmentVariables = task.getMesosTask() .getCommand() .getEnvironment() .getVariablesList() .stream() .collect(Collectors.toMap(Variable::getName, Variable::getValue)); for (String key : overrideVariables.keySet()) { assertEquals( "Environment variable " + key + " not overridden.", environmentVariables.get(key), overrideVariables.get(key)); } }</code><technical_language>generally try HubSpot-specific out of Singularity, for tests ;)</technical_language>

Target:
public void testEnvironmentVariableOverrides() { Map<String, String> overrideVariables = new HashMap<>(); overrideVariables.put("MY_NEW_ENV_VAR", "test"); overrideVariables.put("STARTED_BY_USER", "notTestUser"); final SingularityRequest request = new SingularityRequestBuilder("test", RequestType.WORKER) .build(); final SingularityDeploy deploy = new SingularityDeployBuilder("test", "1") .setCommand(Optional.of("/bin/echo hi")) .build(); final SingularityPendingTask pendingTask = new SingularityPendingTaskBuilder() .setPendingTaskId(new SingularityPendingTaskId("test", "1", 0, 1, PendingType.IMMEDIATE, 0)) .setUser(user) .setEnvOverrides(overrideVariables) .build(); final SingularityTaskRequest taskRequest = new SingularityTaskRequest(request, deploy, pendingTask); final TaskInfo task = builder.buildTask(offerHolder, null, taskRequest, taskResources, executorResources).getMesosTask(); Map<String, String> environmentVariables = task .getCommand() .getEnvironment() .getVariablesList() .stream() .collect(Collectors.toMap(Variable::getName, Variable::getValue)); for (String key : overrideVariables.keySet()) { assertEquals( "Environment variable " + key + " not overridden.", environmentVariables.get(key), overrideVariables.get(key)); } }
Source:
<code>public synchronized String getFieldString(Date d) { <START> StringBuffer buffer = new StringBuffer(255); <END> if (d != null) { calendar.setTime(d); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); if (year < 1000) { if (year >= 100) { buffer.append("0"); } else if (year >= 10) { buffer.append("00"); } else { buffer.append("000"); } } buffer.append(year); if (month < 10) { buffer.append("0"); } buffer.append(month); if (day < 10) { buffer.append("0"); } buffer.append(day); } else { buffer.setLength(8); buffer.replace(0, 8, emptyString); } buffer.setLength(8); return buffer.toString(); }</code><technical_language>Allocating a new buffer for read visible performance consequences (this code is key benchmarks shapefile data), please undo this change</technical_language>

Target:
public String getFieldString(Date d) { if (d != null) { buffer.delete(0, buffer.length()); calendar.setTime(d); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); if (year < 1000) { if (year >= 100) { buffer.append("0"); } else if (year >= 10) { buffer.append("00"); } else { buffer.append("000"); } } buffer.append(year); if (month < 10) { buffer.append("0"); } buffer.append(month); if (day < 10) { buffer.append("0"); } buffer.append(day); } else { buffer.setLength(8); buffer.replace(0, 8, emptyString); } buffer.setLength(8); return buffer.toString(); }
Source:
<code>private void dispatchInternal(ChannelStateWriteRequest request) throws Exception { if (request instanceof CheckpointStartRequest) { <START> Preconditions.checkState(!writers.containsKey(request.getCheckpointId())); <END> writers.put(request.getCheckpointId(), buildWriter((CheckpointStartRequest) request)); } else if (request instanceof CheckpointInProgressRequest) { ChannelStateCheckpointWriter writer = writers.get(request.getCheckpointId()); CheckpointInProgressRequest req = (CheckpointInProgressRequest) request; if (writer == null) { req.onWriterMissing(); } else { req.execute(writer); } } else { throw new IllegalArgumentException("unknown request type: " + request); } }</code><technical_language>nit: add string message (containing checkpoint id for easier debugging)</technical_language>

Target:
private void dispatchInternal(ChannelStateWriteRequest request) throws Exception { if (request instanceof CheckpointStartRequest) { checkState(!writers.containsKey(request.getCheckpointId()), "writer not found for request " + request); writers.put(request.getCheckpointId(), buildWriter((CheckpointStartRequest) request)); } else if (request instanceof CheckpointInProgressRequest) { ChannelStateCheckpointWriter writer = writers.get(request.getCheckpointId()); CheckpointInProgressRequest req = (CheckpointInProgressRequest) request; if (writer == null) { req.onWriterMissing(); } else { req.execute(writer); } } else { throw new IllegalArgumentException("unknown request type: " + request); } }
Source:
<code>private void edit() { if (getWindow() != null) { return; } AffinityGroup affinityGroup = getSelectedItem(); if (affinityGroup == null) { return; } <START> sortVms(affinityGroup); <END> AffinityGroupModel model = new EditAffinityGroupModel(affinityGroup, this, getClusterResolver()); model.init(); setWindow(model); }</code><technical_language>Generally sort VMs, in case do - sort either, move top of list. firstly, consider dropping this method, making edit() protected add logic in VmAffinityGroupListModel. Secondly, drop comparator iterate items find specific ID move top of list, comparator necessary</technical_language>

Target:
private void edit() { if (getWindow() != null) { return; } AffinityGroup affinityGroup = getSelectedItem(); if (affinityGroup == null) { return; } AffinityGroupModel model = new EditAffinityGroupModel(affinityGroup, this, getClusterResolver()); model.init(); setWindow(model); }
Source:
<code>public GremlinServer(final ServerGremlinExecutor<EventLoopGroup> serverGremlinExecutor) { this.serverGremlinExecutor = serverGremlinExecutor; this.settings = serverGremlinExecutor.getSettings(); <START> this.isLinuxOS = settings.useEpollEventLoop && SystemUtils.IS_OS_LINUX; <END> Runtime.getRuntime().addShutdownHook(new Thread(() -> this.stop().join(), SERVER_THREAD_PREFIX + "shutdown")); final ThreadFactory threadFactoryBoss = ThreadFactoryUtil.create("boss-%d"); if(isLinuxOS) { bossGroup = new EpollEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss); } else{ bossGroup = new NioEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss); } workerGroup = serverGremlinExecutor.getScheduledExecutorService(); gremlinExecutorService = serverGremlinExecutor.getGremlinExecutorService(); }</code><technical_language>I worth a logger.warn() this line if "useEpoll" linux. add a logger.info() event loop ultimately used</technical_language>

Target:
public GremlinServer(final ServerGremlinExecutor<EventLoopGroup> serverGremlinExecutor) { this.serverGremlinExecutor = serverGremlinExecutor; this.settings = serverGremlinExecutor.getSettings(); this.isEpollEnabled = settings.useEpollEventLoop && SystemUtils.IS_OS_LINUX; if(settings.useEpollEventLoop && !SystemUtils.IS_OS_LINUX){ logger.warn("cannot use epoll in non-linux env, falling back to NIO"); } Runtime.getRuntime().addShutdownHook(new Thread(() -> this.stop().join(), SERVER_THREAD_PREFIX + "shutdown")); final ThreadFactory threadFactoryBoss = ThreadFactoryUtil.create("boss-%d"); if(isEpollEnabled) { bossGroup = new EpollEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss); } else{ bossGroup = new NioEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss); } workerGroup = serverGremlinExecutor.getScheduledExecutorService(); gremlinExecutorService = serverGremlinExecutor.getGremlinExecutorService(); }
Source:
<code>public LogicalPlanner(Session session, List<PlanOptimizer> planOptimizers, PlanSanityChecker planSanityChecker, PlanNodeIdAllocator idAllocator, Metadata metadata, SqlParser sqlParser, StatsCalculator statsCalculator, CostCalculator costCalculator) { requireNonNull(session, "session is null"); requireNonNull(planOptimizers, "planOptimizers is null"); requireNonNull(planSanityChecker, "planSanityChecker is null"); requireNonNull(idAllocator, "idAllocator is null"); requireNonNull(metadata, "metadata is null"); requireNonNull(sqlParser, "sqlParser is null"); <START> requireNonNull(statsCalculator, "statsCalculator is null"); <END> requireNonNull(costCalculator, "costCalculator is null"); this.session = session; this.planOptimizers = planOptimizers; this.planSanityChecker = planSanityChecker; this.idAllocator = idAllocator; this.metadata = metadata; this.sqlParser = sqlParser; this.statisticsAggregationPlanner = new StatisticsAggregationPlanner(symbolAllocator, metadata); this.statsCalculator = statsCalculator; this.costCalculator = costCalculator; }</code><technical_language>Inline requireNonNulls in a separate commit</technical_language>

Target:
public LogicalPlanner(Session session, List<PlanOptimizer> planOptimizers, PlanSanityChecker planSanityChecker, PlanNodeIdAllocator idAllocator, Metadata metadata, SqlParser sqlParser, StatsCalculator statsCalculator, CostCalculator costCalculator) { this.session = requireNonNull(session, "session is null"); this.planOptimizers = requireNonNull(planOptimizers, "planOptimizers is null"); this.planSanityChecker = requireNonNull(planSanityChecker, "planSanityChecker is null"); this.idAllocator = requireNonNull(idAllocator, "idAllocator is null"); this.metadata = requireNonNull(metadata, "metadata is null"); this.sqlParser = requireNonNull(sqlParser, "sqlParser is null"); this.statisticsAggregationPlanner = new StatisticsAggregationPlanner(symbolAllocator, metadata); this.statsCalculator = requireNonNull(statsCalculator, "statsCalculator is null"); this.costCalculator = requireNonNull(costCalculator, "costCalculator is null"); }
Source:
<code>protected FS() { <START> gitSystemConfig = new Holder<File>(discoverGitSystemConfig()); <END> }</code><technical_language>evaluate gitSystemConfig lazily in getGitSystemConfig(), a call discoverGitSystemConfig() avoided completely if gitSystemConfig set 'manually' before. discoverGitSystemConfig() is possibly slow hang if bash configuration is screwed up</technical_language>

Target:
protected FS() { }
Source:
<code>public long hash(Object value) { ByteBuffer plain; if (value instanceof Binary) { return hashFunction.hashBytes(((Binary) value).getBytes()); } <START> if (value instanceof Integer) { <END> plain = ByteBuffer.allocate(Integer.SIZE/Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putInt(((Integer)value)); } else if (value instanceof Long) { plain = ByteBuffer.allocate(Long.SIZE/Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putLong(((Long)value)); } else if (value instanceof Float) { plain = ByteBuffer.allocate(Float.SIZE/Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putFloat(((Float)value)); } else if (value instanceof Double) { plain = ByteBuffer.allocate(Double.SIZE/ Byte.SIZE); plain.order(ByteOrder.LITTLE_ENDIAN).putDouble(((Double)value)); } else { throw new RuntimeException("Parquet Bloom filter: Not supported type"); } return hashFunction.hashByteBuffer(plain); }</code><technical_language>I call related method instead. (E.g. call hash(int) for Integer)</technical_language>

Target:
public long hash(Object value) { if (value instanceof Binary) { return hashFunction.hashBytes(((Binary) value).getBytes()); } if (value instanceof Integer) { cacheBuffer.putInt((Integer)value); } else if (value instanceof Long) { cacheBuffer.putLong((Long)value); } else if (value instanceof Float) { cacheBuffer.putFloat((Float)value); } else if (value instanceof Double) { cacheBuffer.putDouble((Double) value); } else { throw new RuntimeException("Parquet Bloom filter: Not supported type"); } return doHash(); }
Source:
<code>public void process(Exchange exchange) throws Exception { XChangeEndpoint endpoint = getEndpoint(); String method = endpoint.getConfiguration().getMethod(); if (METHOD_CURRENCY_METADATA.equals(method)) { Currency curr = exchange.getIn().getHeader(HEADER_CURRENCY, Currency.class); Object body = endpoint.getCurrencyMetaData(curr); <START> exchange.getOut().setBody(body); <END> } else if (METHOD_CURRENCY_PAIR_METADATA.equals(method)) { CurrencyPair pair = exchange.getIn().getHeader(HEADER_CURRENCY_PAIR, CurrencyPair.class); Object body = endpoint.getCurrencyPairMetaData(pair); exchange.getOut().setBody(body); } }</code><technical_language>previous IN OUT</technical_language>

Target:
public void process(Exchange exchange) throws Exception { XChangeEndpoint endpoint = getEndpoint(); XChangeMethod method = endpoint.getConfiguration().getMethod(); if (XChangeMethod.currencies == method) { Object body = endpoint.getCurrencies(); exchange.getMessage().setBody(body); } else if (XChangeMethod.currencyPairs == method) { Object body = endpoint.getCurrencyPairs(); exchange.getMessage().setBody(body); } else if (XChangeMethod.currencyMetaData == method) { Currency curr = exchange.getMessage().getHeader(HEADER_CURRENCY, Currency.class); curr = curr != null ? curr : exchange.getMessage().getBody(Currency.class); Object body = endpoint.getCurrencyMetaData(curr); exchange.getMessage().setBody(body); } else if (XChangeMethod.currencyPairMetaData == method) { CurrencyPair pair = exchange.getIn().getHeader(HEADER_CURRENCY_PAIR, CurrencyPair.class); pair = pair != null ? pair : exchange.getMessage().getBody(CurrencyPair.class); Object body = endpoint.getCurrencyPairMetaData(pair); exchange.getMessage().setBody(body); } }
Source:
<code>public static void main(String args[]) { URI uri = null; if (args.length > 0) { try { uri = new URI(args[0]); } catch (URISyntaxException e) { System.err.println("Invalid URI: " + e.getMessage()); System.exit(-1); } CoapClient client = new CoapClient(uri); CoapResponse response = client.get(); if (response!=null) { System.out.println(response.getCode()); System.out.println(response.getOptions()); if (args.length > 1) { try (FileOutputStream out = new FileOutputStream(args[1])) { <START> out.write(response.getPayload()); <END> } catch (IOException e) { e.printStackTrace(); } } else { System.out.println(response.getResponseText()); System.out.println("\nADVANCED\n"); System.out.println(Utils.prettyPrint(response)); } } else { System.out.println("No response received."); } } else { System.out.println("Californium (Cf) GET Client"); System.out.println("(c) 2014, Institute for Pervasive Computing, ETH Zurich"); System.out.println(); System.out.println("Usage : " + GETClient.class.getSimpleName() + " URI [file]"); System.out.println(" URI : The CoAP URI of the remote resource to GET"); System.out.println(" file: optional filename to save the received payload"); } }</code><technical_language>closing file</technical_language>

Target:
public static void main(String args[]) { URI uri = null; if (args.length > 0) { try { uri = new URI(args[0]); } catch (URISyntaxException e) { System.err.println("Invalid URI: " + e.getMessage()); System.exit(-1); } CoapClient client = new CoapClient(uri); CoapResponse response = client.get(); if (response!=null) { System.out.println(response.getCode()); System.out.println(response.getOptions()); if (args.length > 1) { try (FileOutputStream out = new FileOutputStream(args[1])) { out.write(response.getPayload()); } catch (IOException e) { e.printStackTrace(); } } else { System.out.println(response.getResponseText()); System.out.println(System.lineSeparator() + "ADVANCED" + System.lineSeparator()); System.out.println(Utils.prettyPrint(response)); } } else { System.out.println("No response received."); } } else { System.out.println("Californium (Cf) GET Client"); System.out.println("(c) 2014, Institute for Pervasive Computing, ETH Zurich"); System.out.println(); System.out.println("Usage : " + GETClient.class.getSimpleName() + " URI [file]"); System.out.println(" URI : The CoAP URI of the remote resource to GET"); System.out.println(" file: optional filename to save the received payload"); } }
Source:
<code>public void visitFile(AstNode node) { <START> Set<Symbol> symbols = getContext().symbolTable().symbols(node); <END> isUsingDjangoModel = symbols.stream().anyMatch(s -> s.qualifiedName().contains("django.db.models")); isUsingDjangoDBConnection = symbols.stream().anyMatch(s -> s.qualifiedName().contains("django.db.connection")); isUsingDjangoDBConnections = symbols.stream().anyMatch(s -> s.qualifiedName().contains("django.db.connections")); }</code><technical_language>compute qualified names in order stream 3 times for data: java Set<String> symbolsQualifiedNames = getContext().symbolTable().symbols(node).stream() .map(Symbol::qualifiedName) .collect(Collectors.toSet()); isUsingDjangoModel = symbolsQualifiedNames.contains("django.db.connection"); isUsingDjangoDBConnection = symbolsQualifiedNames.contains("django.db.connection"); isUsingDjangoDBConnections = symbolsQualifiedNames.contains("django.db.connections");</technical_language>

Target:
public void visitFile(AstNode node) { isUsingDjangoModel = false; isUsingDjangoDBConnection = false; for (Symbol symbol : getContext().symbolTable().symbols(node)) { String qualifiedName = symbol.qualifiedName(); if (qualifiedName.contains("django.db.models")) { isUsingDjangoModel = true; } if (qualifiedName.contains("django.db.connection")) { isUsingDjangoDBConnection = true; } } }
Source:
<code>public final Subscription subscribe(final Action1<? super Throwable> onError, final Action0 onComplete) { requireNonNull(onError); requireNonNull(onComplete); final MultipleAssignmentSubscription mad = new MultipleAssignmentSubscription(); subscribe(new CompletableSubscriber() { @Override public void onCompleted() { <START> mad.unsubscribe(); <END> try { onComplete.call(); } catch (Throwable e) { onError(e); } } @Override public void onError(Throwable e) { mad.unsubscribe(); try { onError.call(e); } catch (Throwable ex) { e = new CompositeException(Arrays.asList(e, ex)); ERROR_HANDLER.handleError(e); } } @Override public void onSubscribe(Subscription d) { mad.set(d); } }); return mad; }</code><technical_language>This called onComplete.call()</technical_language>

Target:
public final Subscription subscribe(final Action1<? super Throwable> onError, final Action0 onComplete) { requireNonNull(onError); requireNonNull(onComplete); final MultipleAssignmentSubscription mad = new MultipleAssignmentSubscription(); subscribe(new CompletableSubscriber() { @Override public void onCompleted() { try { onComplete.call(); } catch (Throwable e) { onError(e); return; } mad.unsubscribe(); } @Override public void onError(Throwable e) { try { onError.call(e); } catch (Throwable ex) { e = new CompositeException(Arrays.asList(e, ex)); ERROR_HANDLER.handleError(e); } mad.unsubscribe(); } @Override public void onSubscribe(Subscription d) { mad.set(d); } }); return mad; }
Source:
<code><START> public void testProcessQueryJsonApi() throws NoHttpResponseException, URISyntaxException { <END> String query = "/group?sort=commonName&fields%5Bgroup%5D=commonName,description"; ElideResponse response = mock(ElideResponse.class); when(queryObj.getQuery()).thenReturn(query); when(queryObj.getQueryType()).thenReturn(QueryType.JSONAPI_V1_0); when(elide.get(anyString(), any(), any(), anyString())).thenReturn(response); when(response.getResponseCode()).thenReturn(200); when(response.getBody()).thenReturn("ResponseBody"); }</code><technical_language>this test tests anything</technical_language>

Target:
public void testProcessQueryJsonApi() throws NoHttpResponseException, URISyntaxException { AsyncQuery queryObj = new AsyncQuery(); ElideResponse response = new ElideResponse(200, "ResponseBody"); String query = "/group?sort=commonName&fields%5Bgroup%5D=commonName,description"; String id = "edc4a871-dff2-4054-804e-d80075cf827d"; queryObj.setId(id); queryObj.setQuery(query); queryObj.setQueryType(QueryType.JSONAPI_V1_0); when(elide.get(anyString(), any(), any(), anyString())).thenReturn(response); AsyncQueryThread queryThread = new AsyncQueryThread(queryObj, user, elide, runner, asyncQueryDao, "v1"); queryResultObj = queryThread.processQuery(); assertEquals(queryResultObj.getResponseBody(), "ResponseBody"); assertEquals(queryResultObj.getHttpStatus(), 200); }
Source:
<code>public void setAssignees(Collection<GHUser> assignees) throws IOException { root.retrieve() <START> .method("POST") <END> .with(ASSIGNEES, getLogins(assignees)) .method("PATCH") .withUrlPath(getIssuesApiRoute()) .to(); }</code><technical_language>Multiple method(*) methods</technical_language>

Target:
public void setAssignees(Collection<GHUser> assignees) throws IOException { root.createRequest() .method("PATCH") .with(ASSIGNEES, getLogins(assignees)) .withUrlPath(getIssuesApiRoute()) .send(); }
Source:
<code>public IReviewRemoteFactoryProvider createFactoryProvider(TaskRepository repository) { GerritClient client = getClient(repository); <START> return new GerritRemoteFactoryProvider(client); <END> }</code><technical_language>minor, lines combined</technical_language>

Target:
public IReviewRemoteFactoryProvider createFactoryProvider(TaskRepository repository) { return new GerritRemoteFactoryProvider(getClient(repository)); }
Source:
<code>public void testDecoder(String testName, DataComplex dataComplex, boolean enableFixedLengthFloatDoubles) throws Exception { ProtobufDataCodec codec = new ProtobufDataCodec( new ProtobufCodecOptions.Builder().setEnableFixedLengthFloatDoubles(enableFixedLengthFloatDoubles) .setEnableASCIIOnlyStrings(false).build()); byte[] bytes = TestUtil.dataComplexToBytes(codec, dataComplex); DataComplex decodedDataComplex = decode(bytes); assertEquals(TestUtil.dataComplexToBytes(codec, decodedDataComplex), bytes); codec = new ProtobufDataCodec( new ProtobufCodecOptions.Builder().setEnableFixedLengthFloatDoubles(enableFixedLengthFloatDoubles) <START> .setEnableASCIIOnlyStrings(true).build()); <END> bytes = TestUtil.dataComplexToBytes(codec, dataComplex); decodedDataComplex = decode(bytes); assertEquals(TestUtil.dataComplexToBytes(codec, decodedDataComplex), bytes); }</code><technical_language>setEnableASCIIOnlyStrings a dataprovider param</technical_language>

Target:
public void testDecoder(String testName, DataComplex dataComplex, boolean enableFixedLengthFloatDoubles) throws Exception { ProtobufDataCodec codec = new ProtobufDataCodec( new ProtobufCodecOptions.Builder().setEnableFixedLengthFloatDoubles(enableFixedLengthFloatDoubles) .setEnableASCIIOnlyStrings(true).build()); byte[] bytes = TestUtil.dataComplexToBytes(codec, dataComplex); DataComplex decodedDataComplex = decode(bytes, 20); assertEquals(TestUtil.dataComplexToBytes(codec, decodedDataComplex), bytes); }
Source:
<code>private boolean pickJumpPoint(DateTime now) { if(currentSystem.isZenithCharge(now) && !currentSystem.isNadirCharge(now)) { return true; } if(!currentSystem.isZenithCharge(now) && currentSystem.isNadirCharge(now)) { return false; } <START> return Compute.randomInt(1)==1; <END> }</code><technical_language>I forget if Compute.randomInt a number 0 x inclusively excludes upper bound</technical_language>

Target:
private boolean pickJumpPoint(DateTime now) { if(currentSystem.isZenithCharge(now) && !currentSystem.isNadirCharge(now)) { return true; } if(!currentSystem.isZenithCharge(now) && currentSystem.isNadirCharge(now)) { return false; } return Compute.randomInt(2)==1; }
Source:
<code>public void unvoidPatient_shouldReturnNullWhenPatientIsNull() throws Exception { <START> PatientService patientService = Context.getPatientService(); <END> Patient unVoidedPatient = patientService.unvoidPatient(null); Assert.assertNull(unVoidedPatient); }</code><technical_language>is a patientService for you. need get context</technical_language>

Target:
public void unvoidPatient_shouldReturnNullWhenPatientIsNull() throws Exception { assertNull(patientService.unvoidPatient(null)); }
Source:
<code>public boolean getAndRelease() { <START> ByteBufAllocator alloc = PooledByteBufAllocator.DEFAULT; <END> ByteBuf buf = alloc.directBuffer(size); if (tokens > 0) { Blackhole.consumeCPU(tokens); } return buf.release(); }</code><technical_language>@netudima create a new PooledByteBufAllocator instance in a @Setup method ? produce fair results stuff cached etc. want disable ThreadLocal caches ensure hit PoolArena. WDYT</technical_language>

Target:
public boolean getAndRelease() { ByteBuf buf = allocator.directBuffer(size); if (tokens > 0) { Blackhole.consumeCPU(tokens); } return buf.release(); }
Source:
<code><START> public void addObjectsToCollection(Cursor cursor, Collection<M> collection) { <END> try { if (cursor.getCount() > 0) { cursor.moveToFirst(); do { collection.add(modelFactory.fromCursor(cursor)); } while (cursor.moveToNext()); } } finally { cursor.close(); } }</code><technical_language>protected</technical_language>

Target:
protected void addObjectsToCollection(Cursor cursor, Collection<M> collection) { try { if (cursor.getCount() > 0) { cursor.moveToFirst(); do { collection.add(modelFactory.fromCursor(cursor)); } while (cursor.moveToNext()); } } finally { cursor.close(); } }