auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public RowData readRecord(RowData reuse, byte[] bytes, int offset, int numBytes) throws IOException { GenericRowData returnRecord = rowData; if (this.getDelimiter() != null && this.getDelimiter().length == 1 && this.getDelimiter()[0] == NEW_LINE && offset + numBytes >= 1 && bytes[offset + numBytes - 1] == CARRIAGE_RETURN){ numBytes -= 1; } byte[] trimBytes = Arrays.copyOfRange(bytes, offset, offset + numBytes); GenericRowData jsonRow = (GenericRowData) deserializationSchema.deserialize(trimBytes); <START> if (jsonRow != null) { <END> for (int i = 0; i < jsonSelectFieldNames.size(); i++) { returnRecord.setField(jsonFieldMapping[i], jsonRow.getField(i)); } } emitted++; return returnRecord; }</code><technical_language>jsonRow != null? happen jsonRow is null</technical_language>

Target:
public RowData readRecord(RowData reuse, byte[] bytes, int offset, int numBytes) throws IOException { if (this.getDelimiter() != null && this.getDelimiter().length == 1 && this.getDelimiter()[0] == NEW_LINE && offset + numBytes >= 1 && bytes[offset + numBytes - 1] == CARRIAGE_RETURN) { numBytes -= 1; } byte[] trimBytes = Arrays.copyOfRange(bytes, offset, offset + numBytes); GenericRowData jsonRow = (GenericRowData) deserializationSchema.deserialize(trimBytes); if (jsonRow == null) { return null; } GenericRowData returnRecord = rowData; for (int i = 0; i < jsonSelectFieldToJsonFieldMapping.length; i++) { returnRecord.setField(jsonSelectFieldToProjectFieldMapping[i], jsonRow.getField(jsonSelectFieldToJsonFieldMapping[i])); } emitted++; return returnRecord; }
Source:
<code>public FedoraId getContainerIdByPath(final String txID, final FedoraId fedoraId) { if (fedoraId.isRepositoryRoot()) { return fedoraId; } final String parent = getContainedBy(txID, fedoraId); if (parent != null) { return FedoraId.create(parent); } <START> String idIterator = fedoraId.getFullId(); <END> while (idIterator.contains("/")) { idIterator = fedoraId.getResourceId().substring(0, idIterator.lastIndexOf("/")); if (idIterator.equals(FEDORA_ID_PREFIX)) { return FedoraId.getRepositoryRootId(); } final FedoraId testID = FedoraId.create(idIterator); if (resourceExists(txID, testID)) { return testID; } } return FedoraId.getRepositoryRootId(); }</code><technical_language>Normally, a variable is named iterator, is of type Iterator. rename this avoids this confusion... fullId</technical_language>

Target:
public FedoraId getContainerIdByPath(final String txID, final FedoraId fedoraId) { if (fedoraId.isRepositoryRoot()) { return fedoraId; } final String parent = getContainedBy(txID, fedoraId); if (parent != null) { return FedoraId.create(parent); } String fullId = fedoraId.getFullId(); while (fullId.contains("/")) { fullId = fedoraId.getResourceId().substring(0, fullId.lastIndexOf("/")); if (fullId.equals(FEDORA_ID_PREFIX)) { return FedoraId.getRepositoryRootId(); } final FedoraId testID = FedoraId.create(fullId); if (resourceExists(txID, testID)) { return testID; } } return FedoraId.getRepositoryRootId(); }
Source:
<code><START> private void setResponseHeaders(BlobInfo blobInfo) <END> throws RestServiceException { BlobProperties blobProperties = blobInfo.getBlobProperties(); restResponseChannel.setStatus(ResponseStatus.Ok); restResponseChannel.setLastModified(new Date(blobProperties.getCreationTimeInMs())); restResponseChannel.setContentLength(blobProperties.getBlobSize()); restResponseChannel.setHeader(RestConstants.Headers.Blob_Size, blobProperties.getBlobSize()); restResponseChannel.setHeader(RestConstants.Headers.Service_Id, blobProperties.getServiceId()); restResponseChannel.setHeader(RestConstants.Headers.Creation_Time, new Date(blobProperties.getCreationTimeInMs())); restResponseChannel.setHeader(RestConstants.Headers.Private, blobProperties.isPrivate()); if (blobProperties.getTimeToLiveInSeconds() != Utils.Infinite_Time) { restResponseChannel.setHeader(RestConstants.Headers.TTL, Long.toString(blobProperties.getTimeToLiveInSeconds())); } if (blobProperties.getContentType() != null) { restResponseChannel.setHeader(RestConstants.Headers.Content_Type, blobProperties.getContentType()); restResponseChannel.setContentType(blobProperties.getContentType()); } if (blobProperties.getOwnerId() != null) { restResponseChannel.setHeader(RestConstants.Headers.Owner_Id, blobProperties.getOwnerId()); } }</code><technical_language>in this is diff setResponseHeaders() in HeadForGetCallback</technical_language>

Target:
private void setResponseHeaders(BlobInfo blobInfo) throws RestServiceException { BlobProperties blobProperties = blobInfo.getBlobProperties(); restResponseChannel.setStatus(ResponseStatus.Ok); restResponseChannel.setLastModified(new Date(blobProperties.getCreationTimeInMs())); restResponseChannel.setContentLength(blobProperties.getBlobSize()); restResponseChannel.setHeader(RestUtils.Headers.Blob_Size, blobProperties.getBlobSize()); restResponseChannel.setHeader(RestUtils.Headers.Service_Id, blobProperties.getServiceId()); restResponseChannel.setHeader(RestUtils.Headers.Creation_Time, new Date(blobProperties.getCreationTimeInMs())); restResponseChannel.setHeader(RestUtils.Headers.Private, blobProperties.isPrivate()); if (blobProperties.getTimeToLiveInSeconds() != Utils.Infinite_Time) { restResponseChannel.setHeader(RestUtils.Headers.TTL, Long.toString(blobProperties.getTimeToLiveInSeconds())); } if (blobProperties.getContentType() != null) { restResponseChannel.setHeader(RestUtils.Headers.Content_Type, blobProperties.getContentType()); restResponseChannel.setContentType(blobProperties.getContentType()); } if (blobProperties.getOwnerId() != null) { restResponseChannel.setHeader(RestUtils.Headers.Owner_Id, blobProperties.getOwnerId()); } }
Source:
<code>private File createTempReactorProject(Server server) throws MojoFailureException, MojoExecutionException { File tempFolder = new File(server.getServerDirectory(), "temp-project"); if (!tempFolder.exists()) { tempFolder.mkdir(); } Model tempModel = createModel(); Set<Project> watchedModules = server.getWatchedProjects(); for(Project module: watchedModules){ if (!module.getModel().getPomFile().exists()) { <START> throw new IllegalStateException("Source code of module " + module.getArtifactId() + " doesn't exist. " + <END> "Unwatch this module by running mvn openmrs-sdk:unwatch -DartifactId="+module.getArtifactId()+" -DserverId=" + serverId); } Path newLink = Paths.get(new File(tempFolder, module.getArtifactId()).getAbsolutePath()); Path existingfile = Paths.get(module.getPath()); try { Files.createSymbolicLink(newLink, existingfile); } catch (IOException e) { copyModuleToTempServer(module.getPath(), newLink.toString()); } finally { tempModel.addModule(module.getArtifactId()); } } try { Writer writer = new FileWriter(new File(tempFolder, "pom.xml")); new MavenXpp3Writer().write(writer, tempModel); } catch (IOException e) { throw new RuntimeException("Failed to write pom.xml", e); } return tempFolder; }</code><technical_language>Please mention path e.g. "Module " + module.getArtifactId() + " " + module.getModel().getPomFile().getAbsolutePath() + ". Unwatch..."</technical_language>

Target:
private File createTempReactorProject(Server server) throws MojoFailureException, MojoExecutionException { File tempFolder = new File(server.getServerDirectory(), "temp-project"); if (!tempFolder.exists()) { tempFolder.mkdir(); } Model tempModel = createModel(); Set<Project> watchedModules = server.getWatchedProjects(); for(Project module: watchedModules){ if (!module.getModel().getPomFile().exists()) { throw new IllegalStateException("Module " + module.getArtifactId() + " could not be found at " + module.getModel().getPomFile().getAbsolutePath() + ". " + "Unwatch this module by running mvn openmrs-sdk:unwatch -DartifactId="+module.getArtifactId()+" -DserverId=" + serverId); } Path newLink = Paths.get(new File(tempFolder, module.getArtifactId()).getAbsolutePath()); Path existingfile = Paths.get(module.getPath()); try { Files.createSymbolicLink(newLink, existingfile); } catch (IOException e) { copyModuleToTempServer(module.getPath(), newLink.toString()); } finally { tempModel.addModule(module.getArtifactId()); } } try { Writer writer = new FileWriter(new File(tempFolder, "pom.xml")); new MavenXpp3Writer().write(writer, tempModel); } catch (IOException e) { throw new RuntimeException("Failed to write pom.xml", e); } return tempFolder; }
Source:
<code>public void testMultipartRequest() throws Exception { String BOUNDARY = "01f136d9282f"; ByteBuf byteBuf = Unpooled.wrappedBuffer(("--" + BOUNDARY + "\n" + "Content-Disposition: form-data; name=\"msg_id\"\n" + "\n" + "15200\n" + "--" + BOUNDARY + "\n" + "Content-Disposition: form-data; name=\"msg\"\n" + "\n" + "test message\n" + "--" + BOUNDARY + "--").getBytes()); DefaultFullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.POST, "/up", byteBuf); req.headers().add(HttpHeaderNames.CONTENT_TYPE, "multipart/form-data; boundary=" + BOUNDARY); HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE), req, java.nio.charset.Charset.forName("utf-8")); assertTrue(decoder.isMultipart()); assertFalse(decoder.getBodyHttpDatas().isEmpty()); assertEquals(2, decoder.getBodyHttpDatas().size()); assertEquals("test message", ((Attribute) decoder.getBodyHttpData("msg")).getValue()); assertEquals("15200", ((Attribute) decoder.getBodyHttpData("msg_id")).getValue()); decoder.destroy(); <START> } <END></code><technical_language>add a assertEquals(0, req.refCnt()); destroy() call</technical_language>

Target:
public void testMultipartRequest() throws Exception { String BOUNDARY = "01f136d9282f"; ByteBuf byteBuf = Unpooled.wrappedBuffer(("--" + BOUNDARY + "\n" + "Content-Disposition: form-data; name=\"msg_id\"\n" + "\n" + "15200\n" + "--" + BOUNDARY + "\n" + "Content-Disposition: form-data; name=\"msg\"\n" + "\n" + "test message\n" + "--" + BOUNDARY + "--").getBytes()); FullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.POST, "/up", byteBuf); req.headers().add(HttpHeaderNames.CONTENT_TYPE, "multipart/form-data; boundary=" + BOUNDARY); HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(new DefaultHttpDataFactory(DefaultHttpDataFactory.MINSIZE), req, CharsetUtil.UTF_8); assertTrue(decoder.isMultipart()); assertFalse(decoder.getBodyHttpDatas().isEmpty()); assertEquals(2, decoder.getBodyHttpDatas().size()); assertEquals("test message", ((Attribute) decoder.getBodyHttpData("msg")).getValue()); assertEquals("15200", ((Attribute) decoder.getBodyHttpData("msg_id")).getValue()); decoder.destroy(); assertEquals(1, req.refCnt()); }
Source:
<code>private LiteralSuggestion getDmsSuggestion(final String query) { final List<LatLon> dmsCoordinates = new ArrayList<>(); final Matcher matcher = PATTERN_DMS_COORDINATE.matcher(query); final StringBuilder nameBuilder = new StringBuilder("DMS:"); int start = 0; while (matcher.find()) { LOGGER.trace("Match found [{}]", matcher.group()); <START> LatLon parsedDms = CoordinateTranslator.dmsToLatLon(query.substring(start, matcher.end())); <END> start = matcher.end(); if (parsedDms != null) { dmsCoordinates.add(parsedDms); nameBuilder .append(" [ ") .append(CoordinateTranslator.normalizedDmsString(matcher.group())) .append(" ]"); } } if (dmsCoordinates.isEmpty()) { LOGGER.trace("No valid DMS strings could be inferred from query [{}]", query); return null; } return new LiteralSuggestion(LITERAL_SUGGESTION_ID, nameBuilder.toString(), dmsCoordinates); }</code><technical_language>suggestion final LatLon parsedDms = CoordinateTranslator.dmsToLatLon(query.substring(start, matcher.end()));</technical_language>

Target:
private LiteralSuggestion getDmsSuggestion(final String query) { final List<LatLon> dmsCoordinates = new ArrayList<>(); final Matcher matcher = PATTERN_DMS_COORDINATES.matcher(query); final StringBuilder nameBuilder = new StringBuilder("DMS:"); int start = 0; while (matcher.find()) { final String dmsString = query.substring(start, matcher.end()); final LatLon latLon = dmsToLatLon(dmsString); start = matcher.end(); if (latLon != null) { LOGGER.trace("Match found [{}]", matcher.group()); dmsCoordinates.add(latLon); nameBuilder .append(" [ ") .append(DMSCoordinates.normalizedDmsString(dmsString)) .append(" ]"); } } if (dmsCoordinates.isEmpty()) { LOGGER.trace("No valid DMS strings could be inferred from query [{}]", query); return null; } return new LiteralSuggestion(LITERAL_SUGGESTION_ID, nameBuilder.toString(), dmsCoordinates); }
Source:
<code>public Optional<StorageObject> openArchive(TaskRequest request) { if (!request.getRevision().isPresent()) { return Optional.absent(); } String revision = request.getRevision().get(); try { return tm.begin((TransactionManager.SupplierInTransaction< Optional<StorageObject>, ResourceNotFoundException, <START> StorageFileNotFoundException, RuntimeException>) () -> <END> archiveManager.openArchive( pm.getProjectStore(request.getSiteId()), request.getProjectId(), revision), ResourceNotFoundException.class, StorageFileNotFoundException.class); } catch (ResourceNotFoundException ex) { throw new IllegalStateException(String.format(ENGLISH, "Archive data for project id=%d revision='%s' is not found in database", request.getProjectId(), request.getRevision().or("") ), ex); } catch (StorageFileNotFoundException ex) { throw new IllegalStateException(String.format(ENGLISH, "Archive file for project id=%d revision='%s' is not found", request.getProjectId(), request.getRevision().or("") ), ex); } }</code><technical_language>This is minor Instead of casting lambda type, this syntax: java tm.<Optional<StorageObject>, ResourceNotFoundException, StorageFileNotFoundException>begin(() -> { ... }, ResourceNotFoundException.class, StorageFileNotFoundException.class); I wish javac smart enough guess types automatically..</technical_language>

Target:
public Optional<StorageObject> openArchive(TaskRequest request) { if (!request.getRevision().isPresent()) { return Optional.absent(); } String revision = request.getRevision().get(); try { return tm.<Optional<StorageObject>, ResourceNotFoundException, StorageFileNotFoundException>begin(() -> archiveManager.openArchive( pm.getProjectStore(request.getSiteId()), request.getProjectId(), revision), ResourceNotFoundException.class, StorageFileNotFoundException.class); } catch (ResourceNotFoundException ex) { throw new IllegalStateException(String.format(ENGLISH, "Archive data for project id=%d revision='%s' is not found in database", request.getProjectId(), request.getRevision().or("") ), ex); } catch (StorageFileNotFoundException ex) { throw new IllegalStateException(String.format(ENGLISH, "Archive file for project id=%d revision='%s' is not found", request.getProjectId(), request.getRevision().or("") ), ex); } }
Source:
<code>protected void executeQueryCommand() { getQueryReturnValue().setReturnValue( <START> DbFacade.getInstance().getDiskImageDao().getImagesByStorageId(getParameters().getStorageDomainId())); <END> }</code><technical_language>getDbFacade()</technical_language>

Target:
protected void executeQueryCommand() { getQueryReturnValue().setReturnValue( getDbFacade().getDiskImageDao().getImagesByStorageId(getParameters().getStorageDomainId())); }
Source:
<code><START> public static String getMD5HashAsString(String plainText) { <END> try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(plainText.getBytes()); byte[] hashInBytes = md.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < hashInBytes.length; i++) sb.append(Integer.toString((hashInBytes[i] & 0xff) + 0x100, 16).substring(1)); return sb.toString(); } catch (NoSuchAlgorithmException e) { return ""; } }</code><technical_language>a bit annoying for replicate this exact process in another environment, Base64 utility convert hash byte[] a base64 string? super easy replicate in, say, Python common libs</technical_language>

Target:
public static String getMD5HashAsString(String plainText) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(plainText.getBytes()); byte[] hashInBytes = md.digest(); return Base64.encode(hashInBytes); } catch (NoSuchAlgorithmException e) { return ""; } }
Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_purchase_req_response); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_purchase_request); toolbar.setTitle("Purchase"); setSupportActionBar(toolbar); <START> if (getSupportActionBar() != null) { <END> getSupportActionBar().setDisplayHomeAsUpEnabled(true); } initializeComponents(); }</code><technical_language>NITPICK: is a class for this exist, reuse that</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_purchase_req_response); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_purchase_request); toolbar.setTitle("Purchase"); setSupportActionBar(toolbar); actionBar.enableHomeButton(this); initializeComponents(); }
Source:
<code>public GetConfigurationValuesQuery(P parameters) { super(parameters); <START> configValuesSet = new HashSet<String>(); <END> }</code><technical_language>in addition moving it, init in right size -ConfigValues.values().size()</technical_language>

Target:
public GetConfigurationValuesQuery(P parameters) { super(parameters); }
Source:
<code>public PackingPlan repack(PackingPlan currentPackingPlan, Map<String, Integer> componentChanges) { this.numContainers = currentPackingPlan.getContainers().size(); resetState(); int additionalContainers = computeNumAdditionalContainers(componentChanges, currentPackingPlan); increaseNumContainers(additionalContainers); LOG.info(String.format( "Allocated %s additional containers for repack bring the number of containers to %s.", additionalContainers, this.numContainers)); int adjustments = 0; while (adjustments <= this.numAdjustments) { try { PackingPlanBuilder planBuilder = newPackingPlanBuilder(currentPackingPlan); planBuilder.updateNumContainers(numContainers); <START> planBuilder = getResourceCompliantRRAllocation( <END> planBuilder, currentPackingPlan, componentChanges); return planBuilder.build(); } catch (ResourceExceededException e) { LOG.info(String.format( "Increasing the number of containers to %s and attempting packing again.", this.numContainers + 1)); adjustNumContainers(1); containerId = 1; adjustments++; } } return null; }</code><technical_language>If get resource compliant allocation fails exception, packingbuilder updaed number of containers? bring in catch clause? a difference eventually update next iteration guarantees consistency. is a tricky verify numContainers in builder is correct one</technical_language>

Target:
public PackingPlan repack(PackingPlan currentPackingPlan, Map<String, Integer> componentChanges) { this.numContainers = currentPackingPlan.getContainers().size(); resetState(); int additionalContainers = computeNumAdditionalContainers(componentChanges, currentPackingPlan); increaseNumContainers(additionalContainers); LOG.info(String.format( "Allocated %s additional containers for repack bring the number of containers to %s.", additionalContainers, this.numContainers)); int adjustments = 0; while (adjustments <= this.numAdjustments) { try { PackingPlanBuilder planBuilder = newPackingPlanBuilder(currentPackingPlan); planBuilder.updateNumContainers(numContainers); planBuilder = getResourceCompliantRRAllocation( planBuilder, currentPackingPlan, componentChanges); return planBuilder.build(); } catch (ResourceExceededException e) { adjustNumContainers(1); containerId = 1; adjustments++; LOG.info(String.format( "Increasing the number of containers to %s and attempting packing again.", this.numContainers)); } } return null; }
Source:
<code>public void commit(boolean ddl) { checkCommitRollback(); currentTransactionName = null; transactionStart = null; if (transaction != null) { try { if (!locks.isEmpty()) { for (Table t : locks) { if (t instanceof MVTable) { ((MVTable) t).commit(); } } } transaction.commit(); } finally { transaction = null; } } else if (containsUncommitted()) { database.commit(this); <START> } <END> analyzeTables(); removeTemporaryLobs(true); if (undoLog != null && undoLog.size() > 0) { undoLog.clear(); } if (!ddl) { cleanTempTables(false); if (autoCommitAtTransactionEnd) { autoCommit = true; autoCommitAtTransactionEnd = false; } } endTransaction(); }</code><technical_language>I need copy part of "if" block analyzeTables() this work properly, a new open transaction META table need committing</technical_language>

Target:
public void commit(boolean ddl) { checkCommitRollback(); currentTransactionName = null; transactionStart = null; if (transaction != null) { try { if (!locks.isEmpty()) { for (Table t : locks) { if (t instanceof MVTable) { ((MVTable) t).commit(); } } } transaction.commit(); } finally { transaction = null; } } else if (containsUncommitted()) { database.commit(this); } removeTemporaryLobs(true); if (undoLog != null && undoLog.size() > 0) { undoLog.clear(); } if (!ddl) { cleanTempTables(false); if (autoCommitAtTransactionEnd) { autoCommit = true; autoCommitAtTransactionEnd = false; } } if (tablesToAnalyze != null) { if (database.isMVStore()) { analyzeTables(); commit(true); } else { analyzeTables(); } } endTransaction(); }
Source:
<code>protected URI buildURI(String url) { <START> LOG.info("buildURI The passed in URL is: " + url); <END> URI uri; try { uri = new URI(url); } catch (URISyntaxException e) { throw new RuntimeException(e); } return uri; }</code><technical_language>is this debug level info level</technical_language>

Target:
protected URI buildURI(String url) { LOG.debug("buildURI The passed in URL is: " + url); URI uri; try { uri = new URI(url); } catch (URISyntaxException e) { LOG.error("buildURI unable to build a URI object for the URL: '" + url + "' with the error: ", e); throw new RuntimeException("Unable to build URI for the URL: " + url, e); } return uri; }
Source:
<code>public TokenManager getTokenManager(Mono<ClaimsBasedSecurityNode> cbsNodeMono, String resource) { <START> final String scopes = getResourceString(resource); <END> final String tokenAudience = String.format(Locale.US, TOKEN_AUDIENCE_FORMAT, fullyQualifiedNamespace, resource); logger.info("Creating new token manager for audience[{}], resource[{}]", tokenAudience, resource); return new ActiveClientTokenManager(cbsNodeMono, tokenAudience, scopes); }</code><technical_language>getScopesFromResource() a name for this method</technical_language>

Target:
public TokenManager getTokenManager(Mono<ClaimsBasedSecurityNode> cbsNodeMono, String resource) { final String scopes = getScopesFromResource(resource); final String tokenAudience = String.format(Locale.US, TOKEN_AUDIENCE_FORMAT, fullyQualifiedNamespace, resource); logger.info("Creating new token manager for audience[{}], resource[{}]", tokenAudience, resource); return new ActiveClientTokenManager(cbsNodeMono, tokenAudience, scopes); }
Source:
<code>public void comprehension_scope() { FunctionDef functionTree = functionTreesByName.get("scope_of_comprehension"); Map<String, Symbol> symbolByName = getSymbolByName(functionTree); assertThat(symbolByName).containsOnlyKeys("x"); <START> assertThat(symbolByName.get("x").usages().stream().map(u -> u.tree().firstToken().line())).hasSize(2).containsExactly(98, 100).doesNotContain(99); <END> Name name = (Name) ((ComprehensionExpression) ((ExpressionStatement) functionTree.body().statements().get(0)).expressions().get(0)).comprehensionFor().loopExpression(); assertThat(name.symbol().usages().stream().map(u -> u.tree().firstToken().line())).hasSize(2).doesNotContain(98, 100).containsExactly(99, 99); }</code><technical_language>I asserting size is redundant here, containsExactly. - a minor suggestion: extracting that: java assertThat(symbolByName.get("x").usages()).extracting(u -> u.tree().firstToken().line())</technical_language>

Target:
public void comprehension_scope() { FunctionDef functionTree = functionTreesByName.get("scope_of_comprehension"); Map<String, Symbol> symbolByName = getSymbolByName(functionTree); assertThat(symbolByName).containsOnlyKeys("x"); assertThat(symbolByName.get("x").usages()).extracting(u -> u.tree().firstToken().line()).containsExactly(98, 100).doesNotContain(99); Name name = (Name) ((ComprehensionExpression) ((ExpressionStatement) functionTree.body().statements().get(0)).expressions().get(0)).comprehensionFor().loopExpression(); assertThat(name.symbol().usages()).extracting(u -> u.tree().firstToken().line()).doesNotContain(98, 100).containsExactly(99, 99); }
Source:
<code>static private void parse(Config cfg, GerritConfig c) { ArrayList<String> l = Lists.newArrayList(splitter.split(c.name())); if (l.size() == 2) { cfg.setString(l.get(0), null, l.get(1), c.value()); } else if (l.size() == 3) { cfg.setString(l.get(0), l.get(1), l.get(2), c.value()); } else { throw new IllegalArgumentException( <START> "GerritConfig.name must of the following format" <END> + " section.subsection.name or section.name"); } }</code><technical_language>"must of format"</technical_language>

Target:
static private void parse(Config cfg, GerritConfig c) { ArrayList<String> l = Lists.newArrayList(splitter.split(c.name())); if (l.size() == 2) { cfg.setString(l.get(0), null, l.get(1), c.value()); } else if (l.size() == 3) { cfg.setString(l.get(0), l.get(1), l.get(2), c.value()); } else { throw new IllegalArgumentException( "GerritConfig.name must be of the format" + " section.subsection.name or section.name"); } }
Source:
<code>private static Geometry readPolyline(SliceInput input, boolean multitype) { skipEsriType(input); skipEnvelope(input); int partCount = input.readInt(); if (partCount == 0) { if (multitype) { return GEOMETRY_FACTORY.createMultiLineString(); } <START> else { <END> return GEOMETRY_FACTORY.createLineString(); } } int pointCount = input.readInt(); int[] startIndexes = new int[partCount]; for (int i = 0; i < partCount; i++) { startIndexes[i] = input.readInt(); } int[] partLengths = new int[partCount]; if (partCount > 1) { partLengths[0] = startIndexes[1]; for (int i = 1; i < partCount - 1; i++) { partLengths[i] = startIndexes[i + 1] - startIndexes[i]; } } partLengths[partCount - 1] = pointCount - startIndexes[partCount - 1]; LineString[] lineStrings = new LineString[partCount]; for (int i = 0; i < partCount; i++) { lineStrings[i] = GEOMETRY_FACTORY.createLineString(readCoordinates(input, partLengths[i])); } if (multitype) { return GEOMETRY_FACTORY.createMultiLineString(lineStrings); } else { verify(lineStrings.length == 1); return lineStrings[0]; } }</code><technical_language>unnecessary else</technical_language>

Target:
private static Geometry readPolyline(SliceInput input, boolean multitype) { skipEsriType(input); skipEnvelope(input); int partCount = input.readInt(); if (partCount == 0) { if (multitype) { return GEOMETRY_FACTORY.createMultiLineString(); } return GEOMETRY_FACTORY.createLineString(); } int pointCount = input.readInt(); int[] startIndexes = new int[partCount]; for (int i = 0; i < partCount; i++) { startIndexes[i] = input.readInt(); } int[] partLengths = new int[partCount]; if (partCount > 1) { partLengths[0] = startIndexes[1]; for (int i = 1; i < partCount - 1; i++) { partLengths[i] = startIndexes[i + 1] - startIndexes[i]; } } partLengths[partCount - 1] = pointCount - startIndexes[partCount - 1]; LineString[] lineStrings = new LineString[partCount]; for (int i = 0; i < partCount; i++) { lineStrings[i] = GEOMETRY_FACTORY.createLineString(readCoordinates(input, partLengths[i])); } if (multitype) { return GEOMETRY_FACTORY.createMultiLineString(lineStrings); } verify(lineStrings.length == 1); return lineStrings[0]; }
Source:
<code>public void testHddToVolume() { server.enqueue( new MockResponse().setBody(stringFromResource("/compute/volume.json")) ); <START> org.apache.jclouds.oneandone.rest.domain.Hdd hdd = api.serverApi().getHdd("some-id", "hdd-id"); <END> Volume actual = fnVolume.apply(hdd); Volume expected = new VolumeBuilder() .id(hdd.id()) .size((float) hdd.size()) .bootDevice(hdd.isMain()) .durable(true) .type(Volume.Type.LOCAL).build(); assertEquals(actual, expected); }</code><technical_language>is need mock api calls implement this test</technical_language>

Target:
public void testHddToVolume() { org.apache.jclouds.oneandone.rest.domain.Hdd hdd = org.apache.jclouds.oneandone.rest.domain.Hdd.create("some-id", 40, true); Volume actual = fnVolume.apply(hdd); Volume expected = new VolumeBuilder() .id(hdd.id()) .size((float) hdd.size()) .bootDevice(hdd.isMain()) .durable(true) .type(Volume.Type.LOCAL).build(); assertEquals(actual, expected); }
Source:
<code>private boolean canRemoveVm() { if (IsVmRunning(getVmId()) || (getVm().getStatus() == VMStatus.NotResponding)) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING); } if (getVm().getStatus() == VMStatus.Suspended) { return failCanDoAction(VdcBllMessages.VM_CANNOT_REMOVE_VM_WHEN_STATUS_IS_NOT_DOWN); } if (isVmInPool(getVmId())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_ATTACHED_TO_POOL); } SnapshotsValidator snapshotsValidator = new SnapshotsValidator(); if (!validate(snapshotsValidator.vmNotDuringSnapshot(getVmId()))) { return false; } if (getParameters().getForce() && !validate(snapshotsValidator.vmNotInPreview(getVmId()))) { return false; } if (!ImagesHandler.PerformImagesChecks(getVm(), getReturnValue().getCanDoActionMessages(), getVm().getStoragePoolId(), Guid.Empty, false, !getParameters().getForce(), false, false, !getVm().getDiskMap().values().isEmpty(), true, getVm().getDiskMap().values())) { return false; } <START> if (getVm().getStatus() == VMStatus.ImageLocked) { <END> if (!getParameters().getForce()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_LOCKED); } if (AsyncTaskManager.getInstance().HasTasksByStoragePoolId(getVm().getStoragePoolId())) { return failCanDoAction(VdcBllMessages.VM_CANNOT_REMOVE_HAS_RUNNING_TASKS); } } return true; }</code><technical_language>vmValidator here</technical_language>

Target:
private boolean canRemoveVm() { if (IsVmRunning(getVmId()) || (getVm().getStatus() == VMStatus.NotResponding)) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING); } if (getVm().getStatus() == VMStatus.Suspended) { return failCanDoAction(VdcBllMessages.VM_CANNOT_REMOVE_VM_WHEN_STATUS_IS_NOT_DOWN); } if (isVmInPool(getVmId())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_VM_ATTACHED_TO_POOL); } SnapshotsValidator snapshotsValidator = new SnapshotsValidator(); if (!validate(snapshotsValidator.vmNotDuringSnapshot(getVmId()))) { return false; } if (getParameters().getForce() && !validate(snapshotsValidator.vmNotInPreview(getVmId()))) { return false; } if (!ImagesHandler.PerformImagesChecks(getVm(), getReturnValue().getCanDoActionMessages(), getVm().getStoragePoolId(), Guid.Empty, false, !getParameters().getForce(), false, false, !getVm().getDiskMap().values().isEmpty(), true, getVm().getDiskMap().values())) { return false; } VmValidator vmValidator = new VmValidator(getVm()); ValidationResult vmLockedValidatorResult = vmValidator.vmNotLocked(); if (!vmLockedValidatorResult.isValid()) { if (!getParameters().getForce()) { return failCanDoAction(vmLockedValidatorResult.getMessage()); } if (AsyncTaskManager.getInstance().HasTasksByStoragePoolId(getVm().getStoragePoolId())) { return failCanDoAction(VdcBllMessages.VM_CANNOT_REMOVE_HAS_RUNNING_TASKS); } } return true; }
Source:
<code>public void shouldNotDeadlockOnConcurrentClassInitialization() throws InterruptedException { final ExecutorService executorService = Executors.newFixedThreadPool(2); <START> executorService.execute(new ClassInitializer(javaslang.collection.Iterator.class.getName())); <END> executorService.execute(new ClassInitializer(javaslang.collection.AbstractIterator.class.getName())); executorService.shutdown(); Iterator.empty().iterator(); }</code><technical_language>Iterator AbstractIterator loaded in main thread, thus, concurrency. pass string constants here</technical_language>

Target:
public void shouldNotDeadlockOnConcurrentClassInitialization() throws InterruptedException { final ExecutorService executorService = Executors.newFixedThreadPool(2); executorService.execute(new ClassInitializer("javaslang.collection.Iterator")); executorService.execute(new ClassInitializer("javaslang.collection.AbstractIterator")); executorService.shutdown(); Iterator.empty().iterator(); }
Source:
<code>public static List<String> getTableDataByColumn(WebElement table, int columnIndex) { List<WebElement> rows = getRowsOfTable(table); List<String> data = new ArrayList<>(); for (WebElement row : rows) { data.add(getCellDataByRow(row, columnIndex)); <START> System.out.println(getCellDataByRow(row, columnIndex)); <END> } return data; }</code><technical_language>Please remove this debug helper ;)</technical_language>

Target:
public static List<String> getTableDataByColumn(WebElement table, int columnIndex) { List<WebElement> rows = getRowsOfTable(table); List<String> data = new ArrayList<>(); for (WebElement row : rows) { data.add(getCellDataByRow(row, columnIndex)); } return data; }
Source:
<code>public void executeTask(final CronTaskConfigurationDto config) throws Throwable { final String lastAccessedTimeInDaysText = config.getRequiredProperty(PROPERTY_LAST_ACCESSED_TIME_IN_DAYS); final String minSizeInBytesText = config.getProperty(PROPERTY_MIN_SIZE_IN_BYTES); final Integer lastAccessedTimeInDays; try { lastAccessedTimeInDays = Integer.valueOf(lastAccessedTimeInDaysText); } catch (NumberFormatException ex) { logger.error("Invalid integer value of 'lastAccessedTimeInDays' property. Cron job won't be fired.", lastAccessedTimeInDaysText, ex); return; } Long minSizeInBytes = Long.valueOf(-1); if (minSizeInBytesText != null) { try { minSizeInBytes = Long.valueOf(minSizeInBytesText); } catch (NumberFormatException ex) { <START> logger.error("Invalid Long value of 'minSizeInBytes' property. Cron job won't be fired.", <END> minSizeInBytesText, ex); return; } } proxyRepositoryObsoleteArtifactsCleaner.cleanup(lastAccessedTimeInDays, minSizeInBytes); }</code><technical_language>need for capitalized word here: suggestion logger.error("Invalid long of 'minSizeInBytes' property. Cron job fired.",</technical_language>

Target:
public void executeTask(final CronTaskConfigurationDto config) throws Throwable { final String lastAccessedTimeInDaysText = config.getRequiredProperty(PROPERTY_LAST_ACCESSED_TIME_IN_DAYS); final String minSizeInBytesText = config.getProperty(PROPERTY_MIN_SIZE_IN_BYTES); final Integer lastAccessedTimeInDays; try { lastAccessedTimeInDays = Integer.valueOf(lastAccessedTimeInDaysText); } catch (NumberFormatException ex) { logger.error("Invalid integer value of 'lastAccessedTimeInDays' property. Cron job won't be fired.", lastAccessedTimeInDaysText, ex); return; } Long minSizeInBytes = Long.valueOf(-1); if (minSizeInBytesText != null) { try { minSizeInBytes = Long.valueOf(minSizeInBytesText); } catch (NumberFormatException ex) { logger.error("Invalid long value of 'minSizeInBytes' property. Cron job won't be fired.", minSizeInBytesText, ex); return; } } proxyRepositoryObsoleteArtifactsCleaner.cleanup(lastAccessedTimeInDays, minSizeInBytes); }
Source:
<code>public InputStream openStream(long offset) throws IOException { try { return azureStorage.getBlobInputStream(offset, containerName, blobPath); } catch (StorageException | URISyntaxException e) { if (AzureUtils.AZURE_RETRY.apply(e)) { throw new IOException("Recoverable exception", e); } <START> log.warn("Exception when opening stream to azure resource, containerName: %s, blobPath: %s, Error: %s", <END> containerName, blobPath, e.getMessage() ); throw new RuntimeException(e); } }</code><technical_language>log level error instead of warn</technical_language>

Target:
public InputStream openStream(long offset) throws IOException { try { return azureStorage.getBlobInputStream(offset, containerName, blobPath); } catch (StorageException | URISyntaxException e) { if (AzureUtils.AZURE_RETRY.apply(e)) { throw new IOException("Recoverable exception", e); } log.error("Exception when opening stream to azure resource, containerName: %s, blobPath: %s, Error: %s", containerName, blobPath, e.getMessage() ); throw new RuntimeException(e); } }
Source:
<code><START> private List<VdcOption> moveDependentToEnd(List<VdcOption> list) { <END> Predicate<VdcOption> isDependent = o -> { EnumValue parsed = parseEnumValue(o.getOptionName()); if (parsed != null) { OptionBehaviourAttribute behaviour = parsed.getOptionBehaviour(); if(behaviour == null){ return false; } return behaviour.behaviour() == ValueDependent; } return false; }; List<VdcOption> optionsList = list.stream().filter(isDependent.negate()).collect(Collectors.toList()); optionsList.addAll(list.stream().filter(isDependent).collect(Collectors.toList())); return optionsList; }</code><technical_language>Please reformat methidusing project formatter</technical_language>

Target:
private List<VdcOption> moveDependentToEnd(List<VdcOption> list) { Predicate<VdcOption> isDependent = o -> { EnumValue parsed = parseEnumValue(o.getOptionName()); if (parsed != null) { OptionBehaviourAttribute behaviour = parsed.getOptionBehaviour(); return behaviour != null && behaviour.behaviour() == ValueDependent; } return false; }; List<VdcOption> optionsList = list.stream().filter(isDependent.negate()).collect(Collectors.toList()); optionsList.addAll(list.stream().filter(isDependent).collect(Collectors.toList())); return optionsList; }
Source:
<code>public void provideUniqueRoutesNames() throws Exception { final HashMap<String, Route> routes = new HashMap<>(); routes.put(POD_NAME, newRoute()); doReturn(routes).when(osEnv).getRoutes(); uniqueNamesProvisioner.provision(environment, osEnv, runtimeIdentity); final String actual = osEnv .getRoutes() .values() .stream() .map(r -> r.getMetadata().getName()) .collect(toList()) .get(0); assertTrue(actual.startsWith(ROUTE_PREFIX)); <START> assertTrue(actual.length() == ROUTE_PREFIX.length() + ROUTE_SUFFIX_SIZE); <END> }</code><technical_language>Please, validate added label</technical_language>

Target:
public void provideUniqueRoutesNames() throws Exception { final HashMap<String, Route> routes = new HashMap<>(); routes.put(POD_NAME, newRoute()); doReturn(routes).when(osEnv).getRoutes(); uniqueNamesProvisioner.provision(environment, osEnv, runtimeIdentity); final ObjectMeta routeData = osEnv.getRoutes().values().stream().map(Route::getMetadata).collect(toList()).get(0); assertTrue(routeData.getName().startsWith(ROUTE_PREFIX)); assertTrue(UNIQUE_ROUTE_NAME_REGEX.matcher(routeData.getName()).matches()); assertEquals(routeData.getLabels().get(CHE_ORIGINAL_NAME_LABEL), ROUTE_NAME); }
Source:
<code>private static void assertDocumentPropertiesChanges(DocumentModel doc, Map<String, Object> originalProperties, Set<String> expectedChangedPropertyNames) { <START> originalProperties.keySet().forEach(property -> { <END> Object currentValue = doc.getProperty("dublincore", property); if (expectedChangedPropertyNames.contains(property)) { assertNotEquals(originalProperties.get(property), currentValue); } else { assertEquals(currentValue, originalProperties.get(property)); } }); }</code><technical_language>forEach map</technical_language>

Target:
protected static void assertDocumentPropertiesChanges(DocumentModel doc, Map<String, Object> originalProperties, Set<String> expectedChangedPropertyNames) { originalProperties.forEach((key, value) -> { Object currentValue = doc.getProperty("dublincore", key); if (expectedChangedPropertyNames.contains(key)) { assertNotEquals(value, currentValue); } else { assertEquals(currentValue, value); } }); }
Source:
<code>public void addMeasurement(Integer rssi) { LogManager.d(TAG, "adding rssi: %s", rssi); <START> armaMeasurement = Double.valueOf(armaMeasurement - 0.1*(armaMeasurement - rssi)).intValue(); <END> LogManager.d(TAG, "armaMeasurement: %s", armaMeasurement); }</code><technical_language>0.1 a configurable value? a static class member. default bigger (per general issue)</technical_language>

Target:
public void addMeasurement(Integer rssi) { LogManager.d(TAG, "adding rssi: %s", rssi); if (!isInitialized) { armaMeasurement = rssi; isInitialized = true; }; armaMeasurement = Double.valueOf(armaMeasurement - armaSpeed * (armaMeasurement - rssi)).intValue(); LogManager.d(TAG, "armaMeasurement: %s", armaMeasurement); }
Source:
<code>public ISchedulingRule getRule(int kind, Map<String, String> args) { String pref = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID).get(PREF_SCHEDULING_RULE, null); if (pref != null) { if(pref.equals("project")) return getProject(); <START> else if(pref.equals("null")) { END> return null; } } return super.getRule(kind, args); }</code><technical_language>If decide preference name (for compatbility early adopters), want checking value. if ("null".equals(pref) || Boolean.parse(pref)) { return null; }</technical_language>

Target:
public ISchedulingRule getRule(int kind, Map<String, String> args) { String pref = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID).get(PREF_SCHEDULING_RULE, null); if (pref != null) { if(pref.equals("project")) { return getProject(); } else if(pref.equals("null") || Boolean.parseBoolean(pref)) { return null; } } return super.getRule(kind, args); }
Source:
<code>public Tuple2<List<T>, List<T>> splitAtInclusive(Predicate<? super T> predicate) { Tuple2<List<T>, List<T>> t = splitByPredicateFirstRound(this, predicate); <START> if (!t._2.isEmpty()) { <END> return Tuple.of(t._1.prepend(t._2.head()).reverse(), t._2.tail()); } else { return Tuple.of(t._1.reverse(), t._2); } }</code><technical_language>(minor) I test positive condition isEmpty() swap cases. is information for human brain process ! overseen</technical_language>

Target:
public Tuple2<List<T>, List<T>> splitAtInclusive(Predicate<? super T> predicate) { final Tuple2<List<T>, List<T>> t = splitByPredicateReversed(this, predicate); if (t._2.isEmpty() || t._2.tail().isEmpty()) { return Tuple.of(this, empty()); } else { return Tuple.of(t._1.prepend(t._2.head()).reverse(), t._2.tail()); } }
Source:
<code>public PartialConfig load(File configRepoCheckoutDirectory, PartialConfigLoadContext context) { File[] allFiles = getFiles(configRepoCheckoutDirectory, context); <START> <END> PartialConfig[] allFragments = ParseFiles(allFiles); PartialConfig partialConfig = new PartialConfig(); CollectFragments(allFragments, partialConfig); partialConfig.validatePart(); return partialConfig; }</code><technical_language>Please update method names conform java naming convention for - ParseFiles, CollectFragments, ParseFile</technical_language>

Target:
public PartialConfig load(File configRepoCheckoutDirectory, PartialConfigLoadContext context) { File[] allFiles = getFiles(configRepoCheckoutDirectory, context); PartialConfig[] allFragments = parseFiles(allFiles); PartialConfig partialConfig = new PartialConfig(); collectFragments(allFragments, partialConfig); partialConfig.validatePart(); return partialConfig; }
Source:
<code>public ASTNode visit(TermCons tc, Void _) throws ParseFailedException { ASTNode vis; if (!tc.getProduction().containsAttribute("klabel")) <START> vis = super.visitNode(tc.getContents().get(0), _); <END> else vis = super.visit(tc, _); return vis; }</code><technical_language>this.visitNode</technical_language>

Target:
public ASTNode visit(TermCons tc, Void _) throws ParseFailedException { ASTNode vis; if (!tc.getProduction().containsAttribute("klabel")) vis = this.visitNode(tc.getContents().get(0), _); else vis = super.visit(tc, _); return vis; }
Source:
<code>private Map<String, String> getNodeSelectorMap(String selectors) { ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder(); for (String selector : selectors.split(",")) { String[] parts = selector.split("="); if (parts.length == 2) { <START> if (parts.length == 2) { <END> builder = builder.put(parts[0], parts[1]); } } } return builder.build(); }</code><technical_language>ant: double check of a single field</technical_language>

Target:
private Map<String, String> getNodeSelectorMap(String selectors) { if (selectors.isEmpty()) { return ImmutableMap.of(); } else { ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder(); for (String selector : selectors.split(",")) { String[] parts = selector.split("="); if (parts.length == 2 && !parts[0].isEmpty() && !parts[1].isEmpty()) { builder = builder.put(parts[0], parts[1]); } else { LOGGER.log(Level.WARNING, "Ignoring selector '" + selector + "'. Selectors must be in the format 'label1=value1,label2=value2'."); } } return builder.build(); } }
Source:
<code>private void initApplicationState() { logic = new Logic(uiManager, prefs, Optional.empty(), Optional.empty()); TickingTimer refreshTimer = new TickingTimer("Refresh Timer", TickingTimerManager.DEFAULT_REFRESH_PERIOD_IN_SEC, status::updateTimeToRefresh, logic::refresh, TimeUnit.SECONDS); timerManager = new TickingTimerManager(refreshTimer); <START> timerManager.startTimer(); <END> undoController = new UndoController(notificationController); }</code><technical_language>this named RefreshTimer, encapsulate/subclass timer object? In OO sense a more specific kind of timer refresh intervals such. interface is a plus. responsibility of a 'Manager' is a bit vague IMO</technical_language>

Target:
private void initApplicationState() { logic = new Logic(uiManager, prefs, Optional.empty(), Optional.empty()); apiQuotaManager = new ApiQuotaManager(logic); undoController = new UndoController(notificationController); }
Source:
<code>public void x() throws Exception { HashSet<String> doNotStop = new HashSet<String>(); <START> doNotStop.add("org.eclipse.core.resources"); doNotStop.add("org.eclipse.osgi"); <END> OteServiceStarter service = ServiceUtility.getService(OteServiceStarter.class); if(service != null){ service.stop(); } BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext(); long time = System.currentTimeMillis(); boolean canExit = false; int count = 0; while(!canExit && count < 2000){ count++; canExit = true; for(Bundle b:context.getBundles()){ String symbolicName = b.getSymbolicName(); if(!doNotStop.contains(symbolicName)){ if(b.getState() == Bundle.ACTIVE){ canExit = false; b.stop(); } } } try{ Thread.sleep(20); } catch (Throwable th){ } } System.out.printf("%d ms to shutdown server\n", (System.currentTimeMillis() - time)); System.exit(0); }</code><technical_language>This is of list of "Never stop these". in a config file something</technical_language>

Target:
public void x() throws Exception { long time = System.currentTimeMillis(); OteServiceStarter service = ServiceUtility.getService(OteServiceStarter.class); if(service != null){ service.stop(); } OSGIShutdownUtil.stopBundles(); System.out.printf("%d ms to shutdown server\n", (System.currentTimeMillis() - time)); System.exit(0); }
Source:
<code><START> public void forEachAssignedPartition(Consumer<TopicPartition> consumer) { <END> this.assignment.partitionSet().forEach(consumer); }</code><technical_language>this synchronized</technical_language>

Target:
public synchronized void forEachAssignedPartition(Consumer<TopicPartition> consumer) { this.assignment.partitionSet().forEach(consumer); }
Source:
<code>public void createMultipleUpdateActions() throws Exception { final List<String> contentList = generateAsStrings(MyResource.class); final List<String> expectedContent = expectedContent(MyResource.class); int index = 0; <START> for (String content : contentList) { <END> assertThat(content).isEqualTo(expectedContent.get(index++)); } }</code><technical_language>a for loop for (int index = 0; index < contentList.size; i++) {...</technical_language>

Target:
public void createMultipleUpdateActions() throws Exception { final List<String> contentList = generateAsStrings(MyResource.class); final List<String> expectedContent = expectedContent(MyResource.class); assertThat(contentList).hasSameSizeAs(expectedContent); for (int index = 0; index < contentList.size(); index++) { assertThat(contentList.get(index)).isEqualTo(expectedContent.get(index)); } }
Source:
<code>public static byte[] getInputStreamBytes(InputStream inputStream) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); IOUtils.copy(inputStream, outputStream); <START> return outputStream.toByteArray(); <END> }</code><technical_language>I is save result, close outputStream. i</technical_language>

Target:
public static byte[] getInputStreamBytes(InputStream inputStream) throws IOException { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { IOUtils.copy(inputStream, outputStream); outputStream.toByteArray(); return outputStream.toByteArray(); } }