auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>protected void showSelection() { if (getEdgeEditPart() == null) { return; } super.showSelection(); final ViewEdgeFigure fig = getViewEdgeFigure(); if (fig != null && Display.getCurrent() != null) { fig.setForegroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION)); fig.setLineWidth(DiagramEdgeEditPartOperation.getLineWidth(getEdgeEditPart()) + WIDTH_FEEDBACK); for (final Object child : fig.getChildren()) { if (child instanceof PolylineDecoration) { final PolylineDecoration decoration = (PolylineDecoration) child; decoration.setLineWidth(DiagramEdgeEditPartOperation.getLineWidth(getEdgeEditPart()) + WIDTH_FEEDBACK); } } } if (getHost() instanceof AbstractDiagramNameEditPart) { if (((AbstractDiagramNameEditPart) getHost()).getFigure() instanceof SiriusWrapLabelWithAttachment) { ((SiriusWrapLabelWithAttachment) ((AbstractDiagramNameEditPart) getHost()).getFigure()).showAttachment(); } } else { for (final AbstractDiagramNameEditPart edgeNameEditPart : getEdgeNameEditPart()) { if (edgeNameEditPart != null && <START> edgeNameEditPart.getEditText() != null && !"".equals(edgeNameEditPart.getEditText())) <END> { if (edgeNameEditPart.getFigure() instanceof SiriusWrapLabelWithAttachment) { ((SiriusWrapLabelWithAttachment) edgeNameEditPart.getFigure()).showAttachment(); } } } } }</code><technical_language>replace org.eclipse.sirius.common.tools.api.util.StringUtil.isEmpty(String)</technical_language>

Target:
protected void showSelection() { if (getEdgeEditPart() == null) { return; } super.showSelection(); final ViewEdgeFigure fig = getViewEdgeFigure(); if (fig != null && Display.getCurrent() != null) { fig.setForegroundColor(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION)); fig.setLineWidth(DiagramEdgeEditPartOperation.getLineWidth(getEdgeEditPart()) + WIDTH_FEEDBACK); for (final Object child : fig.getChildren()) { if (child instanceof PolylineDecoration) { final PolylineDecoration decoration = (PolylineDecoration) child; decoration.setLineWidth(DiagramEdgeEditPartOperation.getLineWidth(getEdgeEditPart()) + WIDTH_FEEDBACK); } } } if (getHost() instanceof AbstractDiagramNameEditPart) { if (((AbstractDiagramNameEditPart) getHost()).getFigure() instanceof SiriusWrapLabelWithAttachment) { ((SiriusWrapLabelWithAttachment) ((AbstractDiagramNameEditPart) getHost()).getFigure()).showAttachment(); } } else { for (final AbstractDiagramNameEditPart edgeNameEditPart : getEdgeNameEditPart()) { if (edgeNameEditPart != null && !StringUtil.isEmpty(edgeNameEditPart.getEditText())) { if (edgeNameEditPart.getFigure() instanceof SiriusWrapLabelWithAttachment) { ((SiriusWrapLabelWithAttachment) edgeNameEditPart.getFigure()).showAttachment(); } } } } }
Source:
<code>public static NodeId getNodeId(Map<String, Object> properties, int nodeNamespaceIndex, NodeIdType nodeIdType) { String nodeIdString = (String) properties.get(NODE_ID); <START> if (nodeIdType == NodeIdType.NUMERIC) { <END> return new NodeId(nodeNamespaceIndex, Integer.parseInt(nodeIdString)); } else if (nodeIdType == NodeIdType.STRING) { return new NodeId(nodeNamespaceIndex, nodeIdString); } else if (nodeIdType == NodeIdType.GUID) { return new NodeId(nodeNamespaceIndex, UUID.fromString(nodeIdString)); } else { return new NodeId(nodeNamespaceIndex, ByteString.of(Base64.getDecoder().decode(nodeIdString))); } }</code><technical_language>For verbosity, switch NodeIdType</technical_language>

Target:
public static NodeId getNodeId(Map<String, Object> properties, int nodeNamespaceIndex, NodeIdType nodeIdType) { String nodeIdString = (String) properties.get(NODE_ID); switch (nodeIdType) { case NUMERIC: return new NodeId(nodeNamespaceIndex, Integer.parseInt(nodeIdString)); case STRING: return new NodeId(nodeNamespaceIndex, nodeIdString); case GUID: return new NodeId(nodeNamespaceIndex, UUID.fromString(nodeIdString)); case OPAQUE: return new NodeId(nodeNamespaceIndex, ByteString.of(Base64.getDecoder().decode(nodeIdString))); default: throw new IllegalArgumentException(); } }
Source:
<code>public Buffer(String directory) { FileSystem.mkdirs(directory); this.directory = directory; this.inventory = Inventory.create(directory + File.separator + "meta" + File.separator + "inventory"); this.threadNamePrefix = "buffer-" + System.identityHashCode(this); <START> this.percentageOfVerifiesScanningBuffer = ((double) this.numberOfVerifiesTouchingPage)/this.numberOfVerifiesInitiated; <END> }</code><technical_language>this is set once, updated numerator denominator change</technical_language>

Target:
public Buffer(String directory) { FileSystem.mkdirs(directory); this.directory = directory; this.inventory = Inventory.create(directory + File.separator + "meta" + File.separator + "inventory"); this.threadNamePrefix = "buffer-" + System.identityHashCode(this); numVerifyRequests = new AtomicLong(); numVerifyScans = new AtomicLong(); }
Source:
<code>public void hitRateCanBeReturned() throws IllegalAccessException, InstantiationException { Store.ValueHolder<V> valueHolder = factory.newValueHolder(factory.createValue(1)); <START> assertThat(valueHolder.hitRate(TimeUnit.MILLISECONDS.convert(Time.time(), TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS), is(notNullValue())); <END> }</code><technical_language>Time.time() usage instead of a simpler System.currentTimeMillis()? Especially returns System.nanoTime()</technical_language>

Target:
public void hitRateCanBeReturned() throws IllegalAccessException, InstantiationException { Store.ValueHolder<V> valueHolder = factory.newValueHolder(factory.createValue(1)); assertThat(valueHolder.hitRate(TimeUnit.MILLISECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS), anyOf(is(Float.NaN), is(0.0f))); }
Source:
<code>private String getPropertyName(ASTMethod astMethod) { String methodName = astMethod.getName(); if(astMethod.isAnnotated(ParcelProperty.class)){ return astMethod.getAnnotation(ParcelProperty.class).value(); } for (String prepend : PREPENDS) { if (methodName.startsWith(prepend) && methodName.length() - prepend.length() > 0) { String name = methodName.substring(prepend.length()); return name.substring(0, 1).toLowerCase(Locale.getDefault()) + <START> (name.length() > 1 ? name.substring(1) : ""); <END> } } throw new TransfuseAnalysisException("Unable to convert Method name " + methodName); }</code><technical_language>disqualify methods get(), set(), is() representting getters setters in isGetter isSetter methods</technical_language>

Target:
private String getPropertyName(ASTMethod astMethod) { String methodName = astMethod.getName(); if(astMethod.isAnnotated(ParcelProperty.class)){ return astMethod.getAnnotation(ParcelProperty.class).value(); } for (String prepend : PREPENDS) { if (methodName.startsWith(prepend)) { String name = methodName.substring(prepend.length()); return name.substring(0, 1).toLowerCase(Locale.getDefault()) + name.substring(1); } } throw new TransfuseAnalysisException("Unable to convert Method name " + methodName); }
Source:
<code><START> void shouldReturnPong(String acceptHeader) { <END> ValidatableMockMvcResponse response = given() .header(HttpHeaders.ACCEPT, acceptHeader) .when() .get(getContextBaseUrl()) .peek() .then() .statusCode(HttpStatus.OK.value()); String message = "pong"; getResponseBody(response, acceptHeader, message); }</code><technical_language>Cosmetic: please, follow project's coding convention</technical_language>

Target:
void shouldReturnPong(String acceptHeader) { ValidatableMockMvcResponse response = given().accept(acceptHeader) .when() .get(getContextBaseUrl()) .peek() .then() .statusCode(HttpStatus.OK.value()); String message = "pong"; validateResponseBody(response, acceptHeader, message); }
Source:
<code>public UniquenessEnforcerNode(ReteContainer reteContainer, int tupleWidth) { super(reteContainer); this.parents = new ArrayList<Supplier>(); this.memory = new TupleMemory(); this.rederivableMemory = new TupleMemory(); this.tupleWidth = tupleWidth; <START> reteContainer.registerClearable(this.memory); <END> this.nullMask = TupleMask.linear(0, tupleWidth); this.identityMask = TupleMask.identity(tupleWidth); this.deleteRederive = true; }</code><technical_language>rederivableMemory registered clearable well</technical_language>

Target:
public UniquenessEnforcerNode(ReteContainer reteContainer, int tupleWidth) { super(reteContainer); this.parents = new ArrayList<Supplier>(); this.memory = new TupleMemory(); this.rederivableMemory = new TupleMemory(); this.tupleWidth = tupleWidth; reteContainer.registerClearable(this.memory); reteContainer.registerClearable(this.rederivableMemory); this.nullMask = TupleMask.linear(0, tupleWidth); this.identityMask = TupleMask.identity(tupleWidth); this.deleteRederive = true; }
Source:
<code>public Integer encode(MonthDay value) { if ( value == null ) { return null; } <START> return 37 * value.getMonthValue() + value.getDayOfMonth(); <END> }</code><technical_language>37 from. I suppose prime number 31. multiplying 100 trick here, worth this hard</technical_language>

Target:
public Integer encode(MonthDay value) { if ( value == null ) { return null; } return 100 * value.getMonthValue() + value.getDayOfMonth(); }
Source:
<code>public Optional<BaseObject> getXObject(XWikiDocument doc, DocumentReference classRef, int objectNumber) { BaseObject bObj = null; List<BaseObject> objs = getXObjects(doc, classRef); for (BaseObject baseObject : objs) { if (baseObject.getNumber() == objectNumber) { <START> bObj = baseObject; <END> } } return Optional.fromNullable(bObj); }</code><technical_language>add break statement</technical_language>

Target:
public Optional<BaseObject> getXObject(XWikiDocument doc, DocumentReference classRef, int objectNumber) { BaseObject bObj = null; List<BaseObject> objs = getXObjects(doc, classRef); for (BaseObject baseObject : objs) { if (baseObject.getNumber() == objectNumber) { bObj = baseObject; break; } } return Optional.fromNullable(bObj); }
Source:
<code>private static NewXmlVerifier createVerifier(String fileName, NewXmlCheck check) { <START> File file = new File(BASE_DIR.toFile(), check.getClass().getSimpleName() + "/" + fileName); <END> RuleKey checkRuleKey = RuleKey.of(Xml.REPOSITORY_KEY, check.ruleKey()); SensorContextTester context = SensorContextTester.create(BASE_DIR) .setActiveRules(new ActiveRulesBuilder().create(checkRuleKey).activate().build()); String filePath = file.getPath(); String content; try { content = Files.lines(file.toPath()).collect(Collectors.joining("\n")); } catch (IOException e) { throw new IllegalStateException(String.format("Unable to load content of file %s", filePath), e); } DefaultInputFile defaultInputFile = TestInputFileBuilder.create("", filePath) .setType(InputFile.Type.MAIN) .initMetadata(content) .setLanguage(Xml.KEY) .setCharset(StandardCharsets.UTF_8) .build(); context.fileSystem().add(defaultInputFile); NewXmlFile newXmlFile; try { newXmlFile = NewXmlFile.create(defaultInputFile); } catch (IOException | ParserConfigurationException e) { throw new IllegalStateException(String.format("Unable to scan xml file %s", filePath), e); } check.scanFile(context, newXmlFile); return new NewXmlVerifier(context.allIssues()); }</code><technical_language>I if want move this class commons, check.getClass().getSimpleName() here, in test</technical_language>

Target:
private static NewXmlVerifier createVerifier(String fileName, NewXmlCheck check) { File file = new File(new File(BASE_DIR.toFile(), check.getClass().getSimpleName()), fileName); RuleKey checkRuleKey = RuleKey.of(Xml.REPOSITORY_KEY, check.ruleKey()); SensorContextTester context = SensorContextTester.create(BASE_DIR) .setActiveRules(new ActiveRulesBuilder().create(checkRuleKey).activate().build()); String filePath = file.getPath(); String content; try { content = Files.lines(file.toPath()).collect(Collectors.joining("\n")); } catch (IOException e) { throw new IllegalStateException(String.format("Unable to load content of file %s", filePath), e); } DefaultInputFile defaultInputFile = TestInputFileBuilder.create("", filePath) .setType(InputFile.Type.MAIN) .initMetadata(content) .setLanguage(Xml.KEY) .setCharset(StandardCharsets.UTF_8) .build(); context.fileSystem().add(defaultInputFile); NewXmlFile newXmlFile; try { newXmlFile = NewXmlFile.create(defaultInputFile); } catch (IOException e) { throw new IllegalStateException(String.format("Unable to scan xml file %s", filePath), e); } check.scanFile(context, newXmlFile); return new NewXmlVerifier(context.allIssues()); }
Source:
<code><START> static short computeSerialVersionUid(Class cls, List<Field> fields) throws IOException { <END> if (Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls)) { try { Field field = cls.getDeclaredField("serialVersionUID"); if (field.getType() == long.class) { int mod = field.getModifiers(); if (Modifier.isStatic(mod) && Modifier.isFinal(mod)) { field.setAccessible(true); return (short)field.getLong(null); } } } catch (NoSuchFieldException ignored) { } catch (IllegalAccessException e) { throw new IOException(e); } if (false ) return (short)ObjectStreamClass.lookup(cls).getSerialVersionUID(); } MessageDigest md; try { md = MessageDigest.getInstance("SHA"); } catch (NoSuchAlgorithmException e) { throw new IOException("Failed to get digest for SHA.", e); } md.update(cls.getName().getBytes(UTF_8)); if (!F.isEmpty(fields)) { for (int i = 0; i < fields.size(); i++) { Field f = fields.get(i); md.update(f.getName().getBytes(UTF_8)); md.update(f.getType().getName().getBytes(UTF_8)); } } byte[] hashBytes = md.digest(); long hash = 0; for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) hash = (hash << 8) | (hashBytes[i] & 0xFF); return (short)hash; }</code><technical_language>ObjectStreamClass#getSerialVersionUID() instead. set class ObjectStreamClass#cl</technical_language>

Target:
static short computeSerialVersionUid(Class cls, List<Field> fields) throws IOException { if (Serializable.class.isAssignableFrom(cls) && !Enum.class.isAssignableFrom(cls)) { try { Field field = cls.getDeclaredField("serialVersionUID"); if (field.getType() == long.class) { int mod = field.getModifiers(); if (Modifier.isStatic(mod) && Modifier.isFinal(mod)) { field.setAccessible(true); return (short)field.getLong(null); } } } catch (NoSuchFieldException ignored) { } catch (IllegalAccessException e) { throw new IOException(e); } if (USE_DFLT_SUID) return (short)ObjectStreamClass.lookup(cls).getSerialVersionUID(); } MessageDigest md; try { md = MessageDigest.getInstance("SHA"); } catch (NoSuchAlgorithmException e) { throw new IOException("Failed to get digest for SHA.", e); } md.update(cls.getName().getBytes(UTF_8)); if (!F.isEmpty(fields)) { for (int i = 0; i < fields.size(); i++) { Field f = fields.get(i); md.update(f.getName().getBytes(UTF_8)); md.update(f.getType().getName().getBytes(UTF_8)); } } byte[] hashBytes = md.digest(); long hash = 0; for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) hash = (hash << 8) | (hashBytes[i] & 0xFF); return (short)hash; }
Source:
<code>public void _provlr(CommandInterpreter interpreter) { String urlString = processArgument(interpreter.nextArgument()); String id = processArgument(interpreter.nextArgument()); String version = processArgument(interpreter.nextArgument()); if (urlString == null) { URI[] repositories = ProvisioningHelper.getMetadataRepositories(agent); if (repositories != null) for (URI <START> repositorie : <END> repositories) { interpreter.println(repositorie); } return; } URI repoLocation = toURI(interpreter, urlString); if (repoLocation == null) return; IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoLocation, QueryUtil.createIUQuery(id, VersionRange.create(version)), null)); for (IInstallableUnit unit : units) { println(interpreter, unit); } }</code><technical_language>repository is proper name</technical_language>

Target:
public void _provlr(CommandInterpreter interpreter) { String urlString = processArgument(interpreter.nextArgument()); String id = processArgument(interpreter.nextArgument()); String version = processArgument(interpreter.nextArgument()); if (urlString == null) { URI[] repositories = ProvisioningHelper.getMetadataRepositories(agent); if (repositories != null) for (URI repository : repositories) { interpreter.println(repository); } return; } URI repoLocation = toURI(interpreter, urlString); if (repoLocation == null) return; IInstallableUnit[] units = sort(ProvisioningHelper.getInstallableUnits(agent, repoLocation, QueryUtil.createIUQuery(id, VersionRange.create(version)), null)); for (IInstallableUnit unit : units) { println(interpreter, unit); } }
Source:
<code>public Optional<List> jsonValueToMetacardValue( WorkspaceTransformer transformer, List metacardJsonData) { ((List<Object>) metacardJsonData) .stream() .filter(Map.class::isInstance) .map(Map.class::cast) <START> .forEach(listMetacardMap -> EXTERNAL_LIST_ATTRIBUTES.forEach(listMetacardMap::remove)); <END> return super.jsonValueToMetacardValue(transformer, metacardJsonData); }</code><technical_language>Extracting lambda a private function increase readability</technical_language>

Target:
public Optional<List> jsonValueToMetacardValue( WorkspaceTransformer transformer, List metacardJsonData) { ((List<Object>) metacardJsonData) .stream() .filter(Map.class::isInstance) .map(Map.class::cast) .forEach(this::removeExternalListAttributes); return super.jsonValueToMetacardValue(transformer, metacardJsonData); }
Source:
<code>public URI apply(final HttpResponse from) { <START> final String statusCode = Integer.toString(from.getStatusCode()); <END> if (statusCode != null && statusCode.equals("202") && from.getHeaders().containsKey("Location")){ String uri = from.getFirstHeaderOrNull("Location"); return URI.create(uri); } else if (statusCode != null && statusCode.equals("200")){ return null; } throw new IllegalStateException("did not receive expected response code and header in: " + from); }</code><technical_language>Response status is a primitive int, null. is need convert a String</technical_language>

Target:
public URI apply(final HttpResponse from) { if (from.getStatusCode() == 202 && from.getHeaders().containsKey("Location")){ String uri = from.getFirstHeaderOrNull("Location"); return URI.create(uri); } else if (from.getStatusCode() == 200){ return null; } throw new IllegalStateException("did not receive expected response code and header in: " + from); }
Source:
<code>protected String[] customCommandLineValidation() { final LinkedList<String> errors = new LinkedList<String>(); if (READ_NAME_FORMAT == ReadNameFormat.CASAVA_1_8 && MACHINE_NAME == null) { errors.add("MACHINE_NAME is required when using Casava1.8-style read name headers."); } if (READ_NAME_FORMAT == ReadNameFormat.CASAVA_1_8 && FLOWCELL_BARCODE == null) { errors.add("FLOWCELL_BARCODE is required when using Casava1.8-style read name headers."); } if (ADAPTERS_TO_CHECK != null) { <START> log.warn("ADAPTERS_TO_CHECK is no not used"); <END> } if (errors.isEmpty()) { return null; } else { return errors.toArray(new String[errors.size()]); } }</code><technical_language>s/no not/not/</technical_language>

Target:
protected String[] customCommandLineValidation() { final LinkedList<String> errors = new LinkedList<String>(); if (READ_NAME_FORMAT == ReadNameFormat.CASAVA_1_8 && MACHINE_NAME == null) { errors.add("MACHINE_NAME is required when using Casava1.8-style read name headers."); } if (READ_NAME_FORMAT == ReadNameFormat.CASAVA_1_8 && FLOWCELL_BARCODE == null) { errors.add("FLOWCELL_BARCODE is required when using Casava1.8-style read name headers."); } if (ADAPTERS_TO_CHECK != null) { log.warn("ADAPTERS_TO_CHECK is not used"); } if (errors.isEmpty()) { return null; } else { return errors.toArray(new String[errors.size()]); } }
Source:
<code>@Override public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException { <START> BinaryType meta = cache.metadata(typeId); <END> if (meta == null || !((BinaryTypeImpl)meta).metadata().hasSchema(schemaId)) meta = requestAndCacheBinaryType(typeId); return meta != null && ((BinaryTypeImpl)meta).metadata().hasSchema(schemaId) ? meta : null; }</code><technical_language>is cast meta BinaryTypeImpl right here</technical_language>

Target:
@Override public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException { BinaryType meta = cache.metadata(typeId); if (hasSchema(meta, schemaId)) return meta; meta = requestAndCacheBinaryType(typeId); return hasSchema(meta, schemaId) ? meta : null; }
Source:
<code>public Map<?, ?> lookupArticlesByDois(List<String> dois) throws IOException { String doiQueryString = Joiner.on(" OR ").join(dois); ArticleSearchQuery.Builder query = ArticleSearchQuery.builder() .setQuery(doiQueryString) .setStart(0) .setRows(dois.size()) <START> .setDateRange(SolrSearchApiImpl.SolrEnumeratedDateRange.ALL_TIME); <END> return search(query.build()); }</code><technical_language>do need set dateRange</technical_language>

Target:
public Map<?, ?> lookupArticlesByDois(List<String> dois) throws IOException { String doiQueryString = Joiner.on(" OR ").join(dois); ArticleSearchQuery.Builder query = ArticleSearchQuery.builder() .setQuery(doiQueryString) .setStart(0) .setRows(dois.size()); return search(query.build()); }
Source:
<code>public final U assertValueSequence(Iterable<? extends T> sequence) { int i = 0; Iterator<T> actualIterator = values.iterator(); Iterator<? extends T> expectedIterator = sequence.iterator(); boolean actualNext; boolean expectedNext; for (;;) { expectedNext = expectedIterator.hasNext(); actualNext = actualIterator.hasNext(); if (!actualNext || !expectedNext) { break; } T v = expectedIterator.next(); T u = actualIterator.next(); if (!ObjectHelper.equals(u, v)) { <START> throw fail("Values at position " + i + " differ; Expected: " + valueAndClass(v) + ", Actual: " + valueAndClass(u)); <END> } i++; } if (actualNext) { throw fail("More values received than expected (" + i + ")"); } if (expectedNext) { throw fail("Fewer values received than expected (" + i + ")"); } return (U)this; }</code><technical_language>This change needs a test</technical_language>

Target:
public final U assertValueSequence(Iterable<? extends T> sequence) { int i = 0; Iterator<T> actualIterator = values.iterator(); Iterator<? extends T> expectedIterator = sequence.iterator(); boolean actualNext; boolean expectedNext; for (;;) { expectedNext = expectedIterator.hasNext(); actualNext = actualIterator.hasNext(); if (!actualNext || !expectedNext) { break; } T u = expectedIterator.next(); T v = actualIterator.next(); if (!ObjectHelper.equals(u, v)) { throw fail("Values at position " + i + " differ; Expected: " + valueAndClass(u) + ", Actual: " + valueAndClass(v)); } i++; } if (actualNext) { throw fail("More values received than expected (" + i + ")"); } if (expectedNext) { throw fail("Fewer values received than expected (" + i + ")"); } return (U)this; }
Source:
<code>protected void onShowPage(boolean firstShow) { try { loadConfiguration(); if (!isEnable) { disposeControl(); Label label = new Label(page, SWT.WRAP); <START> label.setText("Schema retrieval is not enabled for selected driver."); <END> label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); page.layout(true, true); setMessage(""); setPageComplete(true); return; } if (firstShow) { createComponent(); } else { disposeControl(); schemas.clear(); createComponent(); } getSchemas(); schemaTable.setInput(schemas); if (multipleSelection) { schemaTable.setAllChecked(true); setPageComplete(true); setMessage("Please select one or multiple schemas."); } else { setMessage("Please select one schema."); } } catch (SQLException e) { log.error(e.getMessage(), e); } }</code><technical_language>user is interested is selecting schemas retrieving schemas - I this message confusing. a message "Restricting loaded tables specific database schemas is enabled for this driver. database tables loaded."</technical_language>

Target:
protected void onShowPage(boolean firstShow) { try { loadConfiguration(); if (!isEnable) { disposeControl(); Label label = new Label(page, SWT.WRAP); label.setText( "Restricting the tables to load from specific database schemas, is not " + "supported for this database driver. All database tables will be loaded."); label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); page.layout(true, true); setMessage(""); setPageComplete(true); return; } if (firstShow) { createComponent(); } else { disposeControl(); schemas.clear(); createComponent(); } getSchemas(); schemaTable.setInput(schemas); if (multipleSelection) { schemaTable.setAllChecked(true); setPageComplete(true); setMessage("Please select one or multiple schemas."); } else { setMessage("Please select one schema."); } } catch (SQLException e) { log.error(e.getMessage(), e); } }
Source:
<code>public void clickCloseShareScreenButton() { waitForElementByElement(closeShareScreenButton); closeShareScreenButton.click(); <START> } <END></code><technical_language>consider adding logging end of this method well</technical_language>

Target:
public void clickCloseShareScreenButton() { waitForElementByElement(closeShareScreenButton); closeShareScreenButton.click(); PageObjectLogging.log("clickCloseShareScreenButton", "close share screen button was clicked", true); }
Source:
<code><START> public AppPage clickNoOnModal() { <END> waitForTwoConfirmationModalAndClickOnNo(); waitForPageToLoad(); return this; }</code><technical_language>I wrong, methods added longer used</technical_language>

Target:
public void clickNoOnModal() { waitForModalPresence(); WebElement noButton = browser.driver.findElement(By.cssSelector("[data-bb-handler='no']")); waitForElementToBeClickable(noButton); click(noButton); waitForModalToDisappear(); }
Source:
<code>public List<String> getApiUris() { List<String> apiUris = Lists.newArrayList(); if (config.has(NSBarcodeConfigKeys.API_CONFIG)) { JSONArray childNode = null; try { childNode = config.getJSONArray(NSBarcodeConfigKeys.API_CONFIG); } catch (JSONException e) { log.error(TAG, "Invalid json array: "+ config.toString()); return apiUris; } for (int index = 0; index < childNode.length(); index++) { try { <START> apiUris.add(new JSONObject(childNode.getString(index)).getString(NSBarcodeConfigKeys.API_URI)); <END> } catch (JSONException e) { log.error(TAG, "Invalid child json object: "+ config.toString()); } } } return apiUris; }</code><technical_language>remember, a childNode.getJSONObject(index) method</technical_language>

Target:
public List<String> getApiUris() { List<String> apiUris = Lists.newArrayList(); if (config.has(NSBarcodeConfigKeys.API_CONFIG)) { JSONArray childNode = null; try { childNode = config.getJSONArray(NSBarcodeConfigKeys.API_CONFIG); } catch (JSONException e) { log.error("Invalid json array: "+ config.toString()); return apiUris; } for (int index = 0; index < childNode.length(); index++) { try { apiUris.add(childNode.getJSONObject(index).getString(NSBarcodeConfigKeys.API_URI)); } catch (JSONException e) { log.error("Invalid child json object: "+ config.toString()); } } } return apiUris; }
Source:
<code>public int getNumWaiters() { <START> return this.connectionPool.getNumActive(); <END> }</code><technical_language>suggestion return this.connectionPool.getNumWaiters();</technical_language>

Target:
public int getNumWaiters() { return this.connectionPool.getNumWaiters(); }
Source:
<code>public void getReplicasForBlobIdTest() throws ExecutionException, InterruptedException, JSONException { List<PartitionId> partitionIds = CLUSTER_MAP.getWritablePartitionIds(); PartitionId partitionId = partitionIds.get(new Random().nextInt(partitionIds.size())); String originalReplicaStr = partitionId.getReplicaIds().toString().replace(", ", ","); BlobId blobId = new BlobId(partitionId); String uri = AdminBlobStorageService.GET_REPLICAS_FOR_BLOB_ID + "?" + GetReplicasForBlobIdHandler.BLOB_ID_KEY + "=" + blobId; FullHttpRequest request = buildRequest(HttpMethod.GET, uri, null, null); Queue<HttpObject> responseParts = nettyClient.sendRequest(request, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); assertEquals("Unexpected status", HttpResponseStatus.OK, response.getStatus()); assertEquals("Unexpected Content-Type", "application/json", HttpHeaders.getHeader(response, HttpHeaders.Names.CONTENT_TYPE)); ByteBuffer buffer = getContent(response, responseParts); JSONObject responseObj = new JSONObject(new String(buffer.array())); String returnedReplicasStr = responseObj.getString(GetReplicasForBlobIdHandler.REPLICAS_KEY).replace("\"", ""); <START> assertEquals("Replica IDs returned for the BlobId do no match with the replicas IDs of partition", <END> originalReplicaStr, returnedReplicasStr); }</code><technical_language>Suggest message changed "Return is equal expected replicas". current message implies return is a list of replicas, is a strong statement</technical_language>

Target:
public void getReplicasForBlobIdTest() throws ExecutionException, InterruptedException, JSONException { List<PartitionId> partitionIds = CLUSTER_MAP.getWritablePartitionIds(); PartitionId partitionId = partitionIds.get(new Random().nextInt(partitionIds.size())); String originalReplicaStr = partitionId.getReplicaIds().toString().replace(", ", ","); BlobId blobId = new BlobId(partitionId); String uri = AdminBlobStorageService.GET_REPLICAS_FOR_BLOB_ID + "?" + GetReplicasForBlobIdHandler.BLOB_ID_KEY + "=" + blobId; FullHttpRequest httpRequest = buildRequest(HttpMethod.GET, uri, null, null); Queue<HttpObject> responseParts = nettyClient.sendRequest(httpRequest, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); assertEquals("Unexpected status", HttpResponseStatus.OK, response.getStatus()); assertEquals("Unexpected Content-Type", "application/json", HttpHeaders.getHeader(response, HttpHeaders.Names.CONTENT_TYPE)); ByteBuffer buffer = getContent(response, responseParts); JSONObject responseObj = new JSONObject(new String(buffer.array())); String returnedReplicasStr = responseObj.getString(GetReplicasForBlobIdHandler.REPLICAS_KEY).replace("\"", ""); assertEquals("Returned response for the BlobId do no match with the replicas IDs of partition", originalReplicaStr, returnedReplicasStr); }
Source:
<code>public Sku toSku() { <START> return this.sku; <END> }</code><technical_language>This return a new Sku object. Else user do DatabaseSku.HYPERSCALE_HS_GEN5_80.toSku().withTier(...) get underlying Sku modified</technical_language>

Target:
public Sku toSku() { return new Sku() .withName(sku.name()) .withTier(sku.tier()) .withFamily(sku.family()) .withCapacity(sku.capacity()) .withSize(sku.size()); }
Source:
<code>private static ResourceModel processSimpleResource(final Class<?> resourceClass, ResourceModel parentResource) { Class<? extends RecordTemplate> valueClass = null; if (SingleObjectResource.class.isAssignableFrom(resourceClass)) { @SuppressWarnings("unchecked") Class<? extends SingleObjectResource<?>> clazz = (Class<? extends SingleObjectResource<?>>) resourceClass; List<Class<?>> kvParams = ReflectionUtils.getTypeArguments(SingleObjectResource.class, clazz); valueClass = kvParams.get(0).asSubclass(RecordTemplate.class); } else { for (Method method : resourceClass.getDeclaredMethods()) { if (method.isSynthetic()) { continue; } Finder finderAnno = method.getAnnotation(Finder.class); if (finderAnno == null) { continue; } throw new ResourceConfigException("Class '" + resourceClass.getName() + "' of a SingleUnstructuredDataResource " <START> + "class does not support for @Finder methods"); <END> } } ResourceType resourceType = getResourceType(resourceClass); RestLiAnnotationData annotationData = getRestLiAnnotationData(resourceClass); String name = annotationData.name(); String namespace = annotationData.namespace(); Class<?> parentResourceClass = annotationData.parent().equals(RestAnnotations.ROOT.class) ? null : annotationData.parent(); ResourceModel resourceModel = new ResourceModel(valueClass, resourceClass, parentResourceClass, name, resourceType, namespace); resourceModel.setParentResourceModel(parentResource); addResourceMethods(resourceClass, resourceModel); log.debug("Processed simple resource '" + resourceClass.getName() + "'"); return resourceModel; }</code><technical_language>nit: remove "for" .. support @Finder methods"</technical_language>

Target:
private static ResourceModel processSimpleResource(final Class<?> resourceClass, ResourceModel parentResource) { Class<? extends RecordTemplate> valueClass = null; if (SingleObjectResource.class.isAssignableFrom(resourceClass)) { @SuppressWarnings("unchecked") Class<? extends SingleObjectResource<?>> clazz = (Class<? extends SingleObjectResource<?>>) resourceClass; List<Class<?>> kvParams = ReflectionUtils.getTypeArguments(SingleObjectResource.class, clazz); valueClass = kvParams.get(0).asSubclass(RecordTemplate.class); } ResourceType resourceType = getResourceType(resourceClass); RestLiAnnotationData annotationData = getRestLiAnnotationData(resourceClass); String name = annotationData.name(); String namespace = annotationData.namespace(); Class<?> parentResourceClass = annotationData.parent().equals(RestAnnotations.ROOT.class) ? null : annotationData.parent(); ResourceModel resourceModel = new ResourceModel(valueClass, resourceClass, parentResourceClass, name, resourceType, namespace); resourceModel.setParentResourceModel(parentResource); addResourceMethods(resourceClass, resourceModel); log.debug("Processed simple resource '" + resourceClass.getName() + "'"); return resourceModel; }
Source:
<code>public void writeData(byte[] data) throws IOException { <START> if (getOutputStream() != null) { <END> if (isHardwareFlowControl()) { int tries = 0; while (tries < 3 && !isCTS()) { try { Thread.sleep(100); } catch (InterruptedException e) { } tries += 1; } if (isCTS()) { getOutputStream().write(data); getOutputStream().flush(); } } else { getOutputStream().write(data); getOutputStream().flush(); } } }</code><technical_language>Check if data is null</technical_language>

Target:
public void writeData(byte[] data) throws IOException { if (data == null) throw new NullPointerException("Data to be sent cannot be null."); if (getOutputStream() != null) { if (isHardwareFlowControl()) { int tries = 0; while (tries < 3 && !isCTS()) { try { Thread.sleep(100); } catch (InterruptedException e) { } tries += 1; } if (isCTS()) { getOutputStream().write(data); getOutputStream().flush(); } } else { getOutputStream().write(data); getOutputStream().flush(); } } }
Source:
<code>public Response getPhotos(@Auth Key key, @QueryParam("username") String username) <START> throws IOException, MalformedURLException { <END> if (username == null) { return Response.status(Response.Status.BAD_REQUEST) .entity("'username' query parameter is required for getUser").build(); } PilotUser pilotUser = thunderClient.getUser(username); FacebookProvider facebookProvider = facebookProviderFactory.newFacebookProvider(pilotUser.getFacebookAccessToken()); List<String> urlList; try { urlList = facebookProvider.getFacebookUserPhotos(); } catch (FacebookOAuthException e) { LOG.error("Bad Facebook OAuth token for username {}", username, e); return Response.status(Response.Status.NOT_FOUND) .entity("Request rejected due to bad OAuth token").build(); } return Response.ok(urlList).build(); }</code><technical_language>I throws. Do need if so, catch return response status</technical_language>

Target:
public Response getPhotos(@Auth Key key, @QueryParam("username") String username) { if (username == null) { return Response.status(Response.Status.BAD_REQUEST) .entity("'username' query parameter is required for getUser").build(); } PilotUser pilotUser = thunderClient.getUser(username); FacebookProvider facebookProvider = facebookProviderFactory.newFacebookProvider(pilotUser.getFacebookAccessToken()); List<String> urlList; try { urlList = facebookProvider.getFacebookUserPhotos(); } catch (FacebookOAuthException e) { LOG.error("Bad Facebook OAuth token for username {}", username, e); return Response.status(Response.Status.NOT_FOUND) .entity("Request rejected due to bad OAuth token").build(); } return Response.ok(urlList).build(); }
Source:
<code>public void testEqualityOverride() { KieSession ksession = session.getStateful(); FactHandle string = ksession.insert("testString"); ksession.fireAllRules(); Assertions.assertThat(ksession.getObjects().size()).isEqualTo(2); <START> ksession.insert(42); <END> ksession.fireAllRules(); Assertions.assertThat(ksession.getObjects().size()).isEqualTo(4); ksession.delete(string); ksession.fireAllRules(); Assertions.assertThat(ksession.getObjects().size()).isEqualTo(2); }</code><technical_language>Magic constant</technical_language>

Target:
public void testEqualityOverride() { KieSession ksession = session.getStateful(); FactHandle string = ksession.insert("testString"); ksession.fireAllRules(); Assertions.assertThat(ksession.getObjects().size()).isEqualTo(2); ksession.insert(ANY_NUMBER); ksession.fireAllRules(); Assertions.assertThat(ksession.getObjects().size()).isEqualTo(4); ksession.delete(string); ksession.fireAllRules(); Assertions.assertThat(ksession.getObjects().size()).isEqualTo(2); }
Source:
<code>public void prepareRun(BatchSinkContext context) throws Exception { Job job = context.getHadoopJob(); <START> job.setOutputFormatClass(NullOutputFormat.class); <END> context.addOutput(Output.of(batchConfig.referenceName, new SolrSearchSink.SolrOutputFormatProvider(batchConfig))); }</code><technical_language>this statement removed. need set OutputFormat job itself. OutputFormat for specific output (being defined next line)</technical_language>

Target:
public void prepareRun(BatchSinkContext context) throws Exception { context.addOutput(Output.of(batchConfig.referenceName, new SolrSearchSink.SolrOutputFormatProvider(batchConfig))); }
Source:
<code>public void load() { for (IndexConfiguration indexConfiguration : indexesConfigurations) { if (copyConfiguration) { indexConfigurationCopier.copyIndexConfiguration(indexConfiguration, solrHomeLocationPolicy.fetchSolrHome()); <START> } <END> indexReloader.reloadIndex(indexConfiguration); } }</code><technical_language>'if{}' check if configuration copied. configurationPath returned solrHomeLocationPolicy</technical_language>

Target:
public void load() { for (IndexConfiguration indexConfiguration : indexesConfigurations) { if (copyConfiguration) { indexConfigurationCopier.copyIndexConfiguration(indexConfiguration, solrHomeLocationPolicy.getSolrHome()); } indexReloader.reloadIndex(indexConfiguration); } }
Source:
<code>protected void packHeader (OutputObjectState os, Header hdr) throws IOException { Uid txId = ((hdr == null) ? null : hdr.getTxId()); Uid processUid = ((hdr == null) ? null : hdr.getProcessId()); try { <START> os.packStringBytes(markerBytes); <END> if (txId != null) { UidHelper.packInto(txId, os); UidHelper.packInto(processUid, os); } else UidHelper.packInto(Uid.nullUid(), os); long birthDate = System.currentTimeMillis(); if (tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("StateManager.packHeader for object-id " + get_uid() + " birth-date " + birthDate); } os.packLong(birthDate); } catch (IOException ex) { throw ex; } catch (Exception e) { IOException ioException = new IOException(e.toString()); ioException.initCause(e); throw ioException; } }</code><technical_language>is performance difference packing bytes packing string - is string copy (os.packString(StateManager.marker)) is avoided</technical_language>

Target:
protected void packHeader (OutputObjectState os, Header hdr) throws IOException { Uid txId = ((hdr == null) ? null : hdr.getTxId()); Uid processUid = ((hdr == null) ? null : hdr.getProcessId()); try { os.packStringBytes(StateManager.markerBytes); if (txId != null) { UidHelper.packInto(txId, os); UidHelper.packInto(processUid, os); } else UidHelper.packInto(Uid.nullUid(), os); long birthDate = System.currentTimeMillis(); if (tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("StateManager.packHeader for object-id " + get_uid() + " birth-date " + birthDate); } os.packLong(birthDate); } catch (IOException ex) { throw ex; } catch (Exception e) { IOException ioException = new IOException(e.toString()); ioException.initCause(e); throw ioException; } }
Source:
<code>@Test public void testFilterableWhere3() throws SQLException { final String sql = "select empno, gender, name from EMPS\n" + " where gender = 'F' or empno > 125"; <START> sql("filterable-model", sql) <END> .returns("EMPNO=120; GENDER=F; NAME=Wilma", "EMPNO=130; GENDER=F; NAME=Alice") .ok(); }</code><technical_language>update code while test case sql is OR, i kind of confused</technical_language>

Target:
@Test public void testFilterableWhere3() throws SQLException { final String sql = "select empno, gender, name from EMPS\n" + " where gender <> 'M' and empno > 125"; sql("filterable-model", sql) .returns("EMPNO=130; GENDER=F; NAME=Alice") .ok(); }
Source:
<code>public static String getRootURL() { String moduleURL = GWT.getModuleBaseURL(); int index = moduleURL.indexOf("://"); <START> if (index == -1) { <END> GWT.log("Can't extract root URL from module URL \"" + moduleURL + "\"."); } index = moduleURL.indexOf("/", index + 3); if (index == -1) { return moduleURL; } return moduleURL.substring(0, index); }</code><technical_language>In practice this happen :) suggest remove this check, throw a runtime exception instead of logging error</technical_language>

Target:
public static String getRootURL() { String moduleURL = GWT.getModuleBaseURL(); String separator = "://"; int index = moduleURL.indexOf(separator); if (index == -1) { throw new RuntimeException(); } index = moduleURL.indexOf("/", index + separator.length()); if (index == -1) { return moduleURL; } return moduleURL.substring(0, index); }
Source:
<code><START> public void canWaitForLocks() { <END> LockTokenV2 token = CLUSTER.lock(requestFor(LOCK_A, LOCK_B)); Future<?> future = executor.submit( () -> CLUSTER.timelockService().waitForLocks(waitRequestFor(LOCK_A, LOCK_B))); assertNotDone(future); CLUSTER.unlock(token); assertDone(future); }</code><technical_language>nit: 3 lines a separate test</technical_language>

Target:
public void canWaitForLocks() { LockTokenV2 token = CLUSTER.lock(requestFor(LOCK_A, LOCK_B)); Future<?> future = CLUSTER.waitForLocksAsync(waitRequestFor(LOCK_A, LOCK_B)); assertNotDone(future); CLUSTER.unlock(token); assertDone(future); }
Source:
<code>public void testGetUrl() { try { String url = reservationReportPdfStamperView.getUrl(); assertThat(url, is("classpath:reports/reservationReport.pdf")); } catch (Exception e) { e.printStackTrace(); fail(); <START> } <END> }</code><technical_language>[x] write throws Exception try-catch. (Same @Before)</technical_language>

Target:
public void testGetUrl() { reservationReportPdfStamperView.reservationReportPdfUrl = "classpath:reports/reservationReport.pdf"; String url = reservationReportPdfStamperView.getUrl(); assertThat(url, is("classpath:reports/reservationReport.pdf")); }
Source:
<code>public static OutputStream makeCipherOutputForStream( final OutputStream httpOut, final SupportedCipherDetails cipherDetails, <START> final Cipher cipher, <END> final HMac hmac) { final CloseShieldOutputStream noCloseOut = new CloseShieldOutputStream(httpOut); final CipherOutputStream cipherOut = new CipherOutputStream(noCloseOut, cipher); final OutputStream out; Validate.notNull(cipherDetails, "Cipher details must not be null"); if (cipherDetails.isAEADCipher()) { out = cipherOut; } else { out = new HmacOutputStream(hmac, cipherOut); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Creating new OutputStream for multipart [{}]", out.getClass()); } return out; }</code><technical_language>cipher validated for nullness</technical_language>

Target:
public static OutputStream makeCipherOutputForStream( final OutputStream httpOut, final SupportedCipherDetails cipherDetails, final Cipher cipher, final HMac hmac) { final CloseShieldOutputStream noCloseOut = new CloseShieldOutputStream(httpOut); final CipherOutputStream cipherOut = new CipherOutputStream(noCloseOut, cipher); final OutputStream out; Validate.notNull(cipherDetails, "Cipher details must not be null"); Validate.notNull(cipher, "Cipher must not be null"); if (cipherDetails.isAEADCipher()) { out = cipherOut; } else { out = new HmacOutputStream(hmac, cipherOut); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Creating new OutputStream for multipart [{}]", out.getClass()); } return out; }
Source:
<code>public Reply<?> removeOperators(@Named("id")Object id, Request request) { OperatorIdentifiersDTO dto = request.read(OperatorIdentifiersDTO.class).as(Json.class); OperatorIdentifiers ids = adapt(dto); Optional<RoamingGroup> group = repository.findById(id); if (!group.isPresent()) { <START> return Reply.with("Roaming group to which you want to remove operators is undefined.").status(SC_BAD_REQUEST); <END> } repository.remove(id, ids); return Reply.saying().ok(); }</code><technical_language>change message status code</technical_language>

Target:
public Reply<?> removeOperators(@Named("id")Object id, Request request) { List<Object> dtos = request.read(new TypeLiteral<List<Object>>() {}).as(Json.class); List<ID> ids = adaptToID(dtos); repository.removeOperators(new ID(id), ids); return Reply.saying().ok(); }
Source:
<code>public Iterator<Vector3ic> iterator() { Vector3i pos = new Vector3i(); final int[] level = {this.startDistance}; <START> final int[] offset = {-this.startDistance,0,0}; <END> return new Iterator<Vector3ic>() { @Override public boolean hasNext() { return level[0] < endDistance; } @Override public Vector3ic next() { pos.set(origin.x + offset[0], origin.y + offset[1], origin.z + offset[2]); if (offset[2] < 0) { offset[2] *= -1; } else if (offset[1] < 0) { offset[1] *= -1; offset[2] = -(level[0] - TeraMath.fastAbs(offset[0]) - TeraMath.fastAbs(offset[1])); } else { offset[1] = -offset[1] + 1; if (offset[1] > 0) { if (++offset[0] <= level[0]) { offset[1] = TeraMath.fastAbs(offset[0]) - level[0]; offset[2] = 0; } else { level[0]++; offset[0] = -level[0]; offset[1] = 0; offset[2] = 0; } } else { offset[2] = -(level[0] - TeraMath.fastAbs(offset[0]) - TeraMath.fastAbs(offset[1])); } } return pos; } }; }</code><technical_language>access clearer a Vector3i here</technical_language>

Target:
public Iterator<Vector3ic> iterator() { Vector3i pos = new Vector3i(); final int[] level = {this.startDistance}; final Vector3i offset = new Vector3i(-this.startDistance,0,0); return new Iterator<Vector3ic>() { @Override public boolean hasNext() { return level[0] < endDistance; } @Override public Vector3ic next() { origin.add(offset, pos); if (offset.z < 0) { offset.z *= -1; } else if (offset.y() < 0) { offset.y *= -1; offset.z = -(level[0] - TeraMath.fastAbs(offset.x()) - TeraMath.fastAbs(offset.y())); } else { offset.y = -offset.y() + 1; if (offset.y > 0) { if (++offset.x <= level[0]) { offset.y = TeraMath.fastAbs(offset.x) - level[0]; offset.z = 0; } else { level[0]++; offset.x = -level[0]; offset.y = 0; offset.z = 0; } } else { offset.z = -(level[0] - TeraMath.fastAbs(offset.x) - TeraMath.fastAbs(offset.y)); } } return pos; } }; }
Source:
<code><START> private boolean logContains(String msg) { <END> List<LogItem> logs = ShadowLog.getLogs(); boolean found = false; for (LogItem logItem : logs) { if (logItem.msg.startsWith(msg)) found = true; } return found; }</code><technical_language>this static</technical_language>

Target:
private static boolean logContains(String msg) { List<LogItem> logs = ShadowLog.getLogs(); boolean found = false; for (LogItem logItem : logs) { if (logItem.msg.startsWith(msg)) found = true; } return found; }